The query parser. Parses strings into ASTs, and converts ASTs to functions which match events.
The query parser. Parses strings into ASTs, and converts ASTs to functions which match events.
(antlr->ast [node-type & terms])
Converts a parse tree to an intermediate AST which is a little easier to analyze and work with. This is the AST we use for optimization and which is passed to various query compilers. Turns literals into their equivalent JVM types, and eliminates some unnecessary parser structure.
Converts a parse tree to an intermediate AST which is a little easier to analyze and work with. This is the AST we use for optimization and which is passed to various query compilers. Turns literals into their equivalent JVM types, and eliminates some unnecessary parser structure.
(ast string)
Takes a string to a general AST.
Takes a string to a general AST.
(ast-predicate terms)
Rewrites predicates with and/or/not to normal Clojure forms.
Rewrites predicates with and/or/not to normal Clojure forms.
(ast-prefix sym [t1 _ t2])
Rewrites binary expressions from infix to prefix. Takes a symbol (e.g. '=)
and a 3-element seq like (1 "=" 2)
and emits (= 1 2)
, ignoring the
middle term and transforming t1 and t2.
Rewrites binary expressions from infix to prefix. Takes a symbol `(e.g. '=)` and a 3-element seq like `(1 "=" 2)` and emits `(= 1 2)`, ignoring the middle term and transforming t1 and t2.
(ast-regex type [string _ pattern])
Takes a type of match (:like or :regex), a list of three string terms: an
AST resolving to a string, the literal =~ (ignored), and a pattern. Returns
(:regex pattern string-ast)
.
For :regex matches, emits a regular expression pattern. For :like matches, emits a string pattern.
Takes a type of match (:like or :regex), a list of three string terms: an AST resolving to a string, the literal =~ (ignored), and a pattern. Returns `(:regex pattern string-ast)`. For :regex matches, emits a regular expression pattern. For :like matches, emits a string pattern.
(clj-ast ast)
Rewrites an AST to eval-able Clojure forms.
Rewrites an AST to eval-able Clojure forms.
(clj-ast-field field)
Takes a keyword field name and emits an expression to extract that field
from an 'event map, e.g. (:fieldname event)
.
Takes a keyword field name and emits an expression to extract that field from an 'event map, e.g. `(:fieldname event)`.
(clj-ast-guarded-prefix f check [a b])
Like prefix, but inserts a predicate check around both terms.
Like prefix, but inserts a predicate check around both terms.
(clj-ast-regex-match pattern-transformer [pattern field])
Takes a pattern transformer, and a list of [pattern string-ast], and emits code to match the string-ast's results with a regex match, compiling pattern with pattern-transformer.
Takes a pattern transformer, and a list of [pattern string-ast], and emits code to match the string-ast's results with a regex match, compiling pattern with pattern-transformer.
(clj-ast-tagged tag)
Takes a tag and emits an expression to match that tag in an event.
Takes a tag and emits an expression to match that tag in an event.
(fun ast)
Transforms an AST into a fn [event] which returns true if the query matches that event. Example:
(def q (fun (ast "metric > 2")))
(q {:metric 1}) => false
(q {:metric 3}) => true
Transforms an AST into a fn [event] which returns true if the query matches that event. Example: ```clojure (def q (fun (ast "metric > 2"))) (q {:metric 1}) => false (q {:metric 3}) => true ```
Speeds up the compilation of queries by caching map of ASTs to corresponding functions.
Speeds up the compilation of queries by caching map of ASTs to corresponding functions.
(make-regex string)
Convert a string like "foo%" into /^foo.*$/
Convert a string like "foo%" into /^foo.*$/
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close