Skip to Content.
Sympa Menu

k-user - Re: [K-user] Tokens and Terminals

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] Tokens and Terminals


Chronological Thread 
  • From: Radu Mereuta <headness13 AT gmail.com>
  • To: Joseph Osborn <joe.osborn AT me.com>
  • Cc: "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>
  • Subject: Re: [K-user] Tokens and Terminals
  • Date: Thu, 14 Mar 2013 00:13:06 +0200
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

Try 

 syntax Atom ::= Token{"main"} 
or
#token("Atom", "main") directly in the rule if you don't want to specify another syntax declaration.

When you say 
syntax Atom ::= "main"
will create the label 'main, and not the constant "main" of type Atom.

Radu


On Wed, Mar 13, 2013 at 11:58 PM, Joseph Osborn <joe.osborn AT me.com> wrote:
Just a short question today:

In my language, I needed a custom lexical rule:

> syntax Atom ::= Token{[a-z][a-zA-Z0-9\_]*}               [onlyLabel]
> syntax Stmt ::= "run" Atom Terms ";"
> syntax Terms ::= List{Atom,","}

But I also need to refer to a certain atom in my initial configuration (like "main" in Cink):

> syntax Atom ::= "main"
>
> ...
>   <k> run main ; </k>
> ...

Unfortunately, I get a stuck configuration after applying this rule to upgrade procedure names from atoms at evaluation time to include an argument count:

> syntax ProcQualifiedName ::= "proc" Atom "/" Int

> rule run PName:Atom Ts => run PName / length(Ts)


(and my stuck configuration is:)

> <k> run main / 0 ; </k>


Which means this rule:

> rule
>   <procs> ...
>     <proc> ...
>       <k> run N:ProcQualifiedName ; => . ... </k>
>     ... </proc>
>     (. => <proc>
>       <k> K </k>
>     </proc>)
>   ... </procs>
>   <proc-def> ...

>     <proc-def-name> N </proc-def-name>
>     <proc-def-body> K </proc-def-body>
>   ... </proc-def>

is not firing, even though my configuration also includes:

> <proc-def>
>   <proc-def-name> proc main / 0 </proc-def-name>
>   <proc-body> ... </proc-body>
> </proc-def>

I think it has to do with the custom lexical rule, because if I remove the bit of the rule that finds the right process definition, I can create empty processes; and otherwise, my code is basically the same as Cink's, which extends #Id.

Is there a way I can create an Atom token that will match properly against an Atom defined in the source file?


_______________________________________________
k-user mailing list
k-user AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/k-user




Archive powered by MHonArc 2.6.16.

Top of Page