Documentation
¶
Overview ¶
********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
********************************************************************** MicroCore Copyright 2017 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
********************************************************************** MicroCore Copyright 2020 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
********************************************************************** MicroCore Copyright 2017 - 2020 by Danyil Dobryvechir (dobrivecher@yahoo.com ddobryvechir@gmail.com) ***********************************************************************
Index ¶
- Constants
- Variables
- func CheckCreateGrammarTable(rules *GrammarRuleDefinitions)
- func EnrichErrorStr(err error, info string) error
- func ErrorMessageForNode(message string, node *BuildNode, context *ExpressionContext) error
- func GetEscapedString(data []byte) string
- type BuildNode
- type ExpressionContext
- type ExpressionValue
- type GrammarBaseDefinition
- type GrammarRuleDefinitions
- type GrammarTable
- type InterOperator
- type InterOperatorVisitor
- type ScopeInterface
- type SourceReference
- type Token
- func RecognizerByteControl(grammar *GrammarTable, data []byte, pos int, n int) (t *Token, nextPos int, err error)
- func RecognizerByteDigit(grammar *GrammarTable, data []byte, pos int, n int) (t *Token, nextPos int, err error)
- func RecognizerByteLetter(grammar *GrammarTable, data []byte, pos int, n int) (t *Token, nextPos int, err error)
- func RecognizerByteListControl(grammar *GrammarTable, data []byte, pos int, n int) (t *Token, nextPos int, err error)
- func RecognizerByteQuotation(grammar *GrammarTable, data []byte, pos int, n int) (t *Token, nextPos int, err error)
- func Tokenize(src *SourceReference, data []byte, grammar *GrammarTable) ([]Token, error)
- type TokenBlock
- type TokenMapType
- type TypeRecognizer
- type UnaryOperator
- type UnaryVisitor
Constants ¶
const ( NON_LATIN_LETTERS_ONLY_IN_STRINGS = 1 << iota SINGLE_QUOTE_HAS_TYPE_CHAR EXCLUDE_RECOGNIZER_BYTE_LETTER EXCLUDE_RECOGNIZER_BYTE_DIGIT EXCLUDE_RECOGNIZER_BYTE_QUOTATION EXCLUDE_RECOGNIZER_BYTE_CONTROL EXCLUDE_RECOGNIZER_BYTE_LIST_CONTROL )
bitwise values of EvaluateOptions
const ( TYPE_CONTROL = iota TYPE_OPERATOR = iota TYPE_STRING = iota TYPE_CHAR = iota TYPE_NUMBER = iota TYPE_NUMBER_INT = iota TYPE_BOOLEAN = iota TYPE_NULL = iota TYPE_UNDEFINED = iota TYPE_NAN = iota TYPE_FUNCTION = iota TYPE_DATA = iota TYPE_MASK = 0x7ff )
const ( BYTE_ONLY_INSIDE_STRING = iota BYTE_CONTROL BYTE_DIGIT BYTE_LETTER BYTE_LIST_CLOSING BYTE_LIST_SEPARATOR BYTE_OPERATOR BYTE_QUOTATION BYTE_SPACE )
const (
VISITOR_OPTION_CASHED = 1 << iota
)
bitwise values of VisitorOptions
Variables ¶
var CommonGrammarBaseDefinition = &GrammarBaseDefinition{ Operators: map[string]*InterOperator{ ";": &InterOperator{ Precedence: 0, Multi: true, }, ",": &InterOperator{ Precedence: 1, Multi: true, }, "=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, "+=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, "-=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, "**=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, "*=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, "/=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, "%=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, "<<=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, ">>=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, ">>>=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, "&=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, "^=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, "|=": &InterOperator{ Precedence: 3, Multi: true, RightToLeft: true, Assignment: true, }, "?": &InterOperator{ Precedence: 4, Multi: true, RightToLeft: true, Closing: ":", }, ":": &InterOperator{ Precedence: 4, Multi: true, RightToLeft: true, Opening: "?", }, "||": &InterOperator{ Precedence: 5, Multi: true, LazyLoadedOperands: true, }, "&&": &InterOperator{ Precedence: 6, Multi: true, LazyLoadedOperands: true, }, "|": &InterOperator{ Precedence: 7, Multi: true, }, "^": &InterOperator{ Precedence: 8, Multi: true, }, "&": &InterOperator{ Precedence: 9, Multi: true, }, "!==": &InterOperator{ Precedence: 10, }, "===": &InterOperator{ Precedence: 10, }, "==": &InterOperator{ Precedence: 10, }, "!=": &InterOperator{ Precedence: 10, }, "<": &InterOperator{ Precedence: 11, }, ">": &InterOperator{ Precedence: 11, }, "<=": &InterOperator{ Precedence: 11, }, ">=": &InterOperator{ Precedence: 11, }, "<<": &InterOperator{ Precedence: 12, }, ">>": &InterOperator{ Precedence: 12, }, ">>>": &InterOperator{ Precedence: 12, }, "+": &InterOperator{ Precedence: 13, Multi: true, }, "-": &InterOperator{ Precedence: 13, Multi: true, }, "*": &InterOperator{ Precedence: 14, }, "/": &InterOperator{ Precedence: 14, }, "%": &InterOperator{ Precedence: 14, }, "**": &InterOperator{ Precedence: 15, }, "IN": &InterOperator{ Precedence: 16, }, "NOT IN": &InterOperator{ Precedence: 16, }, "(": &InterOperator{ Precedence: 19, Closing: ")", }, ")": &InterOperator{ Precedence: 19, Opening: "(", }, "[": &InterOperator{ Precedence: 19, Closing: "]", }, "]": &InterOperator{ Precedence: 19, Opening: "[", }, ".": &InterOperator{ Precedence: 19, Multi: true, }, }, UnaryOperators: map[string]*UnaryOperator{ "!": &UnaryOperator{ Post: false, Pre: true, }, "~": &UnaryOperator{ Post: false, Pre: true, }, "+": &UnaryOperator{ Post: false, Pre: true, }, "-": &UnaryOperator{ Post: false, Pre: true, }, "++": &UnaryOperator{ Post: true, Pre: true, }, "--": &UnaryOperator{ Post: true, Pre: true, }, "...": &UnaryOperator{ Post: true, Pre: false, }, }, DefaultOperator: "", }
var LogicalGrammarBaseDefinition = &GrammarBaseDefinition{ Operators: map[string]*InterOperator{ "||": &InterOperator{ Precedence: 0, Multi: true, LazyLoadedOperands: true, }, "&&": &InterOperator{ Precedence: 1, Multi: true, LazyLoadedOperands: true, }, }, UnaryOperators: map[string]*UnaryOperator{ "!": &UnaryOperator{ Post: false, Pre: true, }, }, DefaultOperator: "&&", }
Functions ¶
func CheckCreateGrammarTable ¶
func CheckCreateGrammarTable(rules *GrammarRuleDefinitions)
func EnrichErrorStr ¶
func ErrorMessageForNode ¶
func ErrorMessageForNode(message string, node *BuildNode, context *ExpressionContext) error
func GetEscapedString ¶
Types ¶
type BuildNode ¶
type BuildNode struct {
Children []*BuildNode
Parent *BuildNode
Operator string
Value *Token
PreAttributes []string
PostAttributes []string
// contains filtered or unexported fields
}
func CompileOrCache ¶
func CompileOrCache(data []byte, context *ExpressionContext, cache bool) (*BuildNode, error)
func (*BuildNode) ExecuteExpression ¶
func (tree *BuildNode) ExecuteExpression(context *ExpressionContext) (*ExpressionValue, error)
func (*BuildNode) GetChildrenExpressionValue ¶
func (tree *BuildNode) GetChildrenExpressionValue(childNo int, context *ExpressionContext) (*ExpressionValue, error)
func (*BuildNode) GetChildrenNumber ¶
type ExpressionContext ¶
type ExpressionContext struct {
Scope ScopeInterface
Reference *SourceReference
Rules *GrammarRuleDefinitions
VisitorOptions int
}
type ExpressionValue ¶
type ExpressionValue struct {
DataType int
Value interface{}
}
func FastEvaluation ¶
func FastEvaluation(data []byte, context *ExpressionContext) (*ExpressionValue, error)
type GrammarBaseDefinition ¶
type GrammarBaseDefinition struct {
Operators map[string]*InterOperator
UnaryOperators map[string]*UnaryOperator
DefaultOperator string
}
type GrammarRuleDefinitions ¶
type GrammarRuleDefinitions struct {
BaseGrammar *GrammarBaseDefinition
GrammarAliases map[string]string
Recognizers []TypeRecognizer
EvaluateOptions int
Visitors map[string]InterOperatorVisitor
UnaryPostVisitors map[string]UnaryVisitor
UnaryPreVisitors map[string]UnaryVisitor
DataGetter func(*Token, *ExpressionContext) (*ExpressionValue, error)
Grammar *GrammarTable
// contains filtered or unexported fields
}
type GrammarTable ¶
type GrammarTable struct {
TokenMap TokenMapType
IsSingleQuoteTypeChar bool
}
type InterOperator ¶
type InterOperatorVisitor ¶
type InterOperatorVisitor func([]*ExpressionValue, *BuildNode, *ExpressionContext, string) (*ExpressionValue, error)
type ScopeInterface ¶
type SourceReference ¶
type Token ¶
func RecognizerByteControl ¶
func RecognizerByteDigit ¶
func RecognizerByteLetter ¶
func RecognizerByteQuotation ¶
func Tokenize ¶
func Tokenize(src *SourceReference, data []byte, grammar *GrammarTable) ([]Token, error)
type TokenBlock ¶
type TokenMapType ¶
type TokenMapType [256]*TokenBlock
type TypeRecognizer ¶
type UnaryOperator ¶
type UnaryVisitor ¶
type UnaryVisitor func(*ExpressionValue, *BuildNode, *ExpressionContext, string) (*ExpressionValue, error)