Skip to content

Generation

Generation turns a .flexr.rb specification into Ruby source. The generated lexer keeps rule actions as Ruby code, so review the specification and generated artifact as executable code.

Terminal window
bundle exec flexr check lexer.flexr.rb
bundle exec flexr generate lexer.flexr.rb -o lexer.rb

The generator can use table, direct, or auto backends. firstmatch is experimental and requires an explicit option because it does not preserve the usual longest-match contract.

ModeBuild-time dependencyRuntime dependency
Runtimeflexrflexr
Generatedgenerator and flexrusually flexr
Standalone generatedgenerator and flexrgenerated file only

Use standalone output only when the generated file is verified and the deployment boundary requires no runtime gem. Confirm the generated file does not load the runtime before publishing it.

Treat the generator version, Ruby version, backend, encoding, and Unicode data snapshot as part of the artifact contract. If generated Ruby is committed, regenerate it in CI and fail on a diff.

See runtime vs generated and the repository’s generated artifact reference.