Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Literal character incorrectly parsed as layout #120

Open
MeAmAnUsername opened this issue Jun 25, 2022 · 0 comments
Open

Literal character incorrectly parsed as layout #120

MeAmAnUsername opened this issue Jun 25, 2022 · 0 comments
Labels
C-Bug Category: bug. Not working as expected

Comments

@MeAmAnUsername
Copy link

Summary

The character - (unary minus) is ignored / parsed as layout

What you did

SDF3:

context-free syntax
  Exp.Num = NAT
  Exp.UnaryMinus = [-[e:Exp]] {layout(indent "-" e && offside "-" e)}
lexical syntax
  NAT = [0-9]+
  LAYOUT = [\ \n\t\v\f\r]

Example file:

-
80

Note the trailing newline in the example file.

What you expected to happen

Parsed as Program(UnaryMinus(Num("80")))

What actually happened

Parsed as Program(Num("80"))

Context

  • Spoofax version: Spoofax-pie 0.19.2
  • Operating system & version: MacOS Mojave, 10.14.6 (18G9323)
  • Java version (if applicable): 11 (bundled with Spoofax)
  • Eclipse version (if applicable): 4.23.0.20220310-1200
  • Gradle version (if applicable): N.A.

Additional information

The layout constraint is important.
The problem does not occur with slightly different inputs. All of the following are expected:
-80 is correctly parsed as Program(UnaryMinus(Num("80"))), regardless of trailing layout

-
 80

80 is indented. This is also correctly parsed as Program(UnaryMinus(Num("80"))).

-
80

No newline after 80. Fails to parse (expected, the offside constraint requires that the 80 is indented). Other layout such as spaces after the 80 gives same result.

-
80
 

Newline with space after 80 fails to parse. Spaces between 80 and newline do not matter (still fails to parse).

@MeAmAnUsername MeAmAnUsername added the C-Bug Category: bug. Not working as expected label Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug Category: bug. Not working as expected
Projects
None yet
Development

No branches or pull requests

1 participant