diff options
author | Robert Griesemer <gri@golang.org> | 2015-11-04 09:21:49 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2015-11-13 14:53:57 +0000 |
commit | b569b87ca1f6905ed38cafc2bae6e26f4ec416b7 (patch) | |
tree | 40809baaf4b3cde32d2c87c84382fb6dba3e2740 /test/syntax | |
parent | b5c1b5d7a035d589c5a970f17b7e0c52441d5d34 (diff) | |
download | go-b569b87ca1f6905ed38cafc2bae6e26f4ec416b7.tar.gz go-b569b87ca1f6905ed38cafc2bae6e26f4ec416b7.zip |
cmd/compile/internal/gc: recursive-descent parser
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>
Diffstat (limited to 'test/syntax')
-rw-r--r-- | test/syntax/chan.go | 6 | ||||
-rw-r--r-- | test/syntax/forvar.go | 1 | ||||
-rw-r--r-- | test/syntax/semi4.go | 2 | ||||
-rw-r--r-- | test/syntax/semi6.go | 6 | ||||
-rw-r--r-- | test/syntax/semi7.go | 2 | ||||
-rw-r--r-- | test/syntax/vareq1.go | 2 |
6 files changed, 9 insertions, 10 deletions
diff --git a/test/syntax/chan.go b/test/syntax/chan.go index 3b68bda35f..b016790fe7 100644 --- a/test/syntax/chan.go +++ b/test/syntax/chan.go @@ -8,10 +8,10 @@ package main type xyz struct { ch chan -} // ERROR "unexpected .*}.* in channel type" +} // ERROR "unexpected .*}.* in channel type|missing channel element type" -func Foo(y chan) { // ERROR "unexpected .*\).* in channel type" +func Foo(y chan) { // ERROR "unexpected .*\).* in channel type|missing channel element type" } -func Bar(x chan, y int) { // ERROR "unexpected comma in channel type" +func Bar(x chan, y int) { // ERROR "unexpected comma in channel type|missing channel element type" } diff --git a/test/syntax/forvar.go b/test/syntax/forvar.go index dc592d2b64..043c299040 100644 --- a/test/syntax/forvar.go +++ b/test/syntax/forvar.go @@ -7,4 +7,5 @@ package main func main() { + var x int // avoid undefined: x error below with recursive-descent parser for var x = 0; x < 10; x++ { // ERROR "var declaration not allowed in for initializer" diff --git a/test/syntax/semi4.go b/test/syntax/semi4.go index 99c2d22561..1f4e679cf8 100644 --- a/test/syntax/semi4.go +++ b/test/syntax/semi4.go @@ -8,7 +8,7 @@ package main func main() { for x // GCCGO_ERROR "undefined" - { // ERROR "missing .*{.* after for clause" + { // ERROR "missing .*{.* after for clause|missing operand" z // GCCGO_ERROR "undefined" diff --git a/test/syntax/semi6.go b/test/syntax/semi6.go index c1e1cc363a..1b51d8ba7e 100644 --- a/test/syntax/semi6.go +++ b/test/syntax/semi6.go @@ -7,7 +7,5 @@ package main type T // ERROR "unexpected semicolon or newline in type declaration" -{ - - - +// line below uncommented to avoid follow-up error +// {
\ No newline at end of file diff --git a/test/syntax/semi7.go b/test/syntax/semi7.go index 6c9ade8bc2..357352dea9 100644 --- a/test/syntax/semi7.go +++ b/test/syntax/semi7.go @@ -8,7 +8,7 @@ package main func main() { if x { } // GCCGO_ERROR "undefined" - else { } // ERROR "unexpected semicolon or newline before .?else.?" + else { } // ERROR "unexpected semicolon or newline before .?else.?|unexpected else" } diff --git a/test/syntax/vareq1.go b/test/syntax/vareq1.go index e900eabebe..d4952fedd7 100644 --- a/test/syntax/vareq1.go +++ b/test/syntax/vareq1.go @@ -6,5 +6,5 @@ package main -var x map[string]string{"a":"b"} // ERROR "unexpected { at end of statement|expected ';' or newline after top level declaration" +var x map[string]string{"a":"b"} // ERROR "unexpected { at end of statement|unexpected { after top level declaration|expected ';' or newline after top level declaration" |