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

Fix ambiguous grammar #129

Open
wwerner opened this issue Feb 7, 2020 · 2 comments
Open

Fix ambiguous grammar #129

wwerner opened this issue Feb 7, 2020 · 2 comments
Labels
bug Something isn't working P:1 Highest Priority

Comments

@wwerner
Copy link
Contributor

wwerner commented Feb 7, 2020

We have some ambiguous rules for numbers, i.e. BYTE_LITERAL and DECIMAL_LITERAL, so antlr matches the one that was defined first.

In int answer = 42 , it matches the number as BYTE_LITERAL and complains that it requires an INT_LITERAL . Once the number contains underscores or exceeds the byte range, it matches correctly.

Now I'm wondering whether I missed sth. (antlr version/config) or if it is just an error. That was implemented before my time so I can't say whether there is a reason for it I don't understand or if it's just a bug.

@VaughnVernon
Copy link
Contributor

VaughnVernon commented Feb 7, 2020

@wwerner In Java a byte literal is an int that is cast to a byte. Thus, I think you should eliminate BYTE_LITERAL and use INT_LITERAL for both bytes and ints. The one difference is that you must check for min/max byte range, Byte.MIN_VALUE and Byte.MAX_VALUE.

@wwerner wwerner changed the title [Compiler] Q: Is the grammar correct WRT default types? Fix ambiguous grammar Feb 21, 2020
@wwerner wwerner self-assigned this Feb 21, 2020
@wwerner wwerner added bug Something isn't working P:1 Highest Priority labels Feb 24, 2020
@wwerner wwerner removed their assignment Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P:1 Highest Priority
Projects
None yet
Development

No branches or pull requests

2 participants