This is a translation of the yacc-based parser with adjustements
to make the grammar work for a recursive-descent parser followed
by cleanups and simplifications.
The yacc actions were mostly literally copied for correctness
with better temporary names.
A few of the syntax tests were adjusted for slightly different
error messages (it is very difficult to match the yacc-based
error messages in all cases, and sometimes the new parser could
produce better errors).
The new parser is enabled by default.
To switch back to the yacc-based parser, set -oldparser.
To hardwire the switch back, uncomment "oldparser = 1" in lex.go.
- passes all.bash
- ~18% reduced parse time per file on average for make.bash
- ~3% reduced compile time for building cmd/compile
Change-Id: Icb5651bb9d8b9f66261762d2c94a03793050d4ce
Reviewed-on: https://go-review.googlesource.com/16665
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
bug121.go:12:3: error: name list not allowed in interface type
bug121.go:16:2: error: expected signature or type name
semi1.go:10:76: error: unexpected semicolon or newline before ‘{’
semi1.go:10:5: error: reference to undefined name ‘x’
semi1.go:10:8: error: reference to undefined name ‘y’
semi1.go:12:3: error: reference to undefined name ‘z’
semi2.go:10:79: error: unexpected semicolon or newline before ‘{’
semi2.go:10:9: error: reference to undefined name ‘x’
semi3.go:10:79: error: unexpected semicolon or newline before ‘{’
semi3.go:10:6: error: reference to undefined name ‘x’
semi3.go:10:9: error: reference to undefined name ‘y’
semi3.go:10:12: error: reference to undefined name ‘z’
semi3.go:12:3: error: reference to undefined name ‘z’
semi4.go:11:2: error: unexpected semicolon or newline before ‘{’
semi4.go:10:6: error: reference to undefined name ‘x’
semi4.go:12:3: error: reference to undefined name ‘z’
semi5.go:10:1: error: unexpected semicolon or newline before ‘{’
semi7.go:11:2: error: unexpected semicolon or newline before ‘else’
semi7.go:10:5: error: reference to undefined name ‘x’
slice.go:9:11: error: missing lower bound in slice expression
slice.go:9:9: error: reference to undefined name ‘y’
slice.go:9:12: error: reference to undefined name ‘z’
R=rsc
CC=golang-dev
https://golang.org/cl/201061
* example-based syntax errors (go.errors)
* enable bison's more specific errors
and translate grammar token names into
tokens like ++
* test cases
R=ken2, r, ken3
CC=golang-dev
https://golang.org/cl/194085