I am an ANTLR beginner and want to calculate a SHA1-Hash of symbols.
My simplified example grammar:
grammar Example;
method @after{calculateSha1($text); }: 'call' ID;
ID: 'A'..'Z'+;
WS: (' '|'\n'|'\r')+ {skip(); }
COMMENT: '/*' (options {greedy=false;}: .)* '*/' {$channel=HIDDEN}
As the lexer removes all whitespaces the different strings callABC
, call /* DEF */ ABC
unfortunately get the same SHA1-Hash value.
Is it possible to get the "original" text of a rule between the start- and end-token with all the skipped whitespaces and the text of the other channels?
(One possibility that comes into my mind is to member all characters in the WS
- and COMMENT
-lexer rule, but there are many more rules, so this isn't very practical.)
I use the standard ANTLRInputStream to feed the Lexer, but I don't know how to receive the original text.