LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // A parser for Go source files. Input may be provided in a variety of | 5 // A parser for Go source files. Input may be provided in a variety of |
6 // forms (see the various Parse* functions); the output is an abstract | 6 // forms (see the various Parse* functions); the output is an abstract |
7 // syntax tree (AST) representing the Go source. The parser is invoked | 7 // syntax tree (AST) representing the Go source. The parser is invoked |
8 // through one of the Parse* functions. | 8 // through one of the Parse* functions. |
9 // | 9 // |
10 package parser | 10 package parser |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } | 457 } |
458 | 458 |
459 | 459 |
460 func (p *parser) makeIdentList(list *vector.Vector) []*ast.Ident { | 460 func (p *parser) makeIdentList(list *vector.Vector) []*ast.Ident { |
461 idents := make([]*ast.Ident, len(*list)) | 461 idents := make([]*ast.Ident, len(*list)) |
462 for i, x := range *list { | 462 for i, x := range *list { |
463 ident, isIdent := x.(*ast.Ident) | 463 ident, isIdent := x.(*ast.Ident) |
464 if !isIdent { | 464 if !isIdent { |
465 pos := x.(ast.Expr).Pos() | 465 pos := x.(ast.Expr).Pos() |
466 p.errorExpected(pos, "identifier") | 466 p.errorExpected(pos, "identifier") |
467 » » » ident = &ast.Ident{pos, ast.NewObj(ast.Err, pos, "")} | 467 » » » ident = &ast.Ident{pos, ast.NewObj(ast.Err, pos, "_")} |
468 } | 468 } |
469 idents[i] = ident | 469 idents[i] = ident |
470 } | 470 } |
471 return idents | 471 return idents |
472 } | 472 } |
473 | 473 |
474 | 474 |
475 func (p *parser) parseFieldDecl() *ast.Field { | 475 func (p *parser) parseFieldDecl() *ast.Field { |
476 if p.trace { | 476 if p.trace { |
477 defer un(trace(p, "FieldDecl")) | 477 defer un(trace(p, "FieldDecl")) |
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 | 2058 |
2059 // convert declaration list | 2059 // convert declaration list |
2060 decls = make([]ast.Decl, len(list)) | 2060 decls = make([]ast.Decl, len(list)) |
2061 for i, x := range list { | 2061 for i, x := range list { |
2062 decls[i] = x.(ast.Decl) | 2062 decls[i] = x.(ast.Decl) |
2063 } | 2063 } |
2064 } | 2064 } |
2065 | 2065 |
2066 return &ast.File{doc, pos, ident, decls, p.comments} | 2066 return &ast.File{doc, pos, ident, decls, p.comments} |
2067 } | 2067 } |
LEFT | RIGHT |