k-user AT lists.cs.illinois.edu
Subject: K-user mailing list
List archive
- From: Mark Hills <Mark.Hills AT cwi.nl>
- To: samira kherfellah <samira.kherfellah AT gmail.com>
- Cc: k-user AT cs.uiuc.edu
- Subject: Re: [K-user] Variables declaration
- Date: Wed, 10 Apr 2013 13:29:10 +0200
- List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
- List-id: <k-user.cs.uiuc.edu>
Hi Samira,
If you want to keep track of the types associated with variables, you would want something like a type environment with a mapping, which would give you rules more like:
rule <k> var X integer ; => . ...</k> <tenv> ... . => X |-> integer ...</tenv>
You could then do lookups against this type environment to get back the types associated with each variable. The rules you give are instead mixing, and constraining, your language types with K types. For instance, the first rule reduces "var X integer ;" to "X:Int", which means that "var X integer ;" goes to "X" in the case where "X" is a K variable standing in for an Int (e.g., "var 5 integer ;"). Assuming that X stands for an Id, you really mean "X:Id" instead.
Cheers,
Mark
samira kherfellah wrote:
Hi all,
I want to declare variables in my program, for this, I added in my syntax:
syntax Vardecl ::= "var" Id TypeVar ";"
syntax TypeVar ::= "integer" | "boolean" | "string"
I added in the semantic, these rules:
rule <k> var X integer ; => X:Int ...</k>
rule <k> var X boolean ; => X:Bool ...</k>
rule <k> var X string ; => X:String ...</k>
In the program test, i have:
...
process p(1);
const M = 5 ;
var i integer;
state init2 #start ;
...
provided (i < M);
...
endstate ;
endprocess;
...
But at compilation, 'i' is not recognized as integer. I forgot something in the syntax or semantics?
Sincerly,
Samira
_______________________________________________
k-user mailing list
k-user AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/k-user
- [K-user] Variables declaration, samira kherfellah, 04/10/2013
- Re: [K-user] Variables declaration, Mark Hills, 04/10/2013
- Re: [K-user] Variables declaration, Mark Hills, 04/10/2013
- Re: [K-user] Variables declaration, Mark Hills, 04/10/2013
Archive powered by MHonArc 2.6.16.