Documentation
¶
Overview ¶
Package script implements a simple classification scripting language. A script is a sequence of rules of the form “action <- pattern”, meaning send results matching pattern to the named action.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse(file, text string, fields []string) (*Script, []*SyntaxError)
Parse parses text as a script, returning the parsed form and any parse errors found. (The parser attempts to recover after parse errors by starting over at the next newline, so multiple parse errors are possible.) The file argument is used for reporting the file name in errors and in the Script's File field; Parse does not read from the file itself.
Types ¶
type Expr ¶
type Expr interface { // String returns the syntax for the pattern. String() string // Match reports whether the pattern matches the record. Match(record Record) bool }
An Expr is a pattern expression that can evaluate itself on a Record. The underlying concrete type is *CmpExpr, *AndExpr, *OrExpr, *NotExpr, or *RegExpr.
type NotExpr ¶
type NotExpr struct {
X Expr
}
A NotExpr represents the expression !X (the negation of X).
type SyntaxError ¶
type SyntaxError struct { File string // input file Line int // line number where error was detected (1-indexed) Offset int // byte offset in line where error was detected (1-indexed) Err string // description of error }
A SyntaxError reports a syntax error in a parsed match expression.
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string