ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
[x] Responses from the above seem to indicate that my issue could be an ANTLR bug
[x] I have done a search of the existing issues to make sure I'm not sending in a duplicate
(note: I'm using 4.13.1, though this isn't relevant)
Since 4.2, the location of <assoc=right> has changed: instead of being after the terminal, it must be at the beginning of the production.
Example before: expr: expr '^'<assoc=right> expr;
Example since 4.2: expr: <assoc=right> expr '^' expr;
While I'm sure there was a good reason for this change, the compiler doesn't report an error if assoc is still after the terminal. It only gives a warning and ignores the attribute, resulting in a potentially undetected erroneous behaviour.
I had this problem, and it took a while for me to find out where it was coming from. It didn't help that The Definitive ANTLR4 Reference was mentioning the former syntax. Indeed, I would expect a change that isn't back-compatible to bump the major version number (too late for that now). Apparently, I'm not the only one to be confused by the problem:
=> I suggest therefore to make the compiler report an error when the assoc isn't at the correct place. By default of a major number bump, that's the only safe way to make sure the users WILL notice the change and update their grammar (or use an older version of ANTLR).
asked atchecked stackoverflow(note: I'm using 4.13.1, though this isn't relevant)
Since 4.2, the location of
<assoc=right>
has changed: instead of being after the terminal, it must be at the beginning of the production.Example before:
expr: expr '^'<assoc=right> expr;
Example since 4.2:expr: <assoc=right> expr '^' expr;
While I'm sure there was a good reason for this change, the compiler doesn't report an error if
assoc
is still after the terminal. It only gives a warning and ignores the attribute, resulting in a potentially undetected erroneous behaviour.I had this problem, and it took a while for me to find out where it was coming from. It didn't help that The Definitive ANTLR4 Reference was mentioning the former syntax. Indeed, I would expect a change that isn't back-compatible to bump the major version number (too late for that now). Apparently, I'm not the only one to be confused by the problem:
488
=> I suggest therefore to make the compiler report an error when the
assoc
isn't at the correct place. By default of a major number bump, that's the only safe way to make sure the users WILL notice the change and update their grammar (or use an older version of ANTLR).