You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
@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
changed the title
[Compiler] Q: Is the grammar correct WRT default types?
Fix ambiguous grammar
Feb 21, 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.
The text was updated successfully, but these errors were encountered: