Documentation ¶
Index ¶
- Variables
- func WriteGrammar(dst io.Writer, s Scope)
- type GrammarScope
- type Item
- type Lang
- func (l *Lang) Extend(with *Lang) *Lang
- func (l *Lang) Global() Scope
- func (l *Lang) NewLangWithGlobalScope(s Scope) *Lang
- func (l *Lang) Parse(ctx context.Context, src Scanner) (Meaning, error)
- func (l *Lang) ParseStart(ctx context.Context, src Scanner, start NonTerminal) (Meaning, error)
- func (l *Lang) Restart(start NonTerminal) *Lang
- func (l *Lang) Rule(lhs NonTerminal, formals ...interface{}) *Production
- func (s *Lang) WriteTo(dst io.Writer)
- type Lexeme
- type Meaning
- type NonTerminal
- type ParseError
- type Production
- type Reducer
- type Scanner
- type Scope
- type ScopeChanger
- type ScopeChangerWithErr
- type TokenMatcher
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrAmbiguous = errors.New("ambiguous")
View Source
var ErrNoParse = errors.New("no parse")
View Source
var Trace = false
Functions ¶
func WriteGrammar ¶
Types ¶
type GrammarScope ¶
type GrammarScope interface { Scope Rule(lhs NonTerminal, formals ...interface{}) *Production }
func NewGrammarScope ¶
func NewGrammarScope(outer Scope) GrammarScope
type Item ¶
type Item struct { Of *Production At int }
type Lang ¶
type Lang struct {
// contains filtered or unexported fields
}
func New ¶
func New(starts ...NonTerminal) *Lang
func (*Lang) Extend ¶
Extend takes a given language, extends it with the language (productions) available from the other language; TODO this API could be improved. The Lang object is fuzzy in its semantics; we should be doing this with scope instead.
func (*Lang) NewLangWithGlobalScope ¶
func (*Lang) ParseStart ¶
func (*Lang) Restart ¶
func (l *Lang) Restart(start NonTerminal) *Lang
func (*Lang) Rule ¶
func (l *Lang) Rule(lhs NonTerminal, formals ...interface{}) *Production
type NonTerminal ¶
type NonTerminal string
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
func (*ParseError) Error ¶
func (err *ParseError) Error() string
type Production ¶
type Production struct {
// contains filtered or unexported fields
}
func Lookup ¶
func Lookup(in Scope, nt NonTerminal) []*Production
func (*Production) Accept ¶
func (p *Production) Accept() *Production
setting this on a production causes acceptance of the input which this production is reduced, and the meaning of the accepted production is the meaning of the entire parse
func (*Production) Nth ¶
func (p *Production) Nth(i int) interface{}
Nth returns the nth item in the production, which is either a TokenMatcher or a NonTerminal
func (*Production) Reject ¶
func (p *Production) Reject() *Production
func (*Production) Then ¶
func (p *Production) Then(r Reducer) *Production
type ScopeChanger ¶
type ScopeChangerWithErr ¶
Click to show internal directories.
Click to hide internal directories.