I have this test SDF3 grammar:

context-free sorts
  Start Adjective Noun Preposition
context-free syntax
  Start.Phrase  = <<Adjective+> <Noun>>
  Start.Prep    = <<Preposition> <Start>> {layout(0.first.line == 1.first.line)}

  Adjective.Big   = <big>
  
  Noun.Lemur  = <lemurs>
  
  Preposition.With = <with>
  Preposition.IFO  = <in front of>

and I have the SDF3 parameter jsglr-version: layout-sensitive set in metaborg.yaml.
However the test file in this language

with
  big lemurs

successfully parses to Prep(With(), Phrase([Big()], Lemur())). I would expect it to fail to parse, since it must use the Prep rule, the 0th child of which matches ‘with’ and the 1st child of which matches ‘big lemurs’, but the respective lines of the first characters of these matches are not equal as stipulated in the rule.

Submitted by Glen Whitney on 7 February 2021 at 01:04

On 9 February 2021 at 10:38 Jasper Denkers commented:

As discussed on Slack, tree selectors are 1-based instead of 0-based.

Changing the layout constraint to {layout(1.first.line == 2.first.line)} results in the desired behavior.


On 9 February 2021 at 10:38 Jasper Denkers closed this issue.

On 10 February 2021 at 16:48 Glen Whitney commented:

I agree the issue is closed, but to avoid any future confusion, subsequent to this issue report, the Spoofax team rebased the tree selectors to be 0-based, so now the grammar as originally reported works as expected, and the changed 1-based syntax would not work. My thanks to all involved.


On 11 February 2021 at 17:23 Jasper Denkers commented:

Thank you for following up!

Log in to post comments