Skip to Content.
Sympa Menu

k-user - Re: [K-user] parsing error?

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] parsing error?


Chronological Thread 
  • From: Radu Mereuta <headness13 AT gmail.com>
  • To: Daniele Filaretti <dfilaretti AT gmail.com>
  • Cc: k-user AT cs.uiuc.edu
  • Subject: Re: [K-user] parsing error?
  • Date: Wed, 6 Feb 2013 20:19:44 +0200
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

I just wrote this definition:
module TEST
   configuration <T> <k> $PGM:Stmt </k> </T>
   syntax Exp ::= Id "(" Exps ")" // fcall
                     | Exp "[" Exp "]" // array
                     | Int
   syntax Exps ::= List{Exp, ","}
   syntax Stmt ::= Exp ";"
endmodule

Then I tried to parse: "foo()[0];" and it worked fine.

Are you sure you don't have a priority relation between fcall and array? That might reject the correct parsing tree, and would explain why it works with [bracket].
If you still can't find the problem, I could have a look at your entire definition, maybe I can spot what is happening.

Radu
K dev


On Wed, Feb 6, 2013 at 8:06 PM, Daniele Filaretti <dfilaretti AT gmail.com> wrote:
Hi all,
here is another question for you K hackers!

Let say my grammar contains something that looks like

> syntax Exp ::=
>    …
>    | Id "(" Exps ")" // function call
>    | Exp "[" Exp "]"  [seqstrict] // reading a field from an array (the first Exp must evaluate to an array value, the second to a key value)
>    …

and suppose I write a function, "foo()" that returns an array. Now, if in my program I write something like

> foo()[0];

I get a parsing error:

> [Error] Critical: Parse error: Syntax error near unexpected character ';'
>       File: test.php
>       Location: (5,9,5,9)


As an experiment, I tried to add

> syntax Exp ::= "(" Exp ")" [bracket]

and then, if I evaluate

> (foo())[0]:


it works!

Am I missing something or is a parsing problem?

Thanks a lot!

Cheers,
Daniele


_______________________________________________
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