Skip to Content.
Sympa Menu

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

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

[K-user] Tokens and Terminals


Chronological Thread 
  • From: Joseph Osborn <joe.osborn AT me.com>
  • To: "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>
  • Subject: [K-user] Tokens and Terminals
  • Date: Wed, 13 Mar 2013 14:58:30 -0700
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

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?






Archive powered by MHonArc 2.6.16.

Top of Page