aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/nodes.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2016-08-30 16:31:53 -0700
committerMatthew Dempsky <mdempsky@google.com>2016-08-31 19:49:53 +0000
commitee161e859166b8b8b077998c0101f56c18b18329 (patch)
tree17a635ddb65aa89801ea24571b0e0d18489338dd /src/cmd/compile/internal/syntax/nodes.go
parent69e7e8a696825fa818b70587563ac68e52f8b1a1 (diff)
downloadgo-ee161e859166b8b8b077998c0101f56c18b18329.tar.gz
go-ee161e859166b8b8b077998c0101f56c18b18329.zip
cmd/compile: handle pragmas immediately with -newparser=1
Instead of saving all pragmas and processing them after parsing is finished, process them immediately during scanning like the current lexer does. This is a bit unfortunate because it means we can't use syntax.ParseFile to concurrently parse files yet, but it fixes how we report syntax errors in the presence of //line pragmas. While here, add a bunch more gcCompat entries to syntax/parser.go to get "go build -toolexec='toolstash -cmp' std cmd" passing. There are still a few remaining cases only triggered building unit tests, but this seems like a nice checkpoint. Change-Id: Iaf3bbcf2849857a460496f31eea228e0c585ce13 Reviewed-on: https://go-review.googlesource.com/28226 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/syntax/nodes.go')
-rw-r--r--src/cmd/compile/internal/syntax/nodes.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/syntax/nodes.go b/src/cmd/compile/internal/syntax/nodes.go
index e56b1235fe..280a2e8f69 100644
--- a/src/cmd/compile/internal/syntax/nodes.go
+++ b/src/cmd/compile/internal/syntax/nodes.go
@@ -10,6 +10,7 @@ package syntax
type Node interface {
Line() uint32
aNode()
+ init(p *parser)
}
type node struct {
@@ -35,16 +36,10 @@ func (n *node) init(p *parser) {
type File struct {
PkgName *Name
DeclList []Decl
- Pragmas []Pragma
Lines int
node
}
-type Pragma struct {
- Line int
- Text string
-}
-
// ----------------------------------------------------------------------------
// Declarations
@@ -90,6 +85,7 @@ type (
Name *Name
Type *FuncType
Body []Stmt // nil means no body (forward declaration)
+ Pragma Pragma // TODO(mdempsky): Cleaner solution.
EndLine uint32 // TODO(mdempsky): Cleaner solution.
decl
}
@@ -130,7 +126,8 @@ type (
CompositeLit struct {
Type Expr // nil means no literal type
ElemList []Expr
- NKeys int // number of elements with keys
+ NKeys int // number of elements with keys
+ EndLine uint32 // TODO(mdempsky): Cleaner solution.
expr
}