func Verify(grammar Grammar, start string) error
Verify checks that:
Position information is interpreted relative to the file set fset.
An Alternative node represents a non-empty list of alternative expressions.
type Alternative []Expression // x | y | z
func (x Alternative) Pos() scanner.Position
A Bad node stands for pieces of source code that lead to a parse error.
type Bad struct { TokPos scanner.Position Error string // parser error message }
func (x *Bad) Pos() scanner.Position
An Expression node represents a production expression.
type Expression interface { // Pos is the position of the first character of the syntactic construct Pos() scanner.Position }
A Grammar is a set of EBNF productions. The map is indexed by production name.
type Grammar map[string]*Production
func Parse(filename string, src io.Reader) (Grammar, error)
Parse parses a set of EBNF productions from source src. It returns a set of productions. Errors are reported for incorrect syntax and if a production is declared more than once; the filename is used only for error positions.
A Group node represents a grouped expression.
type Group struct { Lparen scanner.Position Body Expression // (body) }
func (x *Group) Pos() scanner.Position
A Name node represents a production name.
type Name struct { StringPos scanner.Position String string }
func (x *Name) Pos() scanner.Position
An Option node represents an optional expression.
type Option struct { Lbrack scanner.Position Body Expression // [body] }
func (x *Option) Pos() scanner.Position
A Production node represents an EBNF production.
type Production struct { Name *Name Expr Expression }
func (x *Production) Pos() scanner.Position
A List node represents a range of characters.
type Range struct { Begin, End *Token // begin ... end }
func (x *Range) Pos() scanner.Position
A Repetition node represents a repeated expression.
type Repetition struct { Lbrace scanner.Position Body Expression // {body} }
func (x *Repetition) Pos() scanner.Position
A Sequence node represents a non-empty list of sequential expressions.
type Sequence []Expression // x y z
func (x Sequence) Pos() scanner.Position
A Token node represents a literal.
type Token struct { StringPos scanner.Position String string }
func (x *Token) Pos() scanner.Position