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 list 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

property pop

Alias for field number 0

property push

Alias for field number 1

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.

add(target)[source]

Add a Target to this factory.

get()[source]

Get the current target, may be None if no pop and push.

After this the current target is reset.

push(*lexicons)[source]

Enter one or more lexicons.

pop(pop=-1)[source]

Pop off one (or more) lexicon.

classmethod make(lexicon, rule)[source]

Create a Target of a rule.