[antlr-interest] Accepting Erroneus Code in AST construction

Mari Matinlassi mmatinlassi at icinetic.com
Thu Nov 10 01:13:11 PST 2011


Hans-Georg,

A very relevant problem. 
"ANTLR collapses my AST completely to a single error token if some kinds of
mismatches happen."

I would also like to know if a solution is found..

-mari

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Hans-Georg Winkler
Sent: Thursday, November 10, 2011 9:51 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Accepting Erroneus Code in AST construction


Hello,


i'm currently writing a Pascal like language grammar for an editor with
intellisense like features.
It is important that the tree is constructed roughly correct despite
possible errors in the code.
Thats the point where i'm facing some issues with my ANTLR parser.
I already solved some cases but the main problems is that ANTLR collapses my
AST completely to a single error token if some kinds of mismatches happen.


Exapmle:

while_statement
      :	WHILE^ expression DO
 	      statement_section
 	      END_WHILE
      ;


if i have any kind of correct surrounding code (or none) and simply start
typing a new while statement in my editor the parser reduces my complete AST
to a single error token as long as this single statement is incomplete:


<mismatched token: [@11,48:48='<EOF>',<-1>,9:0],
resync=...correctcode...while...correctcode...>


As those mismatches happen in various other szenarios i would like to know
if theres a way to make antlr simply put the error token at the point where
the first mismatch happend instead of making the whole code a mismatch.
I was thinking of changing the recovery but as i'm still new to antlr i
don't really know what should/could be done there.


I hope someone can help me
Georg
 		 	   		  

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address




More information about the antlr-interest mailing list