Documentation
¶
Index ¶
Constants ¶
const EOF rune = -1
EOF denotes the end of file
Variables ¶
var EOLexToken = Token{"eolex", 0}
EOLexToken is Token to denote end of lexing
var ErrorToken = Token{"error", 0}
ErrorToken is a Token to denote error
Functions ¶
This section is empty.
Types ¶
type Bounds ¶
type Bounds struct {
// contains filtered or unexported fields
}
Bounds represents the bounding states of lex machine
type LexState ¶
type LexState struct {
// contains filtered or unexported fields
}
LexState denotes an individual state in a pushdown automata
func NewLexState ¶
func NewLexState(tt TokenType, typ LexStateType, isEmitter bool) *LexState
NewLexState creates a new instance of LexState
type LexStateType ¶
type LexStateType int
LexStateType denotes the type of the state for a LexMachine
const ( // Buffer pushes back input after consuming it Buffer LexStateType = 0 // Feeder simply feeds on input Feeder LexStateType = 1 // Storer stores runes to be mathced Storer LexStateType = 2 // Matcher matches runes Matcher LexStateType = 3 )
func (LexStateType) String ¶
func (l LexStateType) String() string
String (LexStateType) produces a string representation of a LexStateType
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer reperesents a lexing machine reading runes from a Reader
func NewLexer ¶
NewLexer creates a new instance of Lexer from a Reader instance with a given buffer capacity.
type Machine ¶
type Machine struct {
// contains filtered or unexported fields
}
Machine is a PDA which represents a lexing machine attached to the "tape reader"
func NewMachine ¶
func NewMachine(lexer *Lexer, bounds Bounds, matcher *RuneMatcher) *Machine
NewMachine creates a new instance of lexer.Machine
func (*Machine) AttachLexer ¶
AttachLexer attaches new lexer to this machine and resets it.
type Path ¶
type Path rune
Path denotes a link or input to traverse from the current state to the next state
const DefaultPath Path = 0
DefaultPath is the path to be taken in the event of unexpected or no input
type RuneMatcher ¶
type RuneMatcher struct {
// contains filtered or unexported fields
}
RuneMatcher is a component to keep track of matchable runes
func NewRuneMatcher ¶
func NewRuneMatcher() *RuneMatcher
NewRuneMatcher creates a new instance of RuneMatcher
func (*RuneMatcher) EnlistMapping ¶
func (m *RuneMatcher) EnlistMapping(r1, r2 rune)
EnlistMapping enlists a new mapping in this RuneMatcher
func (*RuneMatcher) IsMatched ¶
func (m *RuneMatcher) IsMatched() bool
IsMatched checks whether the RuneMatcher is in matched state if its stack is completely empty
func (*RuneMatcher) Match ¶
func (m *RuneMatcher) Match(r rune) bool
Match matches the given rune against the rune at TOS of matcher's stack
func (*RuneMatcher) Store ¶
func (m *RuneMatcher) Store(r rune) bool
Store stores a rune to matched against in this RuneMatcher