[antlr-interest] Re: Parsing Identifiers
Pankaj Rao
pmrao7 at gmail.com
Tue Jun 13 16:19:03 PDT 2006
Hi Terence,
Yes I did have the '?' rule before the Ident rule, and that was the issue.
Thanks for your suggestion.
--Pankaj
> Hi All,
>
> I have encoutered this special case while writing my parser and I
> am trying to figure out the cleanest way to handle this.
>
> What I am trying to do is be able to parse identifiers having
> characters beyond alphabets and numbers , for example "?name" or
> "%name"
>
> My lexer rule for parsing identifiers is as follows:
>
> IDENT
>
> : ('a'..'z' | 'A'..'Z' | '_' | '$' ) ( ('a'..'z' | 'A'..'Z' |
> '_' | '$' ) | ('0'..'9' ))*
>
> ;
> So I thought about modyfing my Identifier rule to look for '?'.
>
> IDENT
>
> : ('a'..'z' | 'A'..'Z' | '_' | '$'|'?' ) ( ('a'..'z' | 'A'..'Z'
> | '_' | '$' | '?') | ('0'..'9' ))*
>
> ;
My guess is that you also have a '?' rule, which is first and hence
has priority :)
Ter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060613/0b80e010/attachment.html
More information about the antlr-interest
mailing list