[antlr-interest] question on simple grammar for tick format
t o decimal conversion
Nagesh, Harsha
harsha.nagesh at csfb.com
Wed Nov 30 18:14:11 PST 2005
Thanks Micheal ! that fixed my problem.
Another question. In antlr is it possible to turn off a particular literal while
parsing the token stream ? For example - if I have a string "43242-3465678",
and I define "NUM" as (DIGIT)+, till I hit the "-" sign I would like to get
the first part, i.e "43242" as NUM (single token), but after I hit "-", I want
to the parser to start treating the right side of the string as single DIGITs
and not a complete number i.e I don't want to get token of type NUM anymore.
Is it possible to do this ?
Thanks,
Harsha
-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org]On Behalf Of Micheal J
Sent: Wednesday, November 30, 2005 8:29 PM
To: antlr-interest at antlr.org
Subject: RE: [antlr-interest] question on simple grammar for tick format
to decimal conversion
> parse returns [decimal result]
> {result = -1.0;}
> : Number (MINUS DigitsA)? EOF
>
> Number: (DigitsA | DigitsB | DigitsC)+
> ;
>
> My lexer has the following literals
<SNIP>
> But antlr is complaining that "Lexical rule Number defined
> outside of lexer. Exiting due to errors"
>
> Can somebody explain what is wrong here ?
ANTLR parser rules cannot begin with an upper-case char. Trying changing
"Number" to "number".
Micheal
==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.csfb.com/legal_terms/disclaimer_external_email.shtml
==============================================================================
More information about the antlr-interest
mailing list