I tried to use ANTLR3 to build a simple Regexpression parser, but it throws the internal error
Here is the Sample.g
grammar Sample;
options {
me
You're trying to use a rewrite rule (tree construction) on a lexer rule. That doesn't make sense.
In ANTLR, all rules with name starting with an uppercase letter are lexer rules. The tree construction is used on AST nodes, not on tokens themselves, so you have to use it on parser rules (starting with lowercase letter).
When you do that, keep in mind that your NL
is a fragment now (you cannot use fragments in parser rules) and make sure your ANY
token doesn't collide with anything else, i.e. define all needed tokens (/
, NL
etc.) and put them above the ANY
token definition.