Minimal grammar:

context-free syntax

  Start     = Exp

  Exp.Eq    = <<Exp> = <Exp>> {left}
  Exp.Not   = <NOT <Exp>>
  Exp.True  = <true>
  Exp.False = <false>

context-free priorities

  {
    left:
      Exp.Eq
  }
  >
  {
    right:
      Exp.Not
  }

Program:

true = NOT false

Gives error:

Syntax error, not expected here: ' not'

Note that = has a higher priority than NOT (like in SQL), which is different from e.g. Java where ! has a higher priority than ==.

This must be a tough one as existing parsers (e.g. Oracle SQL, MySQL) don’t seem to support the case either, but e.g. PostgressSQL does.

Did I specify the grammar wrongly or is this a bug / known limitation of SDF?

Submitted by Oskar van Rest on 12 February 2018 at 18:50

On 12 February 2018 at 18:59 Jeff Smits commented:

Which parse table generator are you using? Sounds like the kind of problem that was fixed in the new SDF3 priority semantics, which is only implemented in the new Java implementation of sdf2table. Use the following in your metaborg.yaml file to use the Java implementation:

language:
  sdf:
    sdf2table: java

Documented on this page: http://www.metaborg.org/en/latest/source/langdev/meta/lang/sdf3/configuration.html
At this point I think the new implementation is pretty stable and should probably be the default, but Eduardo knows more about the stability.


On 12 February 2018 at 21:50 Oskar van Rest commented:

Thanks, Jeff. However, I changed sdf2table: c into sdf2table: java and cleaned and rebuilt, but I still get the same error.
PS. I’m using Spoofax 2.4.1


On 13 February 2018 at 14:51 Jeff Smits commented:

I tried using a Compiler Construction version of Spoofax I still had installed, and using the Java sdf2table solves the issue there. That’s actually Spoofax 2.3.0, so I wonder if maybe it’s a regression.
EDIT: It also works under 2.4.0, so the issue might be with 2.4.1 or something on your side.


On 13 February 2018 at 19:39 Oskar van Rest commented:

Not sure what I did wrong yesterday, but I tried it again and it works now. Very nice. Closing the issue.


On 13 February 2018 at 19:39 Oskar van Rest closed this issue.

Log in to post comments