[antlr-interest] question on simple grammar for tick formatt o decimal conversion

Nagesh, Harsha harsha.nagesh at csfb.com
Wed Nov 30 19:54:05 PST 2005


Micheal - I wanted to exactly avoid the very same problem of writing conditional code
for parsing character by character. I prefer to write the grammar than code :)

Can you please tell me more about the Fancy option - are you saying that I need to
implement a TokenStream which will do this toggling after hitting the MINUS ?

It just occurred to me that this problem is similar to the "island grammars" that
was being discussed recently - here what I am looking for is island lexers, ability
to toggle a lexer in the middle of parsing...

-----------------------------
Fancy option: Use a smart, filtering TokenStream. It implements TokenStream
so your parser can use it as input. It reads from another TokenStream (your
lexer). When it detects the NUM MINUS NUM sequence, it breaks the last NUM
into a series of DIGIT tokens (one for each char in the NUM). Your parser
can now be written to expect 

	NUM (MINUS (DIGIT)+ )?

Cheers,

Micheal


==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer: 

http://www.csfb.com/legal_terms/disclaimer_external_email.shtml

==============================================================================



More information about the antlr-interest mailing list