Hi,
I have a grammar like this :
tokens {
ERROR = 'error';
IF = 'if';
ELSE = 'else';
}
...
variableAssignment
: variable '=' expression
;
variable
: '$' ID
;
errorStatement
: ERROR STRING
;
...
ID
: ('a' .. 'z' | 'A' .. 'Z' | '_') ( 'a' .. 'z' | 'A' .. 'Z' |
'0' .. '9' | '_' )*
;
As you can see, variables are like in Perl with $ in front of them.
Everything works fine until I try to call a variable "$error" or "$if".
If I try to use a variable like $error anywhere in the code, I get a
MismatchedTokenException with a message "mismatched input 'error'
expecting ID". It calls the variable() method in the parser, matches the
$ and then gives an error in this line trying to match the ID:
Match(input,ID,FOLLOW_ID_in_variable1557)
This seems to happen for any word that is already defined in any other rule.
Why is the parser unable to follow the ID after the $, and how can I
make this work to allow any ID after the $?
I'm using C# Antlr 3.1.3.
Thanks.
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.