[antlr-interest] Accepting Erroneus Code in AST construction
Hans-Georg Winkler
hans-georg.winkler at hotmail.com
Thu Nov 10 00:51:20 PST 2011
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
More information about the antlr-interest
mailing list