[antlr-interest] Overloaded Lexemes!

Steve Taplin steve_taplin at yahoo.co.uk
Mon May 3 06:06:31 PDT 2004


> >>>>> "Steve" == Steve Taplin <steve_taplin at yahoo.co.uk> writes:
> [...]
> 
> > Out of interest, the language I am parsing is quite poorly behaved.
> That
> > is, the string literals are not really identified syntactically
(only
> > semantically).  E.g.
> 
> > COMMENT TEXT(The next line prints an unblinking text string "My
> > label")\r\n PRINT XCOORD(10 + X) YCOORD(20 + Y) LABEL(My label)
> > BLINK(N)\r\n
> 
> > The language follows pattern of:
> 
> > COMMAND (PARAMETER)* '\r''\n'
> 
> Given your examples, isn't that more like:
> 
> COMMAND ( PARAMETER_NAME "(" parameter_data ")" )* "\r\n"
>

Yes. (I over simplified for brevity) :-)
 
> 
> > Clearly, some values within the parentheses will need to be
tokenised
> > further whereas string literals need to be sent as tokens there and
> then.
> 
> Are the types of the "parameter data" based on the name of the
> parameter?  If so, are the types of the parameter names fixed (i.e.,
are
> they keywords) or do you only know them semantically (i.e., are they
only
> known dynamically)?
> 
> Take care,
> 	John

Yes they are.  Each parameter 'keyword' will contain data of a
particular type - this behaviour is constant.  I presume you are
suggesting that I make the lexer 'aware' of these keywords and
subsequently place lexer rules for each based on its predicted
behaviour? Activities normally exercised by the parser...

Steve



 
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