mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: remove gratuituous copying of lexer token data
Rename yySymType to lexer; should eventually capture all lexer state. Embed lexer in parser and access lexer token data directly. Change-Id: I246194705d594f80426f3ba77d8580af9185daf7 Reviewed-on: https://go-review.googlesource.com/19759 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
5621b09dad
commit
11e51ed4bc
2 changed files with 21 additions and 27 deletions
|
|
@ -42,21 +42,10 @@ func parse_file(bin *obj.Biobuf) {
|
|||
}
|
||||
|
||||
type parser struct {
|
||||
tok int32 // next token (one-token look-ahead)
|
||||
op Op // valid if tok == LASOP
|
||||
val Val // valid if tok == LLITERAL
|
||||
sym_ *Sym // valid if tok == LNAME
|
||||
fnest int // function nesting level (for error handling)
|
||||
xnest int // expression nesting level (for complit ambiguity resolution)
|
||||
yy yySymType // for temporary use by next
|
||||
indent []byte // tracing support
|
||||
}
|
||||
|
||||
func (p *parser) next() {
|
||||
p.tok = yylex(&p.yy)
|
||||
p.op = p.yy.op
|
||||
p.val = p.yy.val
|
||||
p.sym_ = p.yy.sym
|
||||
lexer
|
||||
fnest int // function nesting level (for error handling)
|
||||
xnest int // expression nesting level (for complit ambiguity resolution)
|
||||
indent []byte // tracing support
|
||||
}
|
||||
|
||||
func (p *parser) got(tok int32) bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue