Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( EmptyEncoder emptyEncoder StringEncoder stringEncoder NumberEncoder numberEncoder BoolEncoder boolEncoder )
View Source
var ( REG_LBT = regexp.MustCompile(`^([(\[{])`) REG_RBT = regexp.MustCompile(`^([)\]}])`) REG_OPERATOR = regexp.MustCompile(`^(&&|\|\|)`) REG_CONDITION = regexp.MustCompile(`^(?:(==|!=|>=|<=|>|<|containsBit|unContainsBit|contains|unContains|startsWith|unStartsWith|endsWith|unEndsWith|reg|notIn|in)\s*)`) REG_IDENT = regexp.MustCompile(`^([a-zA-Z_][\w\\.\-]*)`) REG_NUM = regexp.MustCompile(`^((?:\+|-)?\d+(?:\.\d+)?)`) REG_BOOL = regexp.MustCompile(`^(true|false)`) REG_STRING = regexp.MustCompile(`^(?:'(.*?)'|"(.*?)")`) REG_DELIM = regexp.MustCompile(`^(\s*)`) REG_ILLEGAL = regexp.MustCompile(`^(.+)`) )
token 的正则表达式
View Source
var (
DelimParser = Parser{Reg: REG_DELIM, Token: DELIM, Encodable: EmptyEncoder}
)
token 解析器
View Source
var ParserMap = map[Token]Parser{ LBT: lbtParser, RBT: rbtParser, OPERATOR: operatorParser, CONDITION: conditionParser, IDENT: identParser, NUM: numParser, BOOL: boolParser, STRING: stringParser, DELIM: DelimParser, ILLEGAL: illegalParser, }
ParserMap token 解析器映射
View Source
var ParserPriority = []Parser{
conditionParser,
operatorParser,
numParser,
boolParser,
stringParser,
identParser,
lbtParser,
rbtParser,
illegalParser,
}
ParserPriority token 解析器优先级
View Source
var StateMatrix = map[Token][]Token{ LITERAL_BEGIN: {LBT, IDENT}, LBT: {LBT, IDENT}, RBT: {OPERATOR, RBT, LITERAL_END}, OPERATOR: {LBT, IDENT}, CONDITION: {NUM, BOOL, STRING}, IDENT: {CONDITION}, NUM: {OPERATOR, RBT, LITERAL_END}, BOOL: {OPERATOR, RBT, LITERAL_END}, STRING: {OPERATOR, RBT, LITERAL_END}, ILLEGAL: {LITERAL_END}, }
StateMatrix 状态转移矩阵
Functions ¶
This section is empty.
Types ¶
type Token ¶
type Token string
const ( LITERAL_BEGIN Token = "literal_begin" LITERAL_END Token = "literal_end" LBT Token = "lbt" // 左括号 RBT Token = "rbt" // 有括号 OPERATOR Token = "operator" // 逻辑关系 CONDITION Token = "condition" // 条件 IDENT Token = "ident" // 变量 NUM Token = "num" // 数字 BOOL Token = "bool" // bool STRING Token = "string" // 字符串 DELIM Token = "delim" // 空字符 ILLEGAL Token = "illegal" // 无法解析 )
token
Click to show internal directories.
Click to hide internal directories.