Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrExpectedLBrace = errors.New("expected '{'") ErrUnmatchedLBrace = errors.New("unmatched '{'") ErrUnexpectedEOF = errors.New("unexpected EOF") ErrUnexpectedNewline = errors.New("unexpected newline") ErrUnexpectedLAngle = errors.New("unexpected '<'") ErrUnmatchedRAngle = errors.New("unmatched '>'") )
Functions ¶
func ExecWithParams ¶
func ExecWithParams(p *ExecParams)
Types ¶
type BuildResult ¶
type Builder ¶
type Builder struct { Standalone bool CustomError bool CustomPrefix string Result BuildResult // contains filtered or unexported fields }
type ExecParams ¶
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
func NewLexerWithInit ¶
NewLexerWithInit creates a new Lexer object, runs the given callback on it, then returns it.
func (*Lexer) Lex ¶
Lex runs the lexer. Always returns 0. When the -s option is given, this function is not generated; instead, the NN_FUN macro runs the lexer.
type Nfa ¶
Nfa - NFA: Nondeterministic Finite Automaton
func BuildNfa ¶
BuildNfa Regex -> NFA We cannot have our alphabet be all Unicode characters. Instead, we compute an alphabet for each regex:
Singles: we add single runes used in the regex: any rune not in a range. These are held in `singles`.
Ranges: entire ranges become elements of the alphabet. If ranges in the same expression overlap, we break them up into non-overlapping ranges. The generated code checks singles before ranges, so there's no need to break up a range if it contains a single. These are maintained in sorted order in `lim`.
Wild: we add an element representing all other runes.
e.g. the alphabet of /[0-9]*[Ee][2-5]*/ is singles: { E, e }, lim: { [0-1], [2-5], [6-9] } and the wild element.