[antlr-interest] Switching between literals and keywords
Donovan, Bob
bob.donovan at ugsplm.com
Tue Feb 10 15:01:54 PST 2004
I have a language that I am preparing a grammer for. The language sometimes has dual uses for some of the tokens.
For instance, I sometimes have to match keywords like "integer" in the following phrase:
"define integer constant HostNameLength = 20;"
In this case, I match this phrase with the following:
protected
defineIntegerConstant
: "define" "integer" "constant" ID EQUAL INT ((SEMI)=>SEMI)?
;
But then I sometimes I have other phrases where I don't won't the "integer" keyword returned as the LITERAL_integer, but instead returned as a IDENTIFIER. For example in the following phrase, the word integer could be any type: integer, ObjectPtr, float, boolean, string, etc. In the example below, I need to match "update" COLON ID ID
"define object message EvaluateForFrozen (
update: integer mfail);"
How do I get the lexer to return a INDENTIER instead of a LITERAL_integer?
Thanks, Bob
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list