Related articles |
---|
Yacc/Bison - what semantic actions to take on a parse error james.harris.1@gmail.com (James Harris) (2012-05-23) |
Re: Yacc/Bison - what semantic actions to take on a parse error james.harris.1@gmail.com (James Harris) (2012-05-24) |
Re: Yacc/Bison - what semantic actions to take on a parse error james.harris.1@gmail.com (James Harris) (2012-05-24) |
Re: Yacc/Bison - what semantic actions to take on a parse error cfc@shell01.TheWorld.com (Chris F Clark) (2012-05-30) |
From: | James Harris <james.harris.1@gmail.com> |
Newsgroups: | comp.compilers |
Date: | Wed, 23 May 2012 04:19:36 -0700 (PDT) |
Organization: | Compilers Central |
Keywords: | yacc, errors, comment |
Posted-Date: | 24 May 2012 00:16:28 EDT |
Yacc etc allow the special "error" keyword to be used in rules to aid
error recovery. Where those rules are there to generate a node of a
tree and there has been a parse error what should one tell Yacc to do?
Sometimes there's nothing valid one can build a node from and I can't
find a good way to communicate the situation to Yacc.
I've looked at various options. Some are OK in certain cases but none
seem right in the general case. I'll post more details if interested
but there may be a simple answer.
Anyone know of an easy or a standard answer or can provide some
recommendations?
James
[My standard answer is that the error token is mostly useful for
resynchronizing to try to find some more syntax errors, but that it's
a losing battle to try to do much what you've parsed. Since the
recovery process pops stuff on the stack and throws it away, you're
going to lose some partially parsed subtrees and get a storage leak
unless you hack on the parser skeleton to do something with the stuff
that's popped off. Bison added %destructor to let you do that. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.