Documentation ¶
Overview ¶
Package frontend parses regular expressions and compiles them into NFA bytecode
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DEBUG = false
Turn on debug prints
Functions ¶
Types ¶
type AST ¶
AST is an abstract syntax tree for a regular expression.
func DesugarRanges ¶
DesugarRanges transform all Range nodes into Alternatives with individual characters
func NewAlternation ¶
NewAlternation creates an Alternation
func NewApplyOp ¶
NewApplyOp applies a given op (Star, Plus, Maybe) to a tree
type AltMatch ¶
AltMatch either match A or B and then finalize matching the string
type Alternation ¶
Alternation matches A or B
func (*Alternation) Children ¶
func (a *Alternation) Children() []AST
Children returns a list of the child nodes
func (*Alternation) Equals ¶
func (a *Alternation) Equals(o AST) bool
Equals checks deep equality of the two trees
type Character ¶
type Character struct {
Char byte
}
Character matches a single byte
type Concat ¶
type Concat struct {
Items []AST
}
Concat matches each item in sequence
type Match ¶
type Match struct {
AST
}
Match the tree AST finalizes the matching
type Maybe ¶
type Maybe struct {
AST
}
Maybe matches 0 or 1 times
type ParseError ¶
type ParseError struct { Reason string Production string TC int // contains filtered or unexported fields }
ParseError gives structured errors for parsing problems.
func Errorf ¶
func Errorf(text []byte, tc int, format string, args ...interface{}) *ParseError
Errorf constructs a parse error with format for a particular location.
func (*ParseError) Chain ¶
func (p *ParseError) Chain(e *ParseError) *ParseError
Chain joins multiple ParseErrors together
func (*ParseError) String ¶
func (p *ParseError) String() string
String formats the error for humans
type Plus ¶
type Plus struct {
AST
}
Plus matches 1 or more times
type Range ¶
Range matches byte ranges From-To inclusive