Parsing
Passgen uses a custom language to encode the pattern it uses to generate passphrases. It is fully AST-based, meaning that the result of parsing is an AST, and the AST is also consumed by the generator (as opposed to using a bytecode approach, whereby the parsed pattern AST is first compiled into bytecode, which is later executed).
Processing of parsed patterns in Passgen is done in three steps:
- Parsing: In this stage, the pattern is parsed and loaded into a raw AST.
- Optimizing: An optimizer simplifies the AST, yielding an AST that is optimized for generation.
- Preparing: During preparation, all external dependencies are resolved and injected into the AST, yielding a Pattern that can be used for generation.
The goal of this is to yield an AST that can be fed to the generator, which includes all the data needed to generate a passphrase from the parsed pattern.
Finally, the pattern is prepared for generation. This consumes the optimized AST and injects dependencies.