OLD | NEW |
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 // Parse input AST and prepare Prog structure. | 5 // Parse input AST and prepare Prog structure. |
6 | 6 |
7 package main | 7 package main |
8 | 8 |
9 import ( | 9 import ( |
10 "fmt" | 10 "fmt" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 // A FuncType collects information about a function type in both the C and Go wo
rlds. | 54 // A FuncType collects information about a function type in both the C and Go wo
rlds. |
55 type FuncType struct { | 55 type FuncType struct { |
56 Params []*Type | 56 Params []*Type |
57 Result *Type | 57 Result *Type |
58 Go *ast.FuncType | 58 Go *ast.FuncType |
59 } | 59 } |
60 | 60 |
61 func openProg(name string, p *Prog) { | 61 func openProg(name string, p *Prog) { |
62 var err os.Error | 62 var err os.Error |
63 » p.AST, err = parser.ParseFile(name, nil, parser.ParseComments) | 63 » p.AST, err = parser.ParseFile(name, nil, nil, parser.ParseComments) |
64 if err != nil { | 64 if err != nil { |
65 if list, ok := err.(scanner.ErrorList); ok { | 65 if list, ok := err.(scanner.ErrorList); ok { |
66 // If err is a scanner.ErrorList, its String will print
just | 66 // If err is a scanner.ErrorList, its String will print
just |
67 // the first error and then (+n more errors). | 67 // the first error and then (+n more errors). |
68 // Instead, turn it into a new Error that will return | 68 // Instead, turn it into a new Error that will return |
69 // details for all the errors. | 69 // details for all the errors. |
70 for _, e := range list { | 70 for _, e := range list { |
71 fmt.Fprintln(os.Stderr, e) | 71 fmt.Fprintln(os.Stderr, e) |
72 } | 72 } |
73 os.Exit(2) | 73 os.Exit(2) |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 case []ast.Stmt: | 321 case []ast.Stmt: |
322 for _, s := range n { | 322 for _, s := range n { |
323 walk(s, p, context) | 323 walk(s, p, context) |
324 } | 324 } |
325 case []ast.Spec: | 325 case []ast.Spec: |
326 for _, s := range n { | 326 for _, s := range n { |
327 walk(s, p, context) | 327 walk(s, p, context) |
328 } | 328 } |
329 } | 329 } |
330 } | 330 } |
OLD | NEW |