Documentation ¶
Index ¶
Constants ¶
View Source
const ( // keyword SelectString = "select" FromString = "from" AsString = "as" WhereString = "where" AndString = "and" OrString = "or" // comparison operator GEString = ">=" LEString = "<=" NotEqual1String = "!=" NotEqual2String = "<>" )
View Source
const ( // char UnderBarRune = '_' // comparison operator GTRune = '>' LTRune = '<' EqualRune = '=' ExclamationRune = '!' // arithmetic operator PlusRune = '+' MinusRune = '-' MultiplyRune = '*' DivideRune = '/' ModRune = '%' // separator CommaRune = ',' SemicolonRune = ';' LeftParenthesisRune = '(' RightParenthesisRune = ')' SingleQuoteRune = '\'' // white space SpaceRune = ' ' TabRune = '\t' ReturnRune = '\r' NewLineRune = '\n' )
View Source
const (
EpsilonRune = 'ε'
)
Variables ¶
View Source
var ( MultiRuneMap = map[token.Type]string{ token.Select: SelectString, token.From: FromString, token.As: AsString, token.Where: WhereString, token.And: AndString, token.Or: OrString, token.GE: GEString, token.LE: LEString, token.NotEqual1: NotEqual1String, token.NotEqual2: NotEqual2String, } SingleRuneMap = map[token.Type]rune{ token.GT: GTRune, token.LT: LTRune, token.Equal: EqualRune, token.Plus: PlusRune, token.Minus: MinusRune, token.Multiply: MultiplyRune, token.Divide: DivideRune, token.Mod: ModRune, token.LeftParenthesis: LeftParenthesisRune, token.RightParenthesis: RightParenthesisRune, token.Comma: CommaRune, token.Semicolon: SemicolonRune, } )
Functions ¶
func IsAlphabetOrDigit ¶
IsWhiteSpace returns if the given rune is either an alphabet or a digit
func IsWhiteSpace ¶
IsWhiteSpace returns if the given rune is a white space
Types ¶
type CharacterSet ¶
func NewCharacterSet ¶
func NewCharacterSet(alphabets, digits []rune) *CharacterSet
NewCharacterSet returns a new *CharacterSet
func NewCharacterSetWithDefault ¶
func NewCharacterSetWithDefault() *CharacterSet
NewCharacterSetWithDefault returns a new *CharacterSet with default
func (*CharacterSet) GetAlphabets ¶
func (cs *CharacterSet) GetAlphabets() []rune
GetAlphabets returns the alphabet runes
func (*CharacterSet) GetDigits ¶
func (cs *CharacterSet) GetDigits() []rune
GetAlphabets returns the digit runes
type DFA ¶
type DFA struct { CharacterSet *CharacterSet NFA *NFA Index int InitSet *Set }
func NewDFAWithDefault ¶
func NewDFAWithDefault() *DFA
NewDFAWithDefault returns a new *DFA with default
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
func (*Lexer) GetFiniteAutomata ¶
func (l *Lexer) GetFiniteAutomata() dependency.Lexer
GetFiniteAutomata returns the finite automata of the lexer
type NFA ¶
type NFA struct { CharacterSet *CharacterSet Index int InitState *State }
func NewNFAWithDefault ¶
func NewNFAWithDefault() *NFA
NewNFAWithDefault returns a new *NFA with default
type Set ¶
func (*Set) AddState ¶
AddState add the given state into the set,
- if a same state already exists in the set, it will be ignored
- if the new state is a final state and there is already a final state exists in the set, only one state of which token type is keyword stays in the set
func (*Set) Equal ¶
Equal returns if the twe sets contains the same states, the order of the states does not matter
func (*Set) GetFinalState ¶
GetFinalState returns the final state in the set
Click to show internal directories.
Click to hide internal directories.