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: Daniele Filaretti <dfilaretti AT gmail.com>
  • To: Radu Mereuta <headness13 AT gmail.com>
  • Cc: k-user AT cs.uiuc.edu
  • Subject: Re: [K-user] parsing error?
  • Date: Wed, 6 Feb 2013 18:34:11 +0000
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

On 6 Feb 2013, at 18:19, Radu Mereuta <headness13 AT gmail.com> wrote:

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].

Oh, well, in fact I had a precedence (I forgot to mention in my question). 
It was 
Exp[Exp] > Id (Exps)

And yes, if I remove the precedence it works. 
To be honest I don't understand why, parsing issues always confuse me :) 
(I mean, my _expression_ -- foo()[0] is an Exp[Exp]. And Exp[Exp] has the precedence. So there should not be any ambiguity I guess?)

Anyway, thanks a lot! 

Cheers, 
Daniele

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