Documentation
¶
Overview ¶
Package lrparser is an LR-parser.
Index ¶
- func CoalesceSymbols(tokens []*textkit.Token, clusters []string) []*textkit.Token
- type Grammar
- type Item
- type Located
- type Operator
- type OperatorAssociativity
- type Rule
- func BuildListRules(root, leaf string, canBeEmpty bool, leftBracket, sep, rightBracket string, ...) []*Rule
- func BuildOperatorRules(root, leaf string, ops []Operator, ...) []*Rule
- func BuildOptSeq(root string, head, tail []string, ...) []*Rule
- func BuildRule(def string, f func([]interface{}) interface{}) (*Rule, error)
- func BuildRules(list []*SynSem) ([]*Rule, error)
- func MustBuildRule(def string, f func([]interface{}) interface{}) *Rule
- func MustBuildRules(list []*SynSem) []*Rule
- type State
- type SynSem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Grammar ¶
type Grammar struct {
// The rules of the grammar.
Rules []*Rule
// contains filtered or unexported fields
}
Grammar is a formal grammar.
func (*Grammar) BuildItems ¶
func (gr *Grammar) BuildItems()
BuildItems builds the items of the automaton.
type Operator ¶
type Operator struct {
Associativity OperatorAssociativity
Priority int
Symbols []string
}
Operator ...
type OperatorAssociativity ¶
type OperatorAssociativity int
OperatorAssociativity ...
const ( LeftAssociative OperatorAssociativity = iota RightAssociative NonAssociative )
constants for OperatorAssociativity
type Rule ¶
Rule is a context-free rule with a builder function.
func BuildListRules ¶
func BuildListRules(root, leaf string, canBeEmpty bool, leftBracket, sep, rightBracket string, builder func([]interface{}) interface{}) []*Rule
BuildListRules builds list rules.
func BuildOperatorRules ¶
func BuildOperatorRules(root, leaf string, ops []Operator, builder func(string, interface{}, interface{}) interface{}) []*Rule
BuildOperatorRules builds operator rules.
func BuildOptSeq ¶
func BuildOptSeq(root string, head, tail []string, builder func([]interface{}, []interface{}) interface{}) []*Rule
BuildOptSeq builds an optional sequence.
func BuildRules ¶ added in v0.1.6
BuildRules creates rules from a slice of `SynSem`s.
func MustBuildRule ¶ added in v0.1.5
MustBuildRule builds a grammar rule from a string. It panics on error.
func MustBuildRules ¶ added in v0.1.6
MustBuildRules creates rules from a slice of `SynSem`s. It panics on error.
Click to show internal directories.
Click to hide internal directories.