Optional
assertThis function is called when dealing with lookarounds.
It will not be called for predefined assertion - ^
, $
, \b
, \B
. Use enter or
leave for predefined assertions instead.
x => x
Optional
continueWhether the current path should continue after the given element (return true
) or whether all elements that
follow this element should be skipped (return false
).
If the current path is a fork path, then only the elements until the fork is joined will be skipped. A stopped fork path will be joined with all other forks like normal.
You shouldn't modify state in this function. Modify state in leave instead.
See the documentation on enter for more details.
() => true
Optional
continueWhether the current path should go into the given element (return true
) or whether it should be skipped
(return false
). If the element is skipped, the given state will not be changed and passed as-is to the leave
function.
You shouldn't modify state in this function. Modify state in enter instead.
See the documentation on enter for more details.
() => true
Optional
continueWhether the current path should continue outside the given lookaround assertion.
Paths that leave a lookaround assertions (= go outside of it) generally can't be followed. However, for some operations it makes sense to do it anyway.
It usually makes sense to follow paths outside of assertions if
getMatchingDirectionFromAssertionKind(element.kind) !== direction
. This condition ensure that lookbehinds only
follow paths going out to the right (e.g. (?<=a)->b
) and lookaheads only follow paths going out to the left
(e.g. b<-(?=a)
).
If this function returns false
, endPath is guaranteed to be called next.
If this function returns true
, continueAfter is guaranteed to be called next for the
lookaround assertion.
You shouldn't modify state in this function. Modify state in endPath or enter instead.
() => false
Optional
endThis function is called when a path ends.
Paths end at the end the patterns and assertions. It means that there is no element after the pattern/assertion in that direction.
Optional
enterThis function is called when entering an element.
Operations for elements are called in the following order:
true
(_, x) => x
Optional
forkSplit off a new path from the given one.
This function should not modify the given state.
If the state is immutable, then fork
may be implemented as the identify function in regard to state
. If the
function is omitted, it will default to the identify function.
If the state is mutable, then fork
must be implemented.
x => x
Optional
leaveThis function is called when leaving an element.
See the documentation on enter for more details.
(_, x) => x
Joins any number of paths to create a combined path.
A set of operations that determine how state is propagated and changed.
See
followPaths