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

VL: implizite Token in ANTLR klarer darstellen #321

Open
cagix opened this issue Jan 8, 2025 · 0 comments
Open

VL: implizite Token in ANTLR klarer darstellen #321

cagix opened this issue Jan 8, 2025 · 0 comments

Comments

@cagix
Copy link
Member

cagix commented Jan 8, 2025

Die Verwendung von Literalen in Parser-Regeln für zu impliziten Token, die vor den selbst definierten Token-Regeln Vorrang haben.

fndecl  :  type ID '(' params? ')' '=' '0' ;
expr    :  NUMBER ;
NUMBER  :  [0-9]+ ;

Die "0" wird zu einem impliziten Token, d.h. während "01" und "10" als "NUMBER" gematcht werden, wird "0" nicht als "NUMBER" erkannt ... Entsprechend schlagen dann die Parser-Regeln mit einem "mismatched input" fehl ...

Das sollte im Skript deutlicher hervorgehoben werden, da es eine typische Stolperfalle ist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant