]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/syntax: various cleanups following CL 221603
authorRobert Griesemer <gri@golang.org>
Thu, 5 Mar 2020 22:14:54 +0000 (14:14 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 11 Mar 2020 19:59:39 +0000 (19:59 +0000)
commitf6a0d723859752a2e7c10a470eadd395ba6892a6
tree3e3c8c2412f07ae09a306d2fd37eed607752c775
parenteafb4d8f8f57f52cbb6792aeff535783525186c5
cmd/compile/internal/syntax: various cleanups following CL 221603

1) Introduced setLit method to uniformly set the scanner state for
   literals instead of directly manipulating the scanner fields.

2) Use a local variable 'ok' to track validity of literals instead
   of relying on the side-effect of error reporters setting s.bad.
   More code but clearer because it is local and explicit.

3) s/litname/baseName/ and use this function uniformly, also for
   escapes. Consequently we now report always "hexadecimal" and
   not "hex" (in the case of invalid escapes).

4) Added TestDirectives verifying that we get the correct directive
   string (even if that string contains '%').

Verified that lines/s parsing performance is unchanged by comparing

go test -run StdLib -fast -skip "syntax/(scanner|scanner_test)\.go"

before and after (no relevant difference).

Change-Id: I143e4648fdaa31d1c365fb794a1cae4bc1c3f5ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/222258
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/syntax/scanner.go
src/cmd/compile/internal/syntax/scanner_test.go