[antlr-interest] Please help a newbie!
Peter Ashford
kaffiene at xtra.co.nz
Wed Aug 4 14:36:58 PDT 2004
Peter Ashford wrote:
>Richard Clark wrote:
>
>
>
>>Some of this just takes a Zen approach: becoming one with the
>>documentation. Try adding # in front of the var names in the action
>>(and look at the generated code to see what ANTLR does with it.)
>>
>>
>>assign
>> { float f; }
>> : i:ID EQ f=f_expr { assignTo(#i->getText(),
>>#f); }
>> ;
>>
>> ...R
>>
>>
>>
>>
>>
>
>I appologise for being a pain - but adding the hash just makes the code
>not compile because MSVC .NET thinks it's a preprocessor command.
>
>I have been stepping through the generated code and what I find is the
>parser skipping over all of the possiblities (keywords, comments etc)
>and throwing the no valid alternative exception rather than scanning as
>an identifier
>
>
>
>
I've got it! The problem was my alpha class - I had
protected
ALPHA : ('a'..'z' 'A'..'Z');
I should have had:
protected
ALPHA : ('a'..'z' | 'A'..'Z');
And so identifiers ( ALPHA (ALPHA | DIGIT)*; ) weren't being matched
because they didn't match the incorrect ALPHA pattern.
Richard - thanks very much for your help tracking this problem down.
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