[antlr-interest] Simple questions

Sinan sinan.karasu at boeing.com
Thu Feb 28 09:53:08 PST 2002


Eli Mesika wrote:
> 
> HI folks
> 
> I have a real problem in using '!' in the Antlr Tokens section.
> I have tried Matthew's solution, it doesn't work.
> 
> Attached please find connect.g which describes the "connect" language.
> The language can recognize the following statement:
> (connect a b)
> However, the exact command is
> (connect! a b)
> if you are generating java files from it compiling and running Main it will
> accept (connect a b)
> However if you change the CONNECT token in the .g file to "connect!" and
> test (connect! a b) you
> will get an error.
> 
> Am I missing something ???
> 
> Please HELP.
> Thanks


The way nextToken works in lexer, you have to have a rule that accepts
the token before a hash
table is consulted for keywords.

so do in the lexer

CATCH_LITERAL_TOKENS:  ( "connect!" | "whatever_else_i_want!@#") ;

so on...

you HAVE TO HAVE testLiterals=true; for this to work.....


I think nextToken should check the keyword  table after consuming 
until a special token ( such as WS ) is seen. But both Ter and Ric are
pretty busy these days.....

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list