[antlr-interest] Problem Writing Lexer Rule

Jason jasonriz at yahoo.com
Fri Mar 5 12:31:16 PST 2004


Hello,

The following is a snippet of a grammar I've written:

protected NOT_CB:        ~']';
protected ESC_CB:        "]]";
protected TEMP_D:        NOT_CB | ESC_CB;
protected DELIM_ID:      '['  (TEMP_D)+ ']';
REG_OR_DELIM_ID: DELIM_ID;

It fails on the following input: 

  [aaa].[bbb]

complaining thusly:

  expecting ']', found '.'

I've looked at the generated code and the problem
occurs after the last 'a' has been processed and LA(1)
= ']' and LA(2) = '.'.  The lookahead checks in
mDELIM_ID are constructed such that "]." passes and
mTEMP_D( ) gets called and then of course fails.  This
seems like a job for syntactic predicates but I can't
seem to get it straightened out.  Any guidence would
be greatly appreciated.  Thanks in advance.

-jason

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com


 
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