LEFT | RIGHT |
(no file at all) | |
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 // Package parser implements a parser for Go source files. Input may be | 5 // Package parser implements a parser for Go source files. Input may be |
6 // provided in a variety of forms (see the various Parse* functions); the | 6 // provided in a variety of forms (see the various Parse* functions); the |
7 // output is an abstract syntax tree (AST) representing the Go source. The | 7 // output is an abstract syntax tree (AST) representing the Go source. The |
8 // parser is invoked through one of the Parse* functions. | 8 // parser is invoked through one of the Parse* functions. |
9 // | 9 // |
10 package parser | 10 package parser |
(...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1902 var path *ast.BasicLit | 1902 var path *ast.BasicLit |
1903 if p.tok == token.STRING { | 1903 if p.tok == token.STRING { |
1904 path = &ast.BasicLit{p.pos, p.tok, p.lit} | 1904 path = &ast.BasicLit{p.pos, p.tok, p.lit} |
1905 p.next() | 1905 p.next() |
1906 } else { | 1906 } else { |
1907 p.expect(token.STRING) // use expect() error handling | 1907 p.expect(token.STRING) // use expect() error handling |
1908 } | 1908 } |
1909 p.expectSemi() // call before accessing p.linecomment | 1909 p.expectSemi() // call before accessing p.linecomment |
1910 | 1910 |
1911 // collect imports | 1911 // collect imports |
1912 » spec := &ast.ImportSpec{doc, ident, path, p.lineComment} | 1912 » spec := &ast.ImportSpec{doc, ident, path, p.lineComment, token.NoPos} |
1913 p.imports = append(p.imports, spec) | 1913 p.imports = append(p.imports, spec) |
1914 | 1914 |
1915 return spec | 1915 return spec |
1916 } | 1916 } |
1917 | 1917 |
1918 func parseConstSpec(p *parser, doc *ast.CommentGroup, iota int) ast.Spec { | 1918 func parseConstSpec(p *parser, doc *ast.CommentGroup, iota int) ast.Spec { |
1919 if p.trace { | 1919 if p.trace { |
1920 defer un(trace(p, "ConstSpec")) | 1920 defer un(trace(p, "ConstSpec")) |
1921 } | 1921 } |
1922 | 1922 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 assert(ident.Obj == unresolved, "object already resolved") | 2162 assert(ident.Obj == unresolved, "object already resolved") |
2163 ident.Obj = p.pkgScope.Lookup(ident.Name) // also removes unreso
lved sentinel | 2163 ident.Obj = p.pkgScope.Lookup(ident.Name) // also removes unreso
lved sentinel |
2164 if ident.Obj == nil { | 2164 if ident.Obj == nil { |
2165 p.unresolved[i] = ident | 2165 p.unresolved[i] = ident |
2166 i++ | 2166 i++ |
2167 } | 2167 } |
2168 } | 2168 } |
2169 | 2169 |
2170 return &ast.File{doc, pos, ident, decls, p.pkgScope, p.imports, p.unreso
lved[0:i], p.comments} | 2170 return &ast.File{doc, pos, ident, decls, p.pkgScope, p.imports, p.unreso
lved[0:i], p.comments} |
2171 } | 2171 } |
LEFT | RIGHT |