[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RFC: explicit empty right-hand side of a rule
From: |
Akim Demaille |
Subject: |
RFC: explicit empty right-hand side of a rule |
Date: |
Wed, 30 Jan 2013 14:40:42 +0100 |
Hi all, (Hi Joel, happy new year!)
We have been toying with the introduction of a means to explicitly
mark empty right-hand sides of rules. It's on the explicit-empty
branch on gnu.org's repository. It allows to write
exp: $empty { … }
and it's an exact synonym for
exp: /* nothing. */ { … }
except that:
- bison does check that there is just $empty and nothing else
- it will provide a warning to report implicit empty rhs
- the various reports (e.g., foo.output, foo.dot) will use
$empty (or maybe ε where possible) instead of nothing (or
/* empty. */ as is done in some cases).
I would be happy to receive opinions about this feature, and also
suggestions for the name for this pseudo-symbol.
It is far from being bullet proof, for instance I'm pretty
confident you can give this $empty a name-for-references, which
is absurd.
There is one corner case whose treatment is currently unclear:
mid-rule actions. Currently
exp: $empty { $$ = foo(); } $empty { $$ = bar(); }
is rejected, because I don't think accepting $empty in this situation
actually helping.
/tmp/foo.y:2.6-11: error: $empty must be alone on the right-hand side of the
rule
exp: $empty { $$ = foo(); } $empty { $$ = bar(); }
^^^^^^
/tmp/foo.y:2.29-34: error: $empty must be alone on the right-hand side of the
rule
exp: $empty { $$ = foo(); } $empty { $$ = bar(); }
^^^^^^
Cheers!
- RFC: explicit empty right-hand side of a rule,
Akim Demaille <=