Documentation
¶
Index ¶
- Constants
- func AssertEqualNodes(t *testing.T, v, u Node) bool
- func NewScopeWith(s frozen.Map, ident string, p Parser, val TreeElement) frozen.Map
- type Associativity
- type Choice
- type Delim
- type Empty
- type Extra
- type Func
- type Grammar
- type Named
- type Node
- func (n Node) Count() int
- func (n Node) Format(state fmt.State, c rune)
- func (n Node) Get(path ...int) TreeElement
- func (n Node) GetNode(path ...int) Node
- func (n Node) GetScanner(path ...int) Scanner
- func (n Node) GetString(path ...int) string
- func (Node) IsTreeElement()
- func (n Node) Normalize() Node
- func (n Node) String() string
- type Oneof
- type ParseError
- type Parser
- type Parsers
- type Quant
- type RE
- type REF
- type Rule
- type S
- type Scanner
- func (r Scanner) Context() string
- func (r *Scanner) Eat(i int, eaten *Scanner) *Scanner
- func (r *Scanner) EatRegexp(re *regexp.Regexp, match *Scanner, captures []Scanner) (n int, ok bool)
- func (r *Scanner) EatString(s string, eaten *Scanner) bool
- func (r Scanner) Format(state fmt.State, c rune)
- func (Scanner) IsTreeElement()
- func (r Scanner) Offset() int
- func (r Scanner) Skip(i int) *Scanner
- func (r Scanner) Slice(a, b int) *Scanner
- func (r Scanner) String() string
- func (r Scanner) StripSource() Scanner
- type Seq
- type Stack
- type Term
- type TreeElement
Constants ¶
View Source
const ( StackDelim = "@" At = Rule(StackDelim) WrapRE = Rule(".wrapRE") )
Variables ¶
This section is empty.
Functions ¶
func NewScopeWith ¶ added in v0.10.0
Types ¶
type Associativity ¶ added in v0.10.0
type Associativity int
const ( RightToLeft Associativity = iota - 1 NonAssociative LeftToRight )
func NewAssociativity ¶ added in v0.10.0
func NewAssociativity(s string) Associativity
func (Associativity) IsExtra ¶ added in v0.10.0
func (Associativity) IsExtra()
func (Associativity) String ¶ added in v0.10.0
func (a Associativity) String() string
type Delim ¶ added in v0.10.0
type Delim struct {
Term Term
Sep Term
Assoc Associativity
CanStartWithSep bool
CanEndWithSep bool
}
type Empty ¶ added in v0.10.0
type Empty struct{}
func (Empty) IsTreeElement ¶ added in v0.10.0
func (Empty) IsTreeElement()
type Grammar ¶ added in v0.10.0
func (Grammar) Compile ¶ added in v0.10.0
Compile prepares a grammar for parsing. The parser holds a copy of the grammar modified to support parser execution.
type Node ¶
type Node struct {
Tag string `json:"tag"`
Extra Extra `json:"extra"`
Children []TreeElement `json:"nodes"`
}
func (Node) Get ¶
func (n Node) Get(path ...int) TreeElement
func (Node) GetScanner ¶
func (Node) IsTreeElement ¶ added in v0.6.0
func (Node) IsTreeElement()
type ParseError ¶ added in v0.10.0
type ParseError struct {
// contains filtered or unexported fields
}
func (ParseError) Error ¶ added in v0.10.0
func (p ParseError) Error() string
type Parser ¶
type Parser interface {
Parse(scope frozen.Map, input *Scanner, output *TreeElement) error
}
type Parsers ¶ added in v0.10.0
type Parsers struct {
// contains filtered or unexported fields
}
Parsers holds Parsers generated by Grammar.Compile.
func (Parsers) MustParse ¶ added in v0.10.0
func (p Parsers) MustParse(rule Rule, input *Scanner) TreeElement
MustParse calls Parse and returns the result or panics if an error was returned.
type Quant ¶ added in v0.10.0
func (Quant) MaxLessThan ¶ added in v0.10.0
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
func NewBareScanner ¶ added in v0.2.0
func NewScanner ¶
func NewScannerAt ¶
func (*Scanner) EatRegexp ¶
EatRegexp eats the text matching a regexp, populating match (if != nil) with the whole match and captures (if != nil) with any captured groups. Returns n as the number of captures set and ok iff a match was found.
func (Scanner) IsTreeElement ¶ added in v0.6.0
func (Scanner) IsTreeElement()
func (Scanner) StripSource ¶ added in v0.4.0
type Term ¶ added in v0.10.0
type Term interface {
fmt.Stringer
Parser(name Rule, c cache) Parser
Unparse(g Grammar, e TreeElement, w io.Writer) (n int, err error)
Resolve(oldRule, newRule Rule) Term
}
Term represents the terms of a grammar specification.
type TreeElement ¶ added in v0.6.0
type TreeElement interface {
IsTreeElement()
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.