* doc/bison.texi: here.
Formatting changes in some grammars.
Fix a %prec into %precedence.
type_decl: TYPE ID '=' type ';' ;
type_decl: TYPE ID '=' type ';' ;
@comment file: rpcalc.y
@example
@comment file: rpcalc.y
@example
@group
/* Called by yyparse on error. */
@group
/* Called by yyparse on error. */
@comment file: mfcalc.y: 3
@example
@comment file: mfcalc.y: 3
@example
A Bison grammar rule has the following general form:
@example
A Bison grammar rule has the following general form:
@example
@var{result}: @var{components}@dots{};
@var{result}: @var{components}@dots{};
following example, the action is triggered only when @samp{b} is found:
@example
following example, the action is triggered only when @samp{b} is found:
@example
a-or-b: 'a'|'b' @{ a_or_b_found = 1; @};
a-or-b: 'a'|'b' @{ a_or_b_found = 1; @};
@end example
@cindex default action
@end example
@cindex default action
-%nonassoc "then"
-%nonassoc "else"
+%precedence "then"
+%precedence "else"
@end example
Neither solution is perfect however. Since Bison does not provide, so far,
@end example
Neither solution is perfect however. Since Bison does not provide, so far,
-support for ``scoped'' precedence, both force you to declare the precedence
+``scoped'' precedence, both force you to declare the precedence
of these keywords with respect to the other operators your grammar.
Therefore, instead of being warned about new conflicts you would be unaware
of (e.g., a shift/reduce conflict due to @samp{if test then 1 else 2 + 3}
of these keywords with respect to the other operators your grammar.
Therefore, instead of being warned about new conflicts you would be unaware
of (e.g., a shift/reduce conflict due to @samp{if test then 1 else 2 + 3}
Here is another common error that yields a reduce/reduce conflict:
@example
Here is another common error that yields a reduce/reduce conflict:
@example
/* empty */
| sequence words
| sequence redirects
/* empty */
| sequence words
| sequence redirects
-%nonassoc "word"
-%nonassoc "sequence"
+%precedence "word"
+%precedence "sequence"
| name_list ':' type
;
@end group
| name_list ':' type
;
@end group
@group
return_spec:
type
| name ':' type
;
@end group
@group
return_spec:
type
| name ':' type
;
@end group
@group
name: "id";
name_list:
@group
name: "id";
name_list:
rather than the one for @code{name}.
@example
rather than the one for @code{name}.
@example
param_spec:
type
| name_list ':' type
;
param_spec:
type
| name_list ':' type
;
return_spec:
type
| "id" ':' type
;
return_spec:
type
| "id" ':' type
;
@end example
For a more detailed exposition of LALR(1) parsers and parser
@end example
For a more detailed exposition of LALR(1) parsers and parser
@cindex GLR with LALR
When employing GLR parsers (@pxref{GLR Parsers}), if you do not resolve any
@cindex GLR with LALR
When employing GLR parsers (@pxref{GLR Parsers}), if you do not resolve any
-conflicts statically (for example, with @code{%left} or @code{%prec}), then
+conflicts statically (for example, with @code{%left} or @code{%precedence}),
+then
the parser explores all potential parses of any given input. In this case,
the choice of parser table construction algorithm is guaranteed not to alter
the language accepted by the parser. LALR parser tables are the smallest
the parser explores all potential parses of any given input. In this case,
the choice of parser table construction algorithm is guaranteed not to alter
the language accepted by the parser. LALR parser tables are the smallest