compileProgram
compileProgram(
pattern,maxProgramSize?):RegexProgram
Defined in: packages/format-regex/src/vm/compile.ts:236
Compiles a parsed pattern to a RegexProgram.
Every program embeds an unanchored left-to-right scan (split <try match here>, <consume one char and retry>) so a single VM run finds the leftmost
match without the caller looping over start offsets. This always produces the
same result as scanning start offsets one at a time — it just folds the scan
into the bytecode instead — at the cost of not special-casing patterns that
open with ^ (those simply fail assertStart at every offset but 0, which
is correct, just not the fastest possible instruction count for that case).
Parameters
Section titled “Parameters”pattern
Section titled “pattern”maxProgramSize?
Section titled “maxProgramSize?”number = DEFAULT_REGEX_LIMITS.maxProgramSize
Most instructions the program may hold; see
RegexLimits.maxProgramSize, whose default this takes.
Returns
Section titled “Returns”Throws
Section titled “Throws”If the program outgrows maxProgramSize.