Documentation
¶
Overview ¶
Package ast holds ast related files
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArithmeticElement ¶ added in v0.46.0
type ArithmeticElement struct {
Op string `parser:"@( \"+\" | \"-\" )"`
Operand *BitOperation `parser:"@@"`
}
ArithmeticElement defines one element of ArithmeticElementList.
Grammar:
ArithmeticElement → ArithOp BitOperation ArithOp → "+" ArithOp → "-"
type ArithmeticOperation ¶ added in v0.46.0
type ArithmeticOperation struct {
Pos lexer.Position
First *BitOperation `parser:"@@"`
Rest []*ArithmeticElement `parser:"[ @@ { @@ } ]"`
}
ArithmeticOperation is contained only by Comparison; it holds the first BitOperation and an optional list of ArithmeticElements.
Grammar:
ArithmeticOperation → BitOperation ArithmeticOperation → BitOperation ArithmeticElementList ArithmeticElementList → ArithmeticElement ArithmeticElementList → ArithmeticElement ArithmeticElementList
type Array ¶
type Array struct {
Pos lexer.Position
CIDR *string `parser:"@CIDR"`
Variable *string `parser:"| @Variable"`
FieldReference *string `parser:"| @FieldReference"`
Ident *string `parser:"| @Ident"`
StringMembers []StringMember `parser:"| \"[\" @@ { \",\" @@ } \"]\""`
CIDRMembers []CIDRMember `parser:"| \"[\" @@ { \",\" @@ } \"]\""`
Numbers []int `parser:"| \"[\" @Int { \",\" @Int } \"]\""`
Idents []string `parser:"| \"[\" @Ident { \",\" @Ident } \"]\""`
}
Array is contained only by ArrayComparison or by Macro; it holds the right-hand side of an array membership test.
Grammar:
Array → CIDR Array → Variable Array → Ident Array → FieldReference Array → "[" StringMemberList "]" Array → "[" CIDRMemberList "]" Array → "[" NumberList "]" Array → "[" IdentList "]" StringMemberList → StringMember StringMemberList → StringMember "," StringMemberList CIDRMemberList → CIDRMember CIDRMemberList → CIDRMember "," CIDRMemberList NumberList → Number NumberList → Number "," NumberList IdentList → Ident IdentList → Ident "," IdentList
type ArrayComparison ¶
type ArrayComparison struct {
Pos lexer.Position
Op *string `parser:"@( \"in\" | \"not\" \"in\" | \"allin\" )"`
Array *Array `parser:"@@"`
}
ArrayComparison is contained only by Comparison; it holds the array operator and the right-hand Array.
Grammar:
ArrayComparison → ArrayOp Array ArrayOp → "in" ArrayOp → "notin" ArrayOp → "allin"
type BitOperation ¶
type BitOperation struct {
Pos lexer.Position
Unary *Unary `parser:"@@"`
Op *string `parser:"[ @( \"&\" | \"|\" | \"^\" )"`
Next *BitOperation `parser:"@@ ]"`
}
BitOperation is contained by ArithmeticOperation (as First or as Operand inside Rest) or by another BitOperation (via Next).
Grammar:
BitOperation → Unary BitOperation → Unary BitOp BitOperation BitOp → "&" BitOp → "|" BitOp → "^"
type BooleanExpression ¶
type BooleanExpression struct {
Pos lexer.Position
Expression *Expression `parser:"@@"`
}
BooleanExpression is contained only by Rule; it holds the root Expression of the rule.
Grammar:
BooleanExpression → Expression
type CIDRMember ¶ added in v0.36.0
type CIDRMember struct {
Pos lexer.Position
IP *string `parser:"@IP"`
CIDR *string `parser:"| @CIDR"`
}
CIDRMember defines one element of CIDRMemberList.
Grammar:
CIDRMember → IP CIDRMember → CIDR
type Comparison ¶
type Comparison struct {
Pos lexer.Position
ArithmeticOperation *ArithmeticOperation `parser:"@@"`
ScalarComparison *ScalarComparison `parser:"[ @@"`
ArrayComparison *ArrayComparison `parser:"| @@ ]"`
}
Comparison is contained only by Expression; it holds the left ArithmeticOperation and optional ScalarComparison or ArrayComparison.
Grammar:
Comparison → ArithmeticOperation Comparison → ArithmeticOperation ScalarComparison Comparison → ArithmeticOperation ArrayComparison
type Expression ¶
type Expression struct {
Pos lexer.Position
Comparison *Comparison `parser:"@@"`
Op *string `parser:"[ @( \"|\" \"|\" | \"or\" | \"&\" \"&\" | \"and\" )"`
Next *BooleanExpression `parser:"@@ ]"`
}
Expression is contained by BooleanExpression or by another Expression (via Next in a logical chain).
Grammar:
Expression → Comparison Expression → Comparison LogicalOp BooleanExpression LogicalOp → "||" LogicalOp → "or" LogicalOp → "&&" LogicalOp → "and"
type Macro ¶
type Macro struct {
Pos lexer.Position
Expression *Expression `parser:"@@"`
Array *Array `parser:"| @@"`
Primary *Primary `parser:"| @@"`
}
Macro is the root of a SECL macro body; it has no parent and contains an Expression, an Array, or a Primary.
Grammar:
Macro → Expression Macro → Array Macro → Primary
type ParsingContext ¶ added in v0.42.0
type ParsingContext struct {
// contains filtered or unexported fields
}
ParsingContext holds the parsers and optional rule cache; it has no parent (root factory for Rule, Macro, Expression).
func NewParsingContext ¶ added in v0.42.0
func NewParsingContext(withRuleCache bool) *ParsingContext
NewParsingContext returns a new parsing context
func (*ParsingContext) ParseExpression ¶ added in v0.65.0
func (pc *ParsingContext) ParseExpression(expr string) (*Expression, error)
ParseExpression parses a SECL expression
func (*ParsingContext) ParseMacro ¶ added in v0.42.0
func (pc *ParsingContext) ParseMacro(expr string) (*Macro, error)
ParseMacro parses a SECL macro
type Primary ¶
type Primary struct {
Pos lexer.Position
Ident *string `parser:"@Ident"`
CIDR *string `parser:"| @CIDR"`
IP *string `parser:"| @IP"`
Number *int `parser:"| @Int"`
Variable *string `parser:"| @Variable"`
FieldReference *string `parser:"| @FieldReference"`
String *string `parser:"| @String"`
Pattern *string `parser:"| @Pattern"`
Regexp *string `parser:"| @Regexp"`
Duration *int `parser:"| @Duration"`
SubExpression *Expression `parser:"| \"(\" @@ \")\""`
}
Primary is contained by Unary or by Macro; it holds a single operand.
Grammar:
Primary → Ident
Primary → CIDR
Primary → IP
Primary → Number
Primary → Variable
Primary → String
Primary → Pattern
Primary → Regexp
Primary → Duration
Primary → FieldReference
Primary → "(" Expression ")"
type Rule ¶
type Rule struct {
Pos lexer.Position
Expr string
BooleanExpression *BooleanExpression `parser:"@@"`
}
Rule is the root of a SECL rule AST; it has no parent and contains a BooleanExpression.
Grammar:
Rule → BooleanExpression
type ScalarComparison ¶
type ScalarComparison struct {
Pos lexer.Position
Op *string `parser:"@( \">\" \"=\" | \">\" | \"<\" \"=\" | \"<\" | \"!\" \"=\" | \"=\" \"=\" | \"=\" \"~\" | \"!\" \"~\" )"`
Next *Comparison `parser:"@@"`
}
ScalarComparison is contained only by Comparison; it holds a scalar operator and the right-hand Comparison.
Grammar:
ScalarComparison → ScalarOp Comparison ScalarOp → ">=" ScalarOp → ">" ScalarOp → "<=" ScalarOp → "<" ScalarOp → "!=" ScalarOp → "==" ScalarOp → "=~" ScalarOp → "!~"
type StringMember ¶
type StringMember struct {
Pos lexer.Position
String *string `parser:"@String"`
Pattern *string `parser:"| @Pattern"`
Regexp *string `parser:"| @Regexp"`
}
StringMember defines one element of StringMemberList.
Grammar:
StringMember → String StringMember → Pattern StringMember → Regexp
type Unary ¶
type Unary struct {
Pos lexer.Position
UnaryWithOp *UnaryWithOp `parser:"@@"`
Primary *Primary `parser:"| @@"`
}
Unary is contained by BitOperation or by UnaryWithOp (or recursively by Unary); it holds a Primary or a UnaryWithOp.
Grammar:
Unary → Primary Unary → UnaryOp Unary
type UnaryWithOp ¶ added in v0.71.0
type UnaryWithOp struct {
Pos lexer.Position
Op *string `parser:"@( \"!\" | \"not\" | \"-\" | \"^\" )"`
Unary *Unary `parser:"@@"`
}
UnaryWithOp is contained only by Unary; it holds a unary operator and the operand Unary.
Grammar:
UnaryWithOp → UnaryOp Unary UnaryOp → "!" UnaryOp → "not" UnaryOp → "-" UnaryOp → "^"