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:

    Runner

Methods

Runner:iter_matches (cursor)
Iterate over the Matches of a cursor, executing predicates.

Parameters:

Returns:

    function():Match iterator
Runner:iter_captures (cursor)
Uterate over the Captures of a cursor, executing predicates.

Parameters:

  • cursor cursor

Returns:

    function():Capture iterator
generated by LDoc 1.5.0 Last updated 2024-04-16 14:22:44