SDF3: layout() not constraining
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 inmetaborg.yaml
.
However the test file in this languagewith 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
Issue Log
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.
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.
Thank you for following up!
Log in to post comments