The target module#
A Target describes where to go.
In a lexicon rule, you can specify destinations using integers or lexicons.
A Target generalizes this in two values/attributes: pop
and push
.
pop
is zero or a negative integer, determining how many lexicons to
pop off the current state/context.
push
is a tuple of zero or more lexicons, determining which lexicons to
add to the current state.
You can sort of “add” targets using a TargetFactory, which can create single Target objects combining multiple targets in once.
- class Target(pop, push)#
Bases:
tuple
Used by the
lexer
to describe lexicon changes.- pop#
A negative integer or 0, describing how many lexicons to leave.
- push#
A tuple of zero or more Lexicons to enter.
- class TargetFactory[source]#
Bases:
object
Maintains a current target and allows you to store changes.
Call get() to get the final Target, and to reset the factory’s internal state.