Documentation ¶
Overview ¶
***********************************************************************************
author: soforth date: 2014-9-13 email: soforth@qq.com description: a HTTP package filter, supported BNF as bellow: grammer -> expr => RET grammer // if ( expr ) return RET else return grammer | default => RET grammer // if grammer != 0 return grammer default: return RET | expr grammer // if ( expr) return grammer else return 0 ; expr -> expr || term // logic OR operation | expr && term // logic AND operation | term ; term -> factor @ ( list ) // variable/string/double is in list | factor !@ ( list ) // variable/string/double is not in list | factor > factor // left great than right | factor < factor // left less than right | factor == factor // left equal right | factor != factor // left not equal right | factor >= factor // left great than or equal right | factor <= factor // left less than or equal right | factor # REGEX // left regex match right pattern | factor !# REGEX // left regex not match right pattern | ( expr ) // term can be a expr in paren ; list -> factor list; // list is recursive defined factor -> DOUBLE_const // factor can be double immediate constant | STRING_const // also can be string immediate constant | VAR_str // also can be variable as symbol input by user | func // also can be a internal function ; func -> VAR_str ( list ); // function has zero or more arguments
************************************************************************************
Index ¶
- Constants
- func CmpDbl(kind TKind_t, d1, d2 float64) (int, error)
- func CmpStr(kind TKind_t, s1, s2 string) (int, error)
- func DeleteSymlist(symlist *SymList)
- func DumpSymlist(symlist *SymList)
- func EvalCmp(kind TKind_t, lfactor, rfactor *Factor, symlist *SymList) (int, error)
- func EvalExpr(expr *Expr, symlist *SymList) (int, error)
- func EvalGrammer(grammer *Grammer, symlist *SymList) (int, error)
- func EvalList(kind TKind_t, factor *Factor, list *List, symlist *SymList) (int, error)
- func EvalRegex(kind TKind_t, lfactor *Factor, regex *regexp.Regexp, symlist *SymList) (int, error)
- func EvalTerm(term *Term, symlist *SymList) (int, error)
- type EKind_t
- type Expr
- type FKind_t
- type Factor
- func EvalAtoi(list *List, symlist *SymList) (*Factor, error)
- func EvalCount(symlist *SymList) (*Factor, error)
- func EvalFunc(fn *Func, symlist *SymList) (*Factor, error)
- func EvalItoa(list *List, symlist *SymList) (*Factor, error)
- func EvalLen(list *List, symlist *SymList) (*Factor, error)
- func EvalMD5(list *List, symlist *SymList) (*Factor, error)
- func NewFactor(kind FKind_t, dbl float64, str string, vari string, fn *Func) (*Factor, error)
- func SymbolLookup(symlist *SymList, name string) (*Factor, error)
- type FnKind_t
- type Func
- type GKind_t
- type Grammer
- type Lexer
- type List
- type Parser
- type SymList
- func AppendSymlist(symlist *SymList, name, value string, kind FKind_t) (*SymList, error)
- func AppendSymlistDouble(symlist *SymList, name string, value float64) (*SymList, error)
- func AppendSymlistString(symlist *SymList, name, value string) (*SymList, error)
- func JsonToSymlist(jstr string) (symlist *SymList, err error)
- func NewSymlist(name, value string, kind FKind_t) (*SymList, error)
- func NewSymlistDouble(name string, value float64) (*SymList, error)
- func NewSymlistString(name, value string) (*SymList, error)
- func QueryToSymlist(query string) (symlist *SymList, err error)
- type TKind_t
- type Term
Constants ¶
View Source
const ( EGET = GKind_t(0) DGET = GKind_t(1) EEXPR = GKind_t(2) AND = EKind_t(0) OR = EKind_t(1) TERM = EKind_t(2) IN = TKind_t(0) NI = TKind_t(1) GT = TKind_t(2) LT = TKind_t(3) EQ = TKind_t(4) NE = TKind_t(5) GE = TKind_t(6) LE = TKind_t(7) MA = TKind_t(8) NM = TKind_t(9) EXPR = TKind_t(10) DOUBLE = FKind_t(0) STRING = FKind_t(1) VARIABLE = FKind_t(2) FUNCTION = FKind_t(3) LEN = FnKind_t(0) MD5 = FnKind_t(1) COUNT = FnKind_t(2) ATOI = FnKind_t(3) ITOA = FnKind_t(4) )
View Source
const CMP = 57356
View Source
const COMMA = 57346
View Source
const CONTAIN = 57357
View Source
const DEFAULT = 57352
View Source
const FUNC = 57358
View Source
const GET = 57351
View Source
const LAND = 57349
View Source
const LOR = 57350
View Source
const LPAREN = 57347
View Source
const NUM = 57355
View Source
const RPAREN = 57348
View Source
const STR = 57354
View Source
const VAR = 57353
Variables ¶
This section is empty.
Functions ¶
func DeleteSymlist ¶
func DeleteSymlist(symlist *SymList)
func DumpSymlist ¶
func DumpSymlist(symlist *SymList)
Types ¶
type Factor ¶
type Factor struct { Kind FKind_t // DOUBLE, STRING, VARIABLE, FUNCTION Value interface{} }
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
func NewLexerWithInit ¶
NewLexerWithInit creates a new Lexer object, runs the given callback on it, then returns it.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
parser handle
type SymList ¶
func AppendSymlist ¶
func AppendSymlistDouble ¶
func AppendSymlistString ¶
func JsonToSymlist ¶
* parse a JSON string to symlist_t struct, string format should be: * {"double_name":10.0, "interger_name": 99, "string_name":"FIFA WC 2014", ...}
func NewSymlistString ¶
func QueryToSymlist ¶
* parse a query string to symlist_t struct , string format should be: * nmq=testmq&mac=xxxx&bootid=xxxx...
Click to show internal directories.
Click to hide internal directories.