Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #643

Yacc/Bison - what semantic actions to take on a parse error

From James Harris <james.harris.1@gmail.com>
Newsgroups comp.compilers
Subject Yacc/Bison - what semantic actions to take on a parse error
Date 2012-05-23 04:19 -0700
Organization Compilers Central
Message-ID <12-05-014@comp.compilers> (permalink)

Show all headers | View raw


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]

Back to comp.compilers | Previous | NextNext in thread | Find similar


Thread

Yacc/Bison - what semantic actions to take on a parse error James Harris <james.harris.1@gmail.com> - 2012-05-23 04:19 -0700
  Re: Yacc/Bison - what semantic actions to take on a parse error James Harris <james.harris.1@gmail.com> - 2012-05-24 12:05 -0700
    Re: Yacc/Bison - what semantic actions to take on a parse error James Harris <james.harris.1@gmail.com> - 2012-05-24 22:49 -0700
      Re: Yacc/Bison - what semantic actions to take on a parse error Chris F Clark <cfc@shell01.TheWorld.com> - 2012-05-30 14:41 -0400

csiph-web