Class: LEMInterpreter

LEMInterpreter

LEMInterpreter interprets a text query given its abstract syntax tree form and a LogEvent to check.

Upon calling LEMInterpreter#interpret, this class uses its visitFoo methods to traverse the provided AST. Thus, this class is part of the visitor pattern and implements the ASTVisitor interface.

Constructor

new LEMInterpreter(ast)

Constructs an interpreter that uses the given ast
Parameters:
Name Type Description
ast AST The abstract syntax tree that represents the query
Source:

Methods

interpret(logEvent) → {Boolean}

Checks if the query associated with this LEMInterpreter matches the provided LogEvent. This object's abstract syntax tree is interpreted using the provided LogEvent's fields as the environment - the binding of identifiers to values.
Parameters:
Name Type Description
logEvent LogEvent The LogEvent to check
Source:
Returns:
True if the query represented by this.ast matches the provided log event
Type
Boolean

(protected) visitBinaryOp(ast, env) → {LEMInterpreterValue}

Visits and interprets a BinaryOp in accordance with the visitor pattern

This method always produces a boolean-valued LEMInterpreterValue. The exact value of that boolean is the result of evaluating the binary operation represented by the BinaryOp that this method is visiting. See BinaryOp for information on the semantics of each operator.

Parameters:
Name Type Description
ast BinaryOp
env Object.<String, String> The environment - the binding of identifiers to values as pure-object mapping of strings to strings.
Source:
Returns:
The value resulting from visiting and handling the ast node.
Type
LEMInterpreterValue

(protected) visitIdentifier(ast, env) → {LEMInterpreterValue}

Visits and interprets an Identifer in accordance with the visitor pattern

The value returned will be a string-valued LEMInterpreterValue whose value is the value bound to the identifier represented by the Identifier ast node that this method is visiting. If the identifier is unbound in the current environment, an exception is thrown

Parameters:
Name Type Description
ast BinaryOp
env Object.<String, String> The environment - the binding of identifiers to values as pure-object mapping of strings to strings.
Source:
Throws:
an exception if the identifier does not exist in the current environment
Type
Exception
Returns:
The value resulting from visiting and handling the ast node.
Type
LEMInterpreterValue

(protected) visitImplicitSearch(ast, env) → {LEMInterpreterValue}

Visits and interprets an ImplicitSearch in accordance with the visitor pattern

The value returned will be boolean-valued LEMInterpreterValue. The boolean value will be true if the ImplictSearch's query can be "found" in the environment. For a precise definition of found, see ImplicitSearch

Parameters:
Name Type Description
ast BinaryOp
env Object.<String, String> The environment - the binding of identifiers to values as pure-object mapping of strings to strings.
Source:
Returns:
The value resulting from visiting and handling the ast node.
Type
LEMInterpreterValue

(protected) visitRegexLiteral(ast, env) → {LEMInterpreterValue}

Visits and interprets a RegexLiteral in accordance with the visitor pattern

The value returned will be a regex-valued LEMInterpreterValue whose value is the regex literal represented by the RegexLiteral ast node this method is visiting.

Parameters:
Name Type Description
ast BinaryOp
env Object.<String, String> The environment - the binding of identifiers to values as pure-object mapping of strings to strings.
Source:
Returns:
The value resulting from visiting and handling the ast node.
Type
LEMInterpreterValue

(protected) visitStringLiteral(ast, env) → {LEMInterpreterValue}

Visits and interprets a StringLiteral in accordance with the visitor pattern

The value returned will be a string-valued LEMInterpreterValue whose value is the string literal represented by the StringLiteral ast node this method is visiting.

Parameters:
Name Type Description
ast BinaryOp
env Object.<String, String> The environment - the binding of identifiers to values as pure-object mapping of strings to strings.
Source:
Returns:
The value resulting from visiting and handling the ast node.
Type
LEMInterpreterValue