bison-patches
[Top][All Lists]
Advanced

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

Re: FYI: default %destructor/%printer for error, $undefined, $accept


From: Joel E. Denny
Subject: Re: FYI: default %destructor/%printer for error, $undefined, $accept
Date: Mon, 21 Aug 2006 19:53:05 -0400 (EDT)

On Mon, 21 Aug 2006, Paul Eggert wrote:

> "Joel E. Denny" <address@hidden> writes:

> > Can you give me an example of how error token values would be useful?
> 
> Well, I dunno.  Suppose you're parsing HTML and have as a semantic
> value a list of all the href= values in that subtree.  And when you
> parse a busted subtree you still want its href= values.

So, the error token becomes a nonterminal and its RHS is the sequence of 
discarded symbols?

Unfortunately, $n is static, and the RHS length and symbol types aren't 
known until run time here.

Maybe the user could write this:

  error:
    /* empty */      { /* Init $$.  */                                   }
    | error sym1     { /* Append sym1 to $$.  */                         }
    | error SYM2     { /* Append SYM2 to $$.  */                         }
    | error <field1> { /* Automatic rules for syms of type <field1>.  */ }
    | error <field2> { /* Automatic rules for syms of type <field2>.  */ }
    | error %any     { /* Default rule?  */                              }
    ;

Bison would not allow rules of any other form when the LHS is error.  If 
there's no rule for a particular symbol, the parser would discard that 
symbol during error recovery.

(Hmm... I like %any.  I wonder if I should use that for the default 
%destructor/%printer notation instead of just an empty list.)

Joel




reply via email to

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