Documentation ¶
Index ¶
- Constants
- type Lexer
- func New(startState StateFn, reader io.Reader, channelCap int) Lexer
- func NewFromBytes(startState StateFn, input []byte, channelCap int) Lexer
- func NewFromString(startState StateFn, input string, channelCap int) Lexer
- func NewSize(startState StateFn, reader io.Reader, readerBufLen int, channelCap int) Lexer
- type Marker
- type MatchFn
- type StateFn
- type Token
- type TokenType
Constants ¶
View Source
const RuneEOF = -1
Rune represending EOF
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lexer ¶
type Lexer interface { // PeekRune allows you to look ahead at runes without consuming them PeekRune(int) rune // NetRune consumes and returns the next rune in the input NextRune() rune // BackupRune un-conumes the last rune from the input BackupRune() // BackupRunes un-consumes the last n runes from the input BackupRunes(int) // NewLine increments the line number counter, resets the column counter NewLine() // Line returns the current line number, 1-based Line() int // Column returns the current column number, 1-based Column() int // EmitToken emits a token of the specified type, consuming matched runes // without emitting them EmitToken(TokenType) // EmitTokenWithBytes emits a token along with all the consumed runes EmitTokenWithBytes(TokenType) // IgnoreToken ignores the consumed bytes without emitting any tokens IgnoreToken() // EmitEOF emits a token of type TokenEOF EmitEOF() // NextToken retrieves the next emmitted token from the input NextToken() *Token // Marker returns a marker that you can use to reset the lexer state later Marker() *Marker // CanReset confirms if the marker is still valid CanReset(*Marker) bool // Reset resets the lexer state to the specified marker Reset(*Marker) // MatchZeroOrOneBytes consumes the next rune if it matches, always returning true MatchZeroOrOneBytes([]byte) bool // MatchZeroOrOneRuness consumes the next rune if it matches, always returning true MatchZeroOrOneRunes([]rune) bool // MatchZeroOrOneRune consumes the next rune if it matches, always returning true MatchZeroOrOneRune(rune) bool // MatchZeroOrOneFunc consumes the next rune if it matches, always returning true MatchZeroOrOneFunc(MatchFn) bool // MatchZeroOrMoreBytes consumes a run of matching runes, always returning true MatchZeroOrMoreBytes([]byte) bool // MatchZeroOrMoreRunes consumes a run of matching runes, always returning true MatchZeroOrMoreRunes([]rune) bool // MatchZeroOrMoreFunc consumes a run of matching runes, always returning true MatchZeroOrMoreFunc(MatchFn) bool // MatchOneBytes consumes the next rune if its in the list of bytes MatchOneBytes([]byte) bool // MatchOneRune consumes the next rune if its in the list of bytes MatchOneRunes([]rune) bool // MatchOneRune consumes the next rune if it matches MatchOneRune(rune) bool // MatchOneFunc consumes the next rune if it matches MatchOneFunc(MatchFn) bool // MatchOneOrMoreBytes consumes a run of matching runes MatchOneOrMoreBytes([]byte) bool // MatchOneOrMoreRunes consumes a run of matching runes MatchOneOrMoreRunes([]rune) bool // MatchOneOrMoreFunc consumes a run of matching runes MatchOneOrMoreFunc(MatchFn) bool // MatchMinMaxBytes consumes a specified run of matching runes MatchMinMaxBytes([]byte, int, int) bool // MatchMinMaxRunes consumes a specified run of matching runes MatchMinMaxRunes([]rune, int, int) bool // MatchMinMaxFunc consumes a specified run of matching runes MatchMinMaxFunc(MatchFn, int, int) bool // NonMatchZeroOrOneBytes consumes the next rune if it does not match, always returning true NonMatchZeroOrOneBytes([]byte) bool // NonMatchZeroOrOneRunes consumes the next rune if it does not match, always returning true NonMatchZeroOrOneRunes([]rune) bool // NonMatchZeroOrOneFunc consumes the next rune if it does not match, always returning true NonMatchZeroOrOneFunc(MatchFn) bool // NonMatchZeroOrMoreBytes consumes a run of non-matching runes, always returning true NonMatchZeroOrMoreBytes([]byte) bool // NonMatchZeroOrMoreRunes consumes a run of non-matching runes, always returning true NonMatchZeroOrMoreRunes([]rune) bool // NonMatchZeroOrMoreFunc consumes a run of non-matching runes, always returning true NonMatchZeroOrMoreFunc(MatchFn) bool // NonMatchOneBytes consumes the next rune if its NOT in the list of bytes NonMatchOneBytes([]byte) bool // NonMatchOneRunes consumes the next rune if its NOT in the list of runes NonMatchOneRunes([]rune) bool // NonMatchOneFunc consumes the next rune if it does NOT match NonMatchOneFunc(MatchFn) bool // NonMatchOneOrMoreBytes consumes a run of non-matching runes NonMatchOneOrMoreBytes([]byte) bool // NonMatchOneOrMoreRunes consumes a run of non-matching runes NonMatchOneOrMoreRunes([]rune) bool // NonMatchOneOrMoreFunc consumes a run of non-matching runes NonMatchOneOrMoreFunc(MatchFn) bool // MatchEOF tries to match the next rune against RuneEOF MatchEOF() bool }
lexer.Lexer helps you tokenize bytes
func NewFromBytes ¶
NewFromBytes returns a new Lexer object for the specified byte array
func NewFromString ¶
NewFromString returns a new Lexer object for the specified string
type Marker ¶
type Marker struct {
// contains filtered or unexported fields
}
Marker stores the state of the lexer to allow rewinding
type MatchFn ¶
MatchFn represents a callback function for matching runes that are not feasable for a range
type StateFn ¶
StateFn represents the state of the scanner as a function that returns the next state.
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
Package rangeutil provides services for conversion and iteration of range specifications for use with iNamik/go_lexer Currently, a 'range specifiction' is defined as a string of unicode characters, with the ability to specify a range of chararacters by using a '-' between two characters.
|
Package rangeutil provides services for conversion and iteration of range specifications for use with iNamik/go_lexer Currently, a 'range specifiction' is defined as a string of unicode characters, with the ability to specify a range of chararacters by using a '-' between two characters. |
Click to show internal directories.
Click to hide internal directories.