Nimony

The road to Nim 3

regexcore

nimony/lib/std/private/regexcore.nim

Regular expression engine core: parser, NFA construction, subset construction and DFA minimization. Derived from lexim.

This module is shared by two very different consumers:

  • std/regex compiles a pattern at runtime and walks the resulting DFA

as bytecode;

  • std/deps/regex, the plugin behind std/regex's lex construct, runs the

very same pipeline at compile time and emits the DFA as straight-line Nimony code.

Sharing the pipeline is the point: a pattern cannot mean one thing in a generated lexer and another at runtime, because there is only one implementation of what it means.

Nothing in here raises. A malformed pattern sets err on the context and parsing unwinds to an epsilon node; every entry point hands that message back so the runtime API can turn it into an exception and the plugin into a compile-time diagnostic, each at its own source location.