[antlr-interest] Parse failing, not sure why

Nick La Rooy nicklarooy at hotmail.com
Fri Feb 3 11:47:06 PST 2012


I'm writing a grammar for Small-C. 

As far as I can tell, my grammar matches the language specification. 

ANTLR generates the Java code with no hiccups. 


However, in the interpreter, ANTLR does not seem to be matching rules that it could match, and instead is returning mismatch exceptions. 



Glaring example: 


Given: 

main()
{
    return 1;
}


The interpreter sends back: 

MismatchedTokenException: line 1:5 mismatched input ')' expecting '\u0016'


But this rule should match: 

main : MAIN LPAREN RPAREN body ;



What could be causing this?

Does rule declaration order make a difference?



Grammars are attached. 
 		 	   		  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SmallCLexer.g
Type: application/octet-stream
Size: 1543 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20120203/80a0e07c/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SmallCParser.g
Type: application/octet-stream
Size: 1185 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20120203/80a0e07c/attachment-0001.obj 


More information about the antlr-interest mailing list