help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bison error


From: David Fang
Subject: Re: Bison error
Date: Sat, 21 Apr 2007 16:59:28 -0400 (EDT)

> > When i run my parser on a VRML 2.0 file
> > or the DIVE VRML 1.0 parser on a VRML 1.0 file,
> > i get the following error, which is not too
> > informative:
> >
> > redblue.wrl:5: Error:
> > syntax error  before '?'
> >
> > How can i get these error messages more informative,
> > for example how to print the last good token?
>
> Wait until better error reporting has been implemented into Bison
> generated parsers, or tweak the skeleton file (and include it with --/
> %skeleton). :-)

If you understand the [LA]LR algorithm and feel bold enough to hack
into the internal parser stacks, I posted a recipe long ago on how to
properly interpret the YYSTYPE symbols on the stack given the stack of
state transitions.

http://lists.gnu.org/archive/html/help-bison/2006-04/msg00023.html

The original posting was in response to a means of properly deallocating
resources in the event of an error, but I use the same technique to print
the contents of the stack during an error.  (Note: this was before the
%destructor feature, doh!)  The result is a yyerror() that prints the
stack symbols with user-definable print functions.

Maybe the bison developers could use the %destructor type-deducing
mechanism to provide an overrideable %pretty-printer directive for each
type of symbol in the YYSTYPE union type?  (without going through my hoops
and hurdles :) )

David "yacc-wards compatibility" Fang
Computer Systems Laboratory
Electrical & Computer Engineering
Cornell University
http://www.csl.cornell.edu/~fang/
        -- (2400 baud? Netscape 3.0?? lynx??? No problem!)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]