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 package ebnf | 5 package ebnf |
6 | 6 |
7 import ( | 7 import ( |
8 "go/scanner" | 8 "go/scanner" |
9 "go/token" | 9 "go/token" |
10 "os" | 10 "os" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 return grammar | 194 return grammar |
195 } | 195 } |
196 | 196 |
197 | 197 |
198 // Parse parses a set of EBNF productions from source src. | 198 // Parse parses a set of EBNF productions from source src. |
199 // It returns a set of productions. Errors are reported | 199 // It returns a set of productions. Errors are reported |
200 // for incorrect syntax and if a production is declared | 200 // for incorrect syntax and if a production is declared |
201 // more than once. | 201 // more than once. Position information is recorded relative |
| 202 // to the file set fset. |
202 // | 203 // |
203 func Parse(fset *token.FileSet, filename string, src []byte) (Grammar, os.Error)
{ | 204 func Parse(fset *token.FileSet, filename string, src []byte) (Grammar, os.Error)
{ |
204 var p parser | 205 var p parser |
205 grammar := p.parse(fset, filename, src) | 206 grammar := p.parse(fset, filename, src) |
206 return grammar, p.GetError(scanner.Sorted) | 207 return grammar, p.GetError(scanner.Sorted) |
207 } | 208 } |
LEFT | RIGHT |