Skip to Content.
Sympa Menu

k-user - [K-user] Variable declaration

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

[K-user] Variable declaration


Chronological Thread 
  • From: samira kherfellah <samira.kherfellah AT gmail.com>
  • To: k-user AT cs.uiuc.edu
  • Subject: [K-user] Variable declaration
  • Date: Fri, 30 Aug 2013 17:58:03 +0200
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

Hi All,

I have a question about declaring variables in K. 
Here is an example of using variables in my language

var i integer ;
...
task i := i+1; 
...

The variables must be initialized to 0, the rules are defined as follows:

rule <k> var X:Id TV:Type ;  => . ...</k> 
      <tenv>... . => X |-> TV ...</tenv> 
      <store>... . => X |-> 0 ...</store> 

// lookup
rule <k> X:Id => V ...</k>
<store>... X |-> V ...</store> 

rule <k>  task X:Id := I:Int ; => . ...</k> 
<store>... X |-> (_=> I) ...</store> 
<tenv>... X |-> integer ...</tenv>

this way is it correct or there is something else to add? how to initialize variables to 0?

Thanks.

Samira.









Archive powered by MHonArc 2.6.16.

Top of Page