Class Query.Runner
Runs Querys with support for predicates.
Functions
Runner.new (predicates, setup) | Create a new runner with a given set of predicates. |
Methods
Runner:iter_matches (cursor) | Iterate over the Matches of a cursor, executing predicates. |
Runner:iter_captures (cursor) | Uterate over the Captures of a cursor, executing predicates. |
Functions
- Runner.new (predicates, setup)
-
Create a new runner with a given set of predicates.
Predicates are functions that take a variable number of parameters of type QuantifiedCapture or string.
Currently, predicates' return values are ignored and discarded, unless the name of the predicate ends with '
?
'. In this case, falsey values short-circuit the execution of further predicates and causes the corresponding Match or Capture to be skipped.If results of predicates need to be saved, it is recommended to use closures with side-effects for these predicates.
The
setup
function is ran before executing the predicates of a Match or Capture. This may be useful to ensure side-effects of skipped items are erased.Parameters:
- predicates {string:function(...)}
- setup optional function()
Returns:
Methods
- Runner:iter_matches (cursor)
-
Iterate over the Matches of a cursor, executing predicates.
Parameters:
- cursor Cursor
Returns:
-
function():Match
iterator
- Runner:iter_captures (cursor)
-
Uterate over the Captures of a cursor, executing predicates.
Parameters:
- cursor cursor
Returns:
-
function():Capture
iterator