bison-patches
[Top][All Lists]
Advanced

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

Re: FYI: default %printer/%destructor


From: Paul Eggert
Subject: Re: FYI: default %printer/%destructor
Date: Thu, 23 Nov 2006 23:13:56 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

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

> And what if X is an alternation of symbols with different types?

Its type would be their discriminated union.

> I still wonder if ISO EBNF is the right language.  Aren't most 
> Lex and Yacc users more familiar with notations like "(...)*", "(...)?", 
> and "(...)+"?

Yes, quite likely.  I wouldn't be a slave to ISO EBNF (particularly
since we're already incompatible with it :-), but it can't hurt to be
inspired by it.

> The argument there isn't about the choice of "/" or "#" or "()" or "[]".  
> It's about the choice of "!" (or "-" in the current discussion) to mean 
> nothing.  I prefer the empty string to mean nothing.

OK, how about this idea?  If rules use the syntax S$A to mean that the
symbol S has a value that can be called $A within an action, then
let's use plain S to mean the symbol doesn't have a value.  That's
even shorter, and simpler.  So, something like this:

  exp:
      NUM$a             { $$ = $a; }
    | '-' exp$a %prec NEG { $$ = - $a; }
    | '(' exp$a ')'       { $$ = $a; }
    | exp$a '+' exp$b   { $$ = $a + $b; }
    | exp$a '-' exp$b   { $$ = $a - $b; }
    | exp$a '*' exp$b   { $$ = $a * $b; }
    | exp$a '/' exp$b   { $$ = $a / $b; }
    | exp$a '^' exp$b   { $$ = pow ($a, $b); }

We issue a diagnostic if the user attempts to combine this new
notation with the old $1, $2, $3 notation.




reply via email to

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