An "unexpected token: null"
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ling_Tang
Posted On:   Sunday, September 9, 2001 12:12 PM

My parser rules are listed as stmt : (elem|LPAREN stmt RPAREN) ( bop (elem| LPAREN stmt RPAREN) )* ; elem : "ti" WROD; bop : "and"|"or"|"not" ; WORD : ('a'..'z')+ ; LPAREN : '(' ; RPAREN : ')' ; However, when I parser "ti abc and ti efg", it complains with " unexpected token: null", I guess the lexer returned a null token to the parser at the end of the string and the parser still tried to mathch "any" based on the wildcard pattern. Any idea to resolve that. ( If I try to parser "ti abd and (ti efg)", it works fine. )    More>>

My parser rules are listed as

			
stmt : (elem|LPAREN stmt RPAREN)
( bop (elem| LPAREN stmt RPAREN) )*
;

elem : "ti" WROD;

bop : "and"|"or"|"not"
;

WORD : ('a'..'z')+
;

LPAREN : '('
;

RPAREN : ')'
;


However, when I parser "ti abc and ti efg", it complains with " unexpected token: null", I guess the lexer returned a null token to the parser at the end of the string and the parser still tried to mathch "any" based on the wildcard pattern. Any idea to resolve that. ( If I try to parser "ti abd and (ti efg)", it works fine. )


-Ling

   <<Less

Re: An "unexpected token: null"

Posted By:   Monty_Zukowski  
Posted On:   Monday, September 10, 2001 07:16 AM

I don't know offhand, but antlr's source code is easy to understand and follow with a debugger. Look at the stack trace and try to figure out what is null, where it is in the rules that it is getting that.
About | Sitemap | Contact