mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-13 22:33:03 +00:00
grammar: introduce %empty
Provide a means to explicitly denote empty right-hand sides of rules:
instead of
exp: { ... }
allow
exp: %empty { ... }
Make sure that %empty is properly used.
With help from Joel E. Denny and Gabriel Rassoul.
http://lists.gnu.org/archive/html/bison-patches/2013-01/msg00142.html
* src/reader.h, src/reader.c (grammar_current_rule_empty_set): New.
* src/parse-gram.y (%empty): New token.
Use it.
* src/scan-gram.l (%empty): Scan it.
* src/reader.c (grammar_rule_check): Check that %empty is properly used.
* tests/actions.at (Invalid uses of %empty, Valid uses of %empty): New.
This commit is contained in:
@@ -605,6 +605,7 @@ rhses.1:
|
||||
| rhses.1 ";"
|
||||
;
|
||||
|
||||
%token PERCENT_EMPTY "%empty";
|
||||
rhs:
|
||||
/* Nothing. */
|
||||
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
|
||||
@@ -615,6 +616,8 @@ rhs:
|
||||
{ grammar_current_rule_action_append ($2, @2, $3, false); }
|
||||
| rhs "%?{...}"
|
||||
{ grammar_current_rule_action_append ($2, @2, NULL, true); }
|
||||
| rhs "%empty"
|
||||
{ grammar_current_rule_empty_set (@2); }
|
||||
| rhs "%prec" symbol
|
||||
{ grammar_current_rule_prec_set ($3, @3); }
|
||||
| rhs "%dprec" INT
|
||||
|
||||
Reference in New Issue
Block a user