[dev.inline] cmd/compile/internal/syntax: introduce general position info for nodes

Reviewed in and cherry-picked from https://go-review.googlesource.com/#/c/33758/.
Minor adjustments in noder.go to fix merge.

Change-Id: Ibe429e327c7f8554f8ac205c61ce3738013aed98
Reviewed-on: https://go-review.googlesource.com/34231
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2016-11-29 16:13:09 -08:00
parent eaca0e0529
commit 8d20b25779
11 changed files with 380 additions and 111 deletions

View file

@ -15,10 +15,9 @@ type Mode uint
// Error describes a syntax error. Error implements the error interface.
type Error struct {
// TODO(gri) decide what we really need here
Pos int // byte offset from file start
Line int // line (starting with 1)
Msg string
// TODO(gri) Line, Col should be replaced with Pos, eventually.
Line, Col uint
Msg string
}
func (err Error) Error() string {
@ -38,7 +37,7 @@ type Pragma uint16
// A PragmaHandler is used to process //line and //go: directives as
// they're scanned. The returned Pragma value will be unioned into the
// next FuncDecl node.
type PragmaHandler func(pos, line int, text string) Pragma
type PragmaHandler func(line uint, text string) Pragma
// Parse parses a single Go source file from src and returns the corresponding
// syntax tree. If there are syntax errors, Parse will return the first error