@end deffn
@deffn {Directive} %default-prec
-Specify whether to assign a precedence to rules lacking an
-explicit @code{%prec} modifier
+Assign a precedence to rules lacking an explicit @code{%prec} modifier
(@pxref{Contextual Precedence, ,Context-Dependent Precedence}).
@end deffn
Program}.
@end deffn
+@deffn {Directive} %no-default-prec
+Do not assign a precedence to rules lacking an explicit @code{%prec}
+modifier (@pxref{Contextual Precedence, ,Context-Dependent
+Precedence}).
+@end deffn
+
@deffn {Directive} %no-parser
Do not include any C code in the parser file; generate tables only. The
parser file contains just @code{#define} directives and static variable
This kind of problem can be tricky to debug, since one typically
discovers the mistake only by testing the code.
-The @code{%default-prec 0;} declaration makes it easier to discover
+The @code{%no-default-prec;} declaration makes it easier to discover
this kind of problem systematically. It causes rules that lack a
@code{%prec} modifier to have no precedence, even if the last terminal
symbol mentioned in their components has a declared precedence.
-If @code{%default-prec 0;} is in effect, you must specify @code{%prec}
+If @code{%no-default-prec;} is in effect, you must specify @code{%prec}
for all rules that participate in precedence conflict resolution.
Then you will see any shift/reduce conflict until you tell Bison how
to resolve it, either by changing your grammar or by adding an
explicit precedence. This will probably add declarations to the
grammar, but it helps to protect against incorrect rule precedences.
-The effect of @code{%default-prec 0;} can be reversed by giving
-@code{%default-prec 1;}, which is the default.
+The effect of @code{%no-default-prec;} can be reversed by giving
+@code{%default-prec;}, which is the default.
@node Parser States
@section Parser States
Equip the parser for debugging. @xref{Decl Summary}.
@end deffn
-@deffn {Directive} %default-prec @var{state};
-Bison declaration to specify whether to assign a precedence to rules
-that lack an explicit @samp{%prec} modifier. @xref{Contextual
-Precedence, ,Context-Dependent Precedence}.
+@deffn {Directive} %default-prec
+Assign a precedence to rules that lack an explicit @samp{%prec}
+modifier. @xref{Contextual Precedence, ,Context-Dependent
+Precedence}.
@end deffn
@deffn {Directive} %defines
Bison declaration to rename the external symbols. @xref{Decl Summary}.
@end deffn
+@deffn {Directive} %no-default-prec
+Do not assign a precedence to rules that lack an explicit @samp{%prec}
+modifier. @xref{Contextual Precedence, ,Context-Dependent
+Precedence}.
+@end deffn
+
@deffn {Directive} %no-lines
Bison declaration to avoid generating @code{#line} directives in the
parser file. @xref{Decl Summary}.
PERCENT_LEX_PARAM "%lex-param {...}"
PERCENT_LOCATIONS "%locations"
PERCENT_NAME_PREFIX "%name-prefix"
+ PERCENT_NO_DEFAULT_PREC "%no-default-prec"
PERCENT_NO_LINES "%no-lines"
PERCENT_NONDETERMINISTIC_PARSER
"%nondeterministic-parser"
symbol_printer_set (list->sym, $1, list->location);
symbol_list_free ($2);
}
-| "%default-prec" INT
+| "%default-prec"
{
- if (0 <= $2 && $2 <= 1)
- default_prec = $2;
- else
- complain_at (@1, _("invalid value for `%default-prec'"));
+ default_prec = true;
+ }
+| "%no-default-prec"
+ {
+ default_prec = false;
}
;
AT_CLEANUP
-## ---------------------------- ##
-## %default-prec without %prec ##
-## ---------------------------- ##
+## ------------------------------- ##
+## %no-default-prec without %prec ##
+## ------------------------------- ##
-AT_SETUP([%default-prec without %prec])
+AT_SETUP([%no-default-prec without %prec])
AT_DATA([[input.y]],
[[%left '+'
%%
-%default-prec 0;
+%no-default-prec;
e: e '+' e
| e '*' e
AT_CLEANUP
-## ------------------------- ##
-## %default-prec with %prec ##
-## ------------------------- ##
+## ---------------------------- ##
+## %no-default-prec with %prec ##
+## ---------------------------- ##
-AT_SETUP([%default-prec with %prec])
+AT_SETUP([%no-default-prec with %prec])
AT_DATA([[input.y]],
[[%left '+'
%%
-%default-prec 0;
+%no-default-prec;
e: e '+' e %prec '+'
| e '*' e %prec '*'
## ---------------- ##
-## %default-prec 1 ##
+## %default-prec ##
## ---------------- ##
-AT_SETUP([%default-prec 1])
+AT_SETUP([%default-prec])
AT_DATA([[input.y]],
[[%left '+'
%%
-%default-prec 1;
+%default-prec;
e: e '+' e
| e '*' e