In Antlr2 there were numerous grammar options that could be set (reference). Now in Antlr3 we have like 1/3 of the amount of options (reference).
So I have two questions concerning this:
To be more specific on my second question, I want to be able to do a few things. First, I want to change the visibility of the generated lexer and parser classes (i.e. Antlr2 option "classHeaderPrefix").
Secondly, I want to be able to ignore any whitespace tokens found within certain keywords, like having "&keyword&" and "& k ey w o rd &" both match (i.e. Antlr2 option "ignore", I think?).
Finally, I want to make certain keywords case insensitive (i.e. Antlr2 option "caseSensitive").
BluePlateSpecial wrote:
To be more specific on my second question, I want to be able to do a few things. First, I want to change the visibility of the generated lexer and parser classes (i.e. Antlr2 option "classHeaderPrefix").
In v3 there is no way to do this.
BluePlateSpecial wrote:
Secondly, I want to be able to ignore any whitespace tokens found within certain keywords, like having "&keyword&" and "& k ey w o rd &" both match (i.e. Antlr2 option "ignore", I think?).
That options might have been removed because the LL(*) algorithm in the lexer is far more powerful than what was used in v2. Now, there is no need for such an option since this would do the trick:
FOO
: '&' (' ' | 'a'..'z')+ '&'
;
BluePlateSpecial wrote:
Finally, I want to make certain keywords case insensitive (i.e. Antlr2 option "caseSensitive").
That is also not possible in v3 other than doing it the "hard" way:
BAR
: ('b' | 'B') ('a' | 'A') ('r' | 'R')
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With