Optimizer

This AST representation is then sent through an optimization pass, which simplifies the pattern and yields a list of dependencies. Dependencies are generally named wordlists, markov-chains and pattern presets.

Pattern processing workflow

The optimizer does three things:

  • Simplifies the AST
  • Turns data structures that are optimized for parsing into data structures optimized for generation
  • Finds unbound references (references to wordlists or pattern presets)

Fundamentally, the optimizer works by traversing the AST.

Simplifications

Single-Segment Group

The optimizer will turn a single-segment group into its contents.

passgen("(abc)") => passgen("abc")

Single-Character Set

The optimizer will turn a single-character set into just the single character.

passgen("[aa]") => passgen("a")

Data structure transform

Unbound references