Skip to content

Commit abb818b

Browse files
mdempskygriesemer
authored andcommitted
spec: fix binary expression grammar rule
The spec explains later in the "Operator precedence" section that * has a higher precedence than +, but the current production rule requires that "1 + 2 * 3" be parsed as "(1 + 2) * 3", instead of the intended "1 + (2 * 3)". The new production rule better matches cmd/internal/gc/go.y's grammar: expr: uexpr | expr LOROR expr | expr LANDAND expr | ... Fixes #10151. Change-Id: I13c9635d6ddf1263cafe7cc63e68f3e5779e24ba Reviewed-on: https://go-review.googlesource.com/9163 Reviewed-by: Robert Griesemer <gri@golang.org>
1 parent 99475df commit abb818b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doc/go_spec.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--{
22
"Title": "The Go Programming Language Specification",
3-
"Subtitle": "Version of March 20, 2015",
3+
"Subtitle": "Version of April 22, 2015",
44
"Path": "/ref/spec"
55
}-->
66

@@ -3305,7 +3305,7 @@ <h3 id="Operators">Operators</h3>
33053305
</p>
33063306

33073307
<pre class="ebnf">
3308-
Expression = UnaryExpr | Expression binary_op UnaryExpr .
3308+
Expression = UnaryExpr | Expression binary_op Expression .
33093309
UnaryExpr = PrimaryExpr | unary_op UnaryExpr .
33103310

33113311
binary_op = "||" | "&amp;&amp;" | rel_op | add_op | mul_op .

0 commit comments

Comments
 (0)