[antlr-interest] How to write this lexer rule?
chain one
chainone at gmail.com
Wed Jan 14 03:17:43 PST 2009
Thanks Gavin.Really appreciate your help.
The method you provided works!
However the size of the generated .C file could reach to 14M. If I change
the language option to Java, the size of generated .Java file is only 123K.
On Wed, Jan 14, 2009 at 5:50 PM, Gavin Lambert <antlr at mirality.co.nz> wrote:
> At 20:58 14/01/2009, chain one wrote:
>
>> I am still working on this. Searching for solutions that could make the
>> IDENT rule and FUNCTION_DECL work together.
>>
>
> Well, one thing you could try would be:
>
> IDENT
> : ('FUNCTION') => FUNCTION_DECL { $type = FUNCTION_DECL; $channel =
> HIDDEN; }
> | ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
> ;
>
> I wouldn't have thought it'd be necessary, though; ANTLR ought to be able
> to figure that out on its own.
>
> Although -- it's generally a good idea to put the more "vague" lexer rules
> further down, so try making sure that the FUNCTION_DECL rule is listed
> before the IDENT rule (instead of doing the above) and see if that helps.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090114/ef9dc5a4/attachment.html
More information about the antlr-interest
mailing list