[antlr-interest] Having problems with whitespace...

Wincent Colaiuta win at wincent.com
Tue Jun 26 00:28:48 PDT 2007


El 26/6/2007, a las 6:06, Cameron Esfahani escribió:

> One difference in my grammar is that whitespace is important.  Not  
> necessarily the amount, but where it can be placed.  For example,  
> with most of the grammars I've seen in the book or on the wiki, an  
> input of "100 1" and "1001" would be the same thing, since  
> whitespace is usually shuttled off to channel HIDDEN.  For me, I  
> want an error to occur if you type "100 1", instead of "1001".

I don't know if I've misunderstood your point, but I think that there  
*is* a difference between "100 1" and "1001" even when whitespace is  
being sent on the HIDDEN channel, because in the former case your  
lexer will produce two tokens (for "100" and then "1") and in the  
later only one ("1001"); if your parser rules are looking for just  
one token and they get two then you'll get the error you're looking for.

Cheers,
Wincent



More information about the antlr-interest mailing list