Commit 5ae4012b authored by Robert Griesemer's avatar Robert Griesemer

go/parser: use method values

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7858045
parent db53d97a
...@@ -2118,7 +2118,7 @@ func (p *parser) parseStmt() (s ast.Stmt) { ...@@ -2118,7 +2118,7 @@ func (p *parser) parseStmt() (s ast.Stmt) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Declarations // Declarations
type parseSpecFunction func(p *parser, doc *ast.CommentGroup, keyword token.Token, iota int) ast.Spec type parseSpecFunction func(doc *ast.CommentGroup, keyword token.Token, iota int) ast.Spec
func isValidImport(lit string) bool { func isValidImport(lit string) bool {
const illegalChars = `!"#$%&'()*,:;<=>?[\]^{|}` + "`\uFFFD" const illegalChars = `!"#$%&'()*,:;<=>?[\]^{|}` + "`\uFFFD"
...@@ -2237,12 +2237,12 @@ func (p *parser) parseGenDecl(keyword token.Token, f parseSpecFunction) *ast.Gen ...@@ -2237,12 +2237,12 @@ func (p *parser) parseGenDecl(keyword token.Token, f parseSpecFunction) *ast.Gen
lparen = p.pos lparen = p.pos
p.next() p.next()
for iota := 0; p.tok != token.RPAREN && p.tok != token.EOF; iota++ { for iota := 0; p.tok != token.RPAREN && p.tok != token.EOF; iota++ {
list = append(list, f(p, p.leadComment, keyword, iota)) list = append(list, f(p.leadComment, keyword, iota))
} }
rparen = p.expect(token.RPAREN) rparen = p.expect(token.RPAREN)
p.expectSemi() p.expectSemi()
} else { } else {
list = append(list, f(p, nil, keyword, 0)) list = append(list, f(nil, keyword, 0))
} }
return &ast.GenDecl{ return &ast.GenDecl{
...@@ -2343,10 +2343,10 @@ func (p *parser) parseDecl(sync func(*parser)) ast.Decl { ...@@ -2343,10 +2343,10 @@ func (p *parser) parseDecl(sync func(*parser)) ast.Decl {
var f parseSpecFunction var f parseSpecFunction
switch p.tok { switch p.tok {
case token.CONST, token.VAR: case token.CONST, token.VAR:
f = (*parser).parseValueSpec f = p.parseValueSpec
case token.TYPE: case token.TYPE:
f = (*parser).parseTypeSpec f = p.parseTypeSpec
case token.FUNC: case token.FUNC:
return p.parseFuncDecl() return p.parseFuncDecl()
...@@ -2398,7 +2398,7 @@ func (p *parser) parseFile() *ast.File { ...@@ -2398,7 +2398,7 @@ func (p *parser) parseFile() *ast.File {
if p.mode&PackageClauseOnly == 0 { if p.mode&PackageClauseOnly == 0 {
// import decls // import decls
for p.tok == token.IMPORT { for p.tok == token.IMPORT {
decls = append(decls, p.parseGenDecl(token.IMPORT, (*parser).parseImportSpec)) decls = append(decls, p.parseGenDecl(token.IMPORT, p.parseImportSpec))
} }
if p.mode&ImportsOnly == 0 { if p.mode&ImportsOnly == 0 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment