~/bend-docscommunity

regex.bend checks

raw source on the hub · import bend-kit-regex@0.9.0.0/regex.bend as Regex

Linear-time regular expressions: RE2 syntax, Pike VM, capture groups. Source: https://github.com/paymog/bend-kit/tree/main/regex

4 imports
import Base
import bend-kit-unicode@0.1.0.0/unicode.bend as U
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
import ./fold.bend as F

Types

type Item source · line 16 · raw

Data

A set member: a code point range, or a Unicode general category ("L", "Lu", ...). Fold, under (?i): the code points whose simple case folding class meets items (complemented when neg). Its items are Rng and Prop only.

type Node source · line 22 · raw

Data

Assertion kinds: 0 start of text, 1 end of text, 2 word boundary, 3 not a word boundary.

type Tok source · line 32 · raw

Data

type Esc source · line 130 · raw

Data

type Cs source · line 249 · raw

Data

type Lx source · line 331 · raw

Data

type Num source · line 337 · raw

Data

A run of decimal digits: its value (capped at 100000), its length, and the rest.

type Frame source · line 483 · raw

Data

An open group: its capture index (None for (?:...)), and the enclosing alternatives and sequence.

type Ps source · line 487 · raw

Data

n: the next capture index. rep: the last token was a repetition. alts and cur are reversed.

type Inst source · line 620 · raw

Data

type Trie source · line 754 · raw

@-V:Data -> Data

A binary trie keyed by n >= 1: the path is the bits of n below its top bit, low bit first, so key n costs log2(n) steps and small keys stay near the root.

type Fs source · line 821 · raw

Data

The walk from pc 0 over the instructions that consume no char: the sets it reaches, or FsAny when it reaches a match, so that any char may start a match. thru: an assertion passes on to the next pc, as if it held; else it ends the walk with FsAny too.

type Ew source · line 864 · raw

Data

Bit-parallel NFA for is_match: bit pc stands for the set at pc, waiting on the next char. The epsilon walk from a pc: the sets it reaches and whether it reaches the match, where at0 says the position is the start of the text and at1 the end.

type Bit source · line 933 · raw

Data

The set at bit mask; follow: the sets live after it takes a char; fin, end: whether the match is then reached inside the text, or at its end.

type Bits source · line 938 · raw

Data

at0: the sets live at the start of the text, and hit0 whether the empty match is there; hit01 the same for the empty text; atn and hitn the same inside the text, hit1 at its end.

type Asc source · line 1034 · raw

Data

The ASCII bytes that may start a match, one bit per byte, 32 to a word.

type Need source · line 1140 · raw

Data

Required literals ----------------- A literal is a sequence of sets: a text holds it at k when its unit at k+j is in set j for each j. Over a String the units are code points; over Bytes they are bytes. A Need is literals one of which every match contains, and far: the most units from a match's start to the start of that literal, or None when unbounded. A set is a node's own set, so under (?i) it holds every equivalent the node matches.

type Lt source · line 1146 · raw

Data

What every match of a node holds. exact: the literal every match spells out whole, when it has at most 32 sets; pre: a literal every match starts with; max: the most units a match takes, None when unbounded or past lt.cap(); cand: the best Need inside the node, far counted from its start.

type Anc source · line 1467 · raw

Data

A literal of a Need with its anchor: off, the anchor's place in the literal; set, the anchor; lit, the literal; tail, the literal from the anchor on.

type Sg source · line 1671 · raw

Data

A round of lits.seek: done, with the text it gives; or go on at t, the text from the anchor place p on, with b, the text from bp on.

type Regex source · line 1800 · raw

Data

type Th source · line 1872 · raw

Data

A thread: its pc and its capture slots.

type Cl source · line 1877 · raw

Data

The epsilon closure as a depth-first walk: stack is the work left, seen the pcs visited at this position, out the threads that wait on a char or match (reversed).

type Sc source · line 1932 · raw

Data

A scan of the threads at one char, in priority order: items are the threads that step past it (reversed), best the latest match. A match drops every later thread.

type Vm source · line 1986 · raw

Data

The live threads and the best match so far.

type Pass source · line 2031 · raw

Data

How many chars of an idle text to pass, and the char before the first one not passed.

type Op source · line 2118 · raw

Data

A new thread: pc, the thread at src it came from (or the seed), and the slots it saved.

type Tr source · line 2123 · raw

Data

next: the state after the char; hit: 1 + the index of the thread that matched, or 0; fresh: no match yet and every new thread comes from the seed, so the next state is a fresh start.

type Sk source · line 2128 · raw

Data

type Ix source · line 2131 · raw

Data

type Ik source · line 2135 · raw

Data

The interned states, how many there are, and the id of one.

type Lr source · line 2139 · raw

Data

A learned transition, with the next state's key in place of its id.

type Dt source · line 2306 · raw

Data

A step: the next state's pcs, and whether a match ends before the char.

type Dl source · line 2374 · raw

Type

A learned step: the table, the states, the index, its size, the next id (seed.id() after a match or with a full cache), and whether a match ended.

type Dr source · line 2399 · raw

Data

What the DFA hands on: no match; a match, which the Pike VM finds from the idle point p; or a full cache, after which the Pike VM runs from p.

type Dz source · line 2424 · raw

Type

A learn round's result, for the round after it.

type Ds source · line 2429 · raw

Data

The rounds of dfas.

type Span source · line 2542 · raw

Data

type Bs source · line 2618 · raw

Data

One char through the bit NFA: next the sets live after it, fin and end as in Bit.

type Dc source · line 2723 · raw

Data

A code point decoded from UTF-8 and its width in bytes, or DEnd at the end of the buffer. An invalid byte is U+FFFD of width 1, as in RE2.

type Rb source · line 2843 · raw

Type

The Pike VM over Bytes: the buffer, the offset i of the next char, that char, and the threads waiting on it.

type Rq source · line 3083 · raw

Type

The DFA over Bytes: the buffer, the transitions by state and ASCII char, the interned states, the current state, the offset i of the next char, that char, and the threads waiting on it.

type Spin source · line 3114 · raw

Type

A same transition leaves the VM and state id intact. Stop before the last byte: its following end-of-text context needs the plain Pike step.

type SpinStep source · line 3117 · raw

Type

type Ar source · line 3159 · raw

Type

Cached DFA steps reuse two thread buffers; the Pike VM handles learning and text boundaries.

type Qst source · line 3263 · raw

Type

type Qa source · line 3284 · raw

Type

type Dlb source · line 3496 · raw

Type

A step learned over bytes: the buffer, the char's width, the step.

type Dzb source · line 3499 · raw

Type

type Db source · line 3508 · raw

Data

The rounds of dfab.

type Rv source · line 3840 · raw

Type

type RevBits source · line 3843 · raw

Type

type RevPhase source · line 3883 · raw

Type

type RevFound source · line 3887 · raw

Type

type Rt source · line 4024 · raw

Type

The bit NFA over Bytes: the buffer, the offset i of the next char, that char, and the NFA state.

Definitions

def lit source · line 39 · raw

@+c:U32 -> Node

def fold.points source · line 45 · raw

@xs:List<&2, U32> -> @acc:List<&2, Item> -> List<&2, Item>

def fold.point source · line 53 · raw

@+c:U32 -> List<&2, Item>

c and the code points equivalent to it, as one-point ranges.

def lit.f source · line 56 · raw

@fold:Bool -> @+c:U32 -> Node

def fold.rng source · line 63 · raw

@one:Bool -> @+lo:U32 -> @+hi:U32 -> List<&2, Item>

def fold.item source · line 71 · raw

@i:Item -> List<&2, Item>

A class member under (?i). Escapes come back from esc already folded.

def fold.items source · line 80 · raw

@xs:List<&2, Item> -> List<&2, Item>

def fold.class source · line 87 · raw

@fold:Bool -> @items:List<&2, Item> -> List<&2, Item>

def is_digit source · line 94 · raw

@+c:U32 -> Bool

def is_word source · line 97 · raw

@+c:U32 -> Bool

def is_alnum source · line 100 · raw

@+c:U32 -> Bool

def perl.d source · line 104 · raw

List<&2, Item>

\d \w \s are ASCII, as in RE2.

def perl.D source · line 107 · raw

List<&2, Item>

def perl.w source · line 110 · raw

List<&2, Item>

def perl.W source · line 113 · raw

List<&2, Item>

def perl.s source · line 116 · raw

List<&2, Item>

def perl.S source · line 119 · raw

List<&2, Item>

def cats source · line 122 · raw

List<&2, String>

def prop.if source · line 136 · raw

@ok:Bool -> @neg:Bool -> @name:String -> @t:String -> Esc

def prop.ok source · line 143 · raw

@neg:Bool -> @+name:String -> @t:String -> Esc

def prop.name source · line 146 · raw

@s:String -> @neg:Bool -> @acc:String -> Esc

def prop source · line 156 · raw

@neg:Bool -> @s:String -> Esc

\pL or \p{Lu}; \P negates.

def prop.fold source · line 166 · raw

@fold:Bool -> @e:Esc -> Esc

Under (?i), \p{X} is every code point equivalent to one in X, and \P{X} the rest.

def perl.w.f source · line 182 · raw

@fold:Bool -> List<&2, Item>

\w under (?i) adds the Kelvin sign and long s; \W loses them. \d and \s have no case.

def perl.W.f source · line 189 · raw

@fold:Bool -> List<&2, Item>

def esc.other source · line 197 · raw

@alnum:Bool -> @+c:U32 -> @t:String -> Esc

An escaped letter or digit with no meaning is an error, as in RE2.

def esc source · line 205 · raw

@+fold:Bool -> @s:String -> Esc

The text after a backslash; fold under (?i).

def class.range source · line 254 · raw

@ok:Bool -> @+c:U32 -> @+d:U32 -> @u:String -> @items:List<&2, Item> -> Cs

def class.hi source · line 261 · raw

@e:Esc -> @+c:U32 -> @items:List<&2, Item> -> Cs

def class.lo source · line 273 · raw

@+c:U32 -> @t:String -> @items:List<&2, Item> -> Cs

c is one member; a "-" and a code point after it make a range.

def class.esc source · line 284 · raw

@e:Esc -> @items:List<&2, Item> -> Cs

def class.step source · line 296 · raw

@+fold:Bool -> @s:String -> @first:Bool -> @items:List<&2, Item> -> Cs

A "]" right after "[" or "[^" is a member.

def class.run source · line 312 · raw

@fuel:Nat -> @+fold:Bool -> @st:Cs -> Cs

fuel: every step eats at least one char.

def class source · line 325 · raw

@+fold:Bool -> @+s:String -> @first:Bool -> Cs

def num.add source · line 340 · raw

@+acc:U32 -> @+c:U32 -> U32

def num.go source · line 343 · raw

@t:String -> @+c:U32 -> @+acc:U32 -> @+n:U32 -> @dig:Bool -> Num

def num source · line 358 · raw

@s:String -> Num

def lex.rep source · line 366 · raw

@+min:U32 -> @max:Maybe<&2, U32> -> @t:String -> @toks:List<&2, Tok> -> Lx

A trailing "?" makes a repetition lazy.

def Num.n source · line 373 · raw

@m:Num -> U32

def lex.brace.max source · line 378 · raw

@none:Bool -> @+min:U32 -> @m:Num -> @orig:String -> @toks:List<&2, Tok> -> Lx

A "{" that does not start {n}, {n,} or {n,m} is a literal, as in RE2.

def lex.brace.min source · line 390 · raw

@none:Bool -> @m:Num -> @+orig:String -> @toks:List<&2, Tok> -> Lx

def lex.class source · line 407 · raw

@fold:Bool -> @neg:Bool -> @r:Cs -> @toks:List<&2, Tok> -> Lx

def lex.esc source · line 416 · raw

@fold:Bool -> @e:Esc -> @toks:List<&2, Tok> -> Lx

def lex.step source · line 427 · raw

@+fold:Bool -> @s:String -> @toks:List<&2, Tok> -> Lx

def lex source · line 466 · raw

@fuel:Nat -> @+fold:Bool -> @st:Lx -> Maybe<&2, List<&2, Tok>>

fuel: every step but the last eats at least one char.

def cat source · line 490 · raw

@a:Node -> @b:Node -> Node

def seq.go source · line 501 · raw

@xs:List<&2, Node> -> @acc:Node -> Node

def seq source · line 508 · raw

@xs:List<&2, Node> -> Node

def alt.go source · line 511 · raw

@xs:List<&2, Node> -> @acc:Node -> Node

def group source · line 518 · raw

@cap:Maybe<&2, U32> -> @a:Node -> Node

def rep.copies source · line 525 · raw

@k:Nat -> @+h:Node -> @acc:Node -> Node

def rep.opt source · line 532 · raw

@k:Nat -> @+g:Bool -> @+h:Node -> Node

def rep.inf source · line 540 · raw

@k:Nat -> @+g:Bool -> @+h:Node -> Node

x* is (x+)?, so an empty x cannot loop; x{n,} is n-1 copies then x+; x{n,m} is n copies then (x(x...)?)?, as RE2 builds them.

def rep.fin source · line 547 · raw

@max:Maybe<&2, U32> -> @+min:U32 -> @+g:Bool -> @+h:Node -> Node

def rep source · line 554 · raw

@+h:Node -> @+min:U32 -> @max:Maybe<&2, U32> -> @+g:Bool -> Node

def rep.ok source · line 558 · raw

@+min:U32 -> @max:Maybe<&2, U32> -> Bool

Counts go up to 1000, and a repetition cannot repeat, as in RE2.

def parse.rep source · line 565 · raw

@ok:Bool -> @cur:List<&2, Node> -> @+min:U32 -> @max:Maybe<&2, U32> -> @+g:Bool -> @+n:U32 -> @stack:List<&2, Frame> -> @alts:List<&2, Node> -> Ps

def parse.open source · line 576 · raw

@cap:Bool -> @+n:U32 -> @stack:List<&2, Frame> -> @alts:List<&2, Node> -> @cur:List<&2, Node> -> Ps

def parse.close source · line 583 · raw

@stack:List<&2, Frame> -> @+n:U32 -> @alts:List<&2, Node> -> @cur:List<&2, Node> -> Ps

def parse.tok source · line 590 · raw

@tok:Tok -> @+n:U32 -> @rep:Bool -> @stack:List<&2, Frame> -> @alts:List<&2, Node> -> @cur:List<&2, Node> -> Ps

def parse.step source · line 603 · raw

@st:Ps -> @tok:Tok -> Ps

def parse source · line 610 · raw

@toks:List<&2, Tok> -> @st:Ps -> Ps

def required.right source · line 629 · raw

@b:Maybe<&2, U32> -> @a:Maybe<&2, U32> -> Maybe<&2, U32>

A byte that every match must contain. Optional branches and character classes have none.

def required source · line 636 · raw

@n:Node -> Maybe<&2, U32>

def required.join source · line 657 · raw

@right:Maybe<&2, Node> -> @left:Maybe<&2, Node> -> @a:Node -> Maybe<&2, Node>

def required.prefix source · line 665 · raw

@n:Node -> Maybe<&2, Node>

The first iteration contains the selected literal; every occurrence is inspected.

def reverse.ok source · line 678 · raw

@n:Node -> Bool

def reverse.node source · line 695 · raw

@n:Node -> Node

def size source · line 710 · raw

@n:Node -> U32

def emit source · line 730 · raw

@n:Node -> @+pc:U32 -> @rest:List<&2, Inst> -> List<&2, Inst>

The instructions of n, placed at pc, in front of rest. ISplit tries x first.

def trie.get source · line 759 · raw

@-V:Data -> @t:Trie<V> -> @here:Bool -> @left:Bool -> @+n:U32 -> Maybe<&2, V>

here: n is 1. left: n is even.

def trie.put source · line 775 · raw

@-V:Data -> @fuel:Nat -> @t:Trie<V> -> @here:Bool -> @left:Bool -> @+n:U32 -> @v:V -> Trie<V>

fuel: a U32 key has at most 32 bits.

def trie.at source · line 803 · raw

@-V:Data -> @t:Trie<V> -> @+k:U32 -> Maybe<&2, V>

The value at key k, stored as n = k + 1.

def trie.set source · line 807 · raw

@-V:Data -> @t:Trie<V> -> @+k:U32 -> @v:V -> Trie<V>

def trie.from source · line 811 · raw

@-V:Data -> @xs:List<&2, V> -> @+k:U32 -> @t:Trie<V> -> Trie<V>

def first.inst source · line 825 · raw

@thru:Bool -> @i:Maybe<&2, Inst> -> @+pc:U32 -> @stack:List<&2, U32> -> @seen:List<&2, U32> -> @sets:List<&2, Inst> -> Fs

def first.seen source · line 840 · raw

@+thru:Bool -> @hit:Bool -> @+prog:List<&2, Inst> -> @+pc:U32 -> @stack:List<&2, U32> -> @seen:List<&2, U32> -> @sets:List<&2, Inst> -> Fs

def first source · line 848 · raw

@fuel:Nat -> @+thru:Bool -> @+prog:List<&2, Inst> -> @st:Fs -> Maybe<&2, List<&2, Inst>>

fuel: each pc expands once and pushes at most two pcs.

def eps.ctx source · line 867 · raw

@k:U32 -> @+at0:Bool -> @+at1:Bool -> Bool

def eps.assert source · line 876 · raw

@ok:Bool -> @+pc:U32 -> @stack:List<&2, U32> -> @seen:List<&2, U32> -> @mask:U32 -> @hit:Bool -> Ew

def eps.inst source · line 883 · raw

@i:Maybe<&2, Inst> -> @+pc:U32 -> @+at0:Bool -> @+at1:Bool -> @stack:List<&2, U32> -> @seen:List<&2, U32> -> @+mask:U32 -> @hit:Bool -> Ew

def eps.seen source · line 900 · raw

@hit:Bool -> @+prog:List<&2, Inst> -> @+pc:U32 -> @+at0:Bool -> @+at1:Bool -> @w:Ew -> Ew

def eps.go source · line 909 · raw

@fuel:Nat -> @+prog:List<&2, Inst> -> @+at0:Bool -> @+at1:Bool -> @w:Ew -> Ew

fuel: each pc expands once and pushes at most two pcs.

def eps source · line 920 · raw

@+fuel:Nat -> @+prog:List<&2, Inst> -> @+pc:U32 -> @+at0:Bool -> @+at1:Bool -> Ew

def Ew.mask source · line 923 · raw

@w:Ew -> U32

def Ew.hit source · line 927 · raw

@w:Ew -> Bool

def bits.set source · line 941 · raw

@+fuel:Nat -> @+prog:List<&2, Inst> -> @+pc:U32 -> @neg:Bool -> @items:List<&2, Item> -> Bit

def bits.sets source · line 945 · raw

@xs:List<&2, Inst> -> @+fuel:Nat -> @+prog:List<&2, Inst> -> @+pc:U32 -> List<&2, Bit>

def bits.plain source · line 955 · raw

@xs:List<&2, Inst> -> Bool

Word boundaries depend on the chars on both sides, which one mask per set cannot track.

def bits.if source · line 964 · raw

@ok:Bool -> @+fuel:Nat -> @+prog:List<&2, Inst> -> Maybe<&2, Bits>

def bits source · line 973 · raw

@+fuel:Nat -> @+prog:List<&2, Inst> -> Maybe<&2, Bits>

def item.plain source · line 977 · raw

@i:Item -> @+c:U32 -> Bool

A Rng or Prop; a Fold never nests.

def items.plain source · line 986 · raw

@xs:List<&2, Item> -> @+c:U32 -> Bool

def fold.any source · line 993 · raw

@os:List<&2, U32> -> @+xs:List<&2, Item> -> Bool

def fold.has source · line 1001 · raw

@hit:Bool -> @+c:U32 -> @+xs:List<&2, Item> -> Bool

The case table is read only when c itself misses.

def item.has source · line 1008 · raw

@i:Item -> @+c:U32 -> Bool

def items.has source · line 1017 · raw

@xs:List<&2, Item> -> @+c:U32 -> Bool

def starts source · line 1024 · raw

@xs:List<&2, Inst> -> @+c:U32 -> Bool

def asc.bit source · line 1037 · raw

@hit:Bool -> @+c:U32 -> @a:Asc -> Asc

def rng.mask source · line 1047 · raw

@out:Bool -> @+a:U32 -> @+b:U32 -> U32

The bits a..b of a word, or none when out.

def rng.word source · line 1055 · raw

@+base:U32 -> @+lo:U32 -> @+hi:U32 -> U32

The bytes lo..hi of the word for bytes base to base+31.

def item.scan source · line 1060 · raw

@n:Nat -> @+c:U32 -> @+i:Item -> @a:Asc -> Asc

c: the byte for step n, counting down from 127 to 0.

def item.asc source · line 1068 · raw

@i:Item -> Asc

The ASCII bytes of an item: a range by its bounds, others byte by byte.

def asc.union source · line 1077 · raw

@a:Asc -> @b:Asc -> Asc

def asc.flip source · line 1082 · raw

@neg:Bool -> @a:Asc -> Asc

def items.asc source · line 1090 · raw

@xs:List<&2, Item> -> @a:Asc -> Asc

def sets.asc source · line 1098 · raw

@xs:List<&2, Inst> -> @a:Asc -> Asc

The ASCII bytes that start sets, as starts finds them.

def asc source · line 1107 · raw

@start:Maybe<&2, List<&2, Inst>> -> Maybe<&2, Asc>

def asc.word source · line 1114 · raw

@k:U32 -> @a:Asc -> U32

def asc.has source · line 1130 · raw

@+b:U32 -> @a:Asc -> Bool

Any non-ASCII byte may start a match: it may lead a char in start.

def lt.cap source · line 1149 · raw

U32

def mx.add source · line 1152 · raw

@a:Maybe<&2, U32> -> @b:Maybe<&2, U32> -> Maybe<&2, U32>

def mx.max source · line 1159 · raw

@a:Maybe<&2, U32> -> @b:Maybe<&2, U32> -> Maybe<&2, U32>

def lits.short source · line 1167 · raw

@xs:List<&2, List<&2, List<&2, U32>>> -> @+acc:U32 -> U32

The length of the shortest literal of xs, or acc.

def need.score source · line 1176 · raw

@n:Need -> U32

Longer literals first, then a bounded far.

def need.best source · line 1181 · raw

@a:Maybe<&2, Need> -> @b:Maybe<&2, Need> -> Maybe<&2, Need>

The better of a and b; a on a tie.

def need.shift source · line 1190 · raw

@c:Maybe<&2, Need> -> @m:Maybe<&2, U32> -> Maybe<&2, Need>

def need.pre source · line 1197 · raw

@p:List<&2, List<&2, U32>> -> Maybe<&2, Need>

def need.alt source · line 1205 · raw

@a:Maybe<&2, Need> -> @b:Maybe<&2, Need> -> Maybe<&2, Need>

One literal of each branch: at most 8 in all.

def lt.exact source · line 1213 · raw

@ea:Maybe<&2, List<&2, List<&2, U32>>> -> @eb:Maybe<&2, List<&2, List<&2, U32>>> -> Maybe<&2, List<&2, List<&2, U32>>>

def lt.pre source · line 1221 · raw

@ea:Maybe<&2, List<&2, List<&2, U32>>> -> @pa:List<&2, List<&2, U32>> -> @pb:List<&2, List<&2, U32>> -> List<&2, List<&2, U32>>

def lt.cat source · line 1228 · raw

@x:Lt -> @y:Lt -> Lt

def lt.alt source · line 1233 · raw

@x:Lt -> @y:Lt -> Lt

def lt.ezero source · line 1239 · raw

@e:Maybe<&2, List<&2, List<&2, U32>>> -> Maybe<&2, List<&2, List<&2, U32>>>

A node that matches only the empty text spells it out.

def lt.pmax source · line 1246 · raw

@m:Maybe<&2, U32> -> Maybe<&2, U32>

def lt.plus source · line 1254 · raw

@x:Lt -> Lt

Every match of a+ starts with a match of a.

def lt.quest source · line 1259 · raw

@x:Lt -> Lt

def lt.zero source · line 1264 · raw

Lt

def lt.none source · line 1267 · raw

@+w:U32 -> Lt

def set.pts source · line 1271 · raw

@items:List<&2, Item> -> @acc:List<&2, U32> -> Maybe<&2, List<&2, U32>>

The code points of a set made of single points only, or None.

def pts.ascii source · line 1280 · raw

@xs:List<&2, U32> -> Bool

def u8w source · line 1287 · raw

@+c:U32 -> U32

def u8 source · line 1291 · raw

@+c:U32 -> List<&2, List<&2, U32>>

The UTF-8 bytes of c, one set each.

def set.bytes source · line 1300 · raw

@+p:List<&2, U32> -> Maybe<&2, List<&2, List<&2, U32>>>

A set of code points as byte sets: one code point by its UTF-8 bytes, ASCII points as one set. U+FFFD also matches an invalid byte, so it has no bytes to require.

def items.w source · line 1308 · raw

@xs:List<&2, Item> -> @+acc:U32 -> U32

The most bytes a char of the set takes.

def lt.lit source · line 1317 · raw

@m:Maybe<&2, List<&2, List<&2, U32>>> -> @+w:U32 -> Lt

def lt.small source · line 1324 · raw

@m:Maybe<&2, List<&2, U32>> -> Maybe<&2, List<&2, U32>>

def lt.char source · line 1331 · raw

@m:Maybe<&2, List<&2, U32>> -> Maybe<&2, List<&2, List<&2, U32>>>

def lt.byte source · line 1338 · raw

@m:Maybe<&2, List<&2, U32>> -> Maybe<&2, List<&2, List<&2, U32>>>

def lt.set source · line 1346 · raw

@neg:Bool -> @bytes:Bool -> @+items:List<&2, Item> -> Lt

A set of at most 4 single points is a literal of one char.

def lt.fin source · line 1358 · raw

@l:Lt -> Lt

A node's prefix is a Need at its start.

def lt source · line 1363 · raw

@n:Node -> @+bytes:Bool -> Lt

def lt.cand source · line 1383 · raw

@l:Lt -> Maybe<&2, Need>

The literals every match of n holds: over code points, or over bytes.

def need.of source · line 1388 · raw

@n:Node -> @+bytes:Bool -> Maybe<&2, Need>

def pts.has source · line 1391 · raw

@xs:List<&2, U32> -> @+c:U32 -> Bool

def rank.word source · line 1414 · raw

@k:U32 -> U32

Anchors ------- A scan for a literal looks for its rarest set, its anchor, and checks the literal around each place that holds it, so that a text full of a literal's first char does not stop the scan at every char. rank: how common a unit is in text, from 0, the rarest, to 9. The ASCII ranks: 0 control chars but \t \n \r, and DEL 1 ! # $ % & + ; ? @ ^ ` | ~ Q X Z J 2 K V Y W U B G H F O 3 * < > q z j D L M P R C N T E A I S 4 k v w b = { } [ ] 5 f g y p 2-9 \ ' 6 c u m x 0 1 ( ) - / _ 7 d l h " , . : \t \r 8 t a o i n s r \n 9 e, space rank.word(k) holds the ranks of bytes 8k to 8k+7, four bits each, byte 8k+j at bit 4j.

def rank.hi source · line 1451 · raw

@+bytes:Bool -> @+c:U32 -> U32

Past ASCII: over Bytes a continuation byte 5, a lead byte 4, and a byte no UTF-8 text holds 0; over a String, a code point 4.

def rank source · line 1454 · raw

@+bytes:Bool -> @+c:U32 -> U32

def set.rank source · line 1458 · raw

@xs:List<&2, U32> -> @+bytes:Bool -> @+acc:U32 -> U32

The rank of a set: that of its most common member, or acc.

def lit.anchor source · line 1472 · raw

@l:List<&2, List<&2, U32>> -> @+bytes:Bool -> @+i:U32 -> @+at:U32 -> @+rk:U32 -> @best:List<&2, U32> -> Pair(U32, List<&2, U32>)

The place and the set of l's rarest set, the first of them on a tie: i is the place of l's head, and at, rk and best the place, rank and set of the rarest before it.

def anc.of source · line 1481 · raw

@r:Pair(U32, List<&2, U32>) -> @+l:List<&2, List<&2, U32>> -> Anc

def lit.anc source · line 1485 · raw

@+l:List<&2, List<&2, U32>> -> @+bytes:Bool -> Anc

def lits.ancs source · line 1489 · raw

@ls:List<&2, List<&2, List<&2, U32>>> -> @+bytes:Bool -> List<&2, Anc>

The literals with their anchors, over bytes or code points.

def ancs.sets source · line 1497 · raw

@xs:List<&2, Anc> -> @acc:List<&2, U32> -> List<&2, U32>

The anchors of xs, added to acc.

def ancs.big source · line 1506 · raw

@xs:List<&2, Anc> -> @+acc:U32 -> U32

The largest anchor place of xs, or acc. A literal found with its anchor at p starts at p - off; one that starts earlier has its anchor at p or later, so it starts at p - big or later.

def lit.at source · line 1514 · raw

@l:List<&2, List<&2, U32>> -> @s:String -> Bool

Whether s starts with the literal l.

def lit.at.c source · line 1526 · raw

@l:List<&2, List<&2, U32>> -> @+c:U32 -> @t:String -> Bool

Whether the text c, then t, starts with the literal l.

def lits.any source · line 1534 · raw

@ls:List<&2, List<&2, List<&2, U32>>> -> @+c:U32 -> @+t:String -> Bool

Whether a literal of ls starts the text c, then t.

def lits.asc source · line 1542 · raw

@xs:List<&2, U32> -> @a:Asc -> Asc

The anchors as a table of ASCII bytes: the ASCII members of xs added to a.

def fst.has source · line 1550 · raw

@+c:U32 -> @+m:Asc -> @+first:List<&2, U32> -> Bool

Whether c is an anchor place: by the table m when ASCII, else among first.

def fst.head source · line 1554 · raw

@s:String -> @+m:Asc -> @+first:List<&2, U32> -> Bool

Whether s's head is an anchor place; the end of the text is not.

def lits.here source · line 1562 · raw

@s:String -> @+ls:List<&2, List<&2, List<&2, U32>>> -> Bool

Whether a literal of ls starts at s's head.

def lits.pass source · line 1571 · raw

@fuel:Nat -> @hit:Bool -> @+s:String -> @+m:Asc -> @+first:List<&2, U32> -> String

s from its first char at an anchor place on, or empty; hit: whether s's head is one. fuel: each round passes a char. s is returned only before it is taken apart, so the loop reads it in place.

def lits.find source · line 1593 · raw

@fuel:Nat -> @ok:Bool -> @+s:String -> @+m:Asc -> @+first:List<&2, U32> -> @+ls:List<&2, List<&2, List<&2, U32>>> -> String

With every anchor at the head of its literal: s from the first literal of ls on, or empty when it holds none: s starts at an anchor place, or is empty, and ok: whether a literal starts at its head. fuel: each round passes a char.

def lits.passn source · line 1611 · raw

@fuel:Nat -> @hit:Bool -> @+s:String -> @+i:U32 -> @+m:Asc -> @+first:List<&2, U32> -> Pair(String, U32)

As lits.pass, counting: s from its first char at an anchor place on, and that char's offset, i being s's.

def anc.tail.if source · line 1630 · raw

@fits:Bool -> @tail:List<&2, List<&2, U32>> -> @+t:String -> Bool

def anc.tail source · line 1639 · raw

@x:Anc -> @+t:String -> @+p:U32 -> Bool

Whether x's anchor is at offset p, as far as the text from p on, t, shows: the literal fits before p, and its tail starts t.

def ancs.tail source · line 1643 · raw

@xs:List<&2, Anc> -> @+t:String -> @+p:U32 -> Bool

def anc.full.if source · line 1650 · raw

@fits:Bool -> @l:List<&2, List<&2, U32>> -> @+b:String -> @+n:U32 -> Bool

def anc.full source · line 1658 · raw

@x:Anc -> @+b:String -> @+bp:U32 -> @+p:U32 -> Bool

Whether x's literal starts at offset p - off, b being the text from bp on, bp <= p - off.

def ancs.full source · line 1662 · raw

@xs:List<&2, Anc> -> @+b:String -> @+bp:U32 -> @+p:U32 -> Bool

def seek.go source · line 1675 · raw

@r:Pair(String, U32) -> @+b:String -> @+bp:U32 -> Sg

def seek.next source · line 1680 · raw

@f:Nat -> @+rest:String -> @+p:U32 -> @+b:String -> @+bp:U32 -> @+m:Asc -> @+first:List<&2, U32> -> Sg

On from the anchor place after p, rest being the text after it.

def seek.full source · line 1684 · raw

@ok:Bool -> @f:Nat -> @+rest:String -> @+p:U32 -> @+b:String -> @+bp:U32 -> @+m:Asc -> @+first:List<&2, U32> -> Sg

ok: whether a literal has its anchor at p; b: the text from bp on.

def seek.cand source · line 1693 · raw

@ok:Bool -> @f:Nat -> @+rest:String -> @+p:U32 -> @+b:String -> @+bp:U32 -> @+m:Asc -> @+first:List<&2, U32> -> @+xs:List<&2, Anc> -> @+big:U32 -> Sg

ok: whether a tail starts at the anchor place p. Only then does b move up, to p - big, and the literals are checked whole.

def seek.step source · line 1702 · raw

@f:Nat -> @+t:String -> @+p:U32 -> @+b:String -> @+bp:U32 -> @+m:Asc -> @+first:List<&2, U32> -> @+xs:List<&2, Anc> -> @+big:U32 -> Sg

def lits.seek source · line 1712 · raw

@fuel:Nat -> @st:Sg -> @+m:Asc -> @+first:List<&2, U32> -> @+xs:List<&2, Anc> -> @+big:U32 -> String

The text from p - big on, or from 0 when p < big, p being the first anchor place where a literal of xs holds; empty when the text holds none. Each SkGo holds bp <= p - big for every anchor place p still to come. fuel: each round passes a char.

def lits.find.by source · line 1725 · raw

@zero:Bool -> @+big:U32 -> @+fuel:Nat -> @+s:String -> @+m:Asc -> @+first:List<&2, U32> -> @+xs:List<&2, Anc> -> @+ls:List<&2, List<&2, List<&2, U32>>> -> String

zero: whether every anchor heads its literal (big, the largest anchor place, is 0); then the literals are tested at each anchor place as they are, ls.

def lits.find.start source · line 1736 · raw

@+s:String -> @+ls:List<&2, List<&2, List<&2, U32>>> -> String

s from where a match may start on: from p - big, p being the first anchor place where a literal of xs holds, or from 0 when p < big; empty when s holds none. A literal is never empty, so a found one leaves a text that is not.

def need.from source · line 1746 · raw

@h:Maybe<&2, U32> -> @far:Maybe<&2, U32> -> Maybe<&2, U32>

Where a match may start: None when no literal occurs, so there is no match; else the first occurrence h less far, or 0 when far is unbounded or reaches past the start.

def need.zero source · line 1758 · raw

@far:Maybe<&2, U32> -> Bool

Whether every match starts at its literal.

def need.gate source · line 1769 · raw

@m:Maybe<&2, Need> -> @+plain:Bool -> Bool

Whether a String search uses its Need: when every match starts at its literal and no word boundary reads the char before one, so the automata start at the first literal, or at most the largest anchor place before it, with nothing to look up. Else a found literal would leave the automata the whole text from its start, or a walk back to the char before it, on top of the scan.

def rev.build source · line 1784 · raw

@m:Maybe<&2, Node> -> Maybe<&2, Bits>

def rev.if source · line 1793 · raw

@ok:Bool -> @node:Node -> Maybe<&2, Bits>

def lead.of source · line 1804 · raw

@start:Maybe<&2, List<&2, Inst>> -> @fuel:Nat -> @+insts:List<&2, Inst> -> Maybe<&2, List<&2, Inst>>

A walk that reaches start meets no assertion, so passing assertions changes nothing: lead is start.

def build source · line 1811 · raw

@+node:Node -> @+n:U32 -> Regex

def compile.fin source · line 1820 · raw

@st:Ps -> Maybe<&2, Regex>

def compile.parse source · line 1831 · raw

@toks:Maybe<&2, List<&2, Tok>> -> Maybe<&2, Regex>

def compile.go source · line 1838 · raw

@+fold:Bool -> @+pat:String -> Maybe<&2, Regex>

def compile source · line 1843 · raw

@+pat:String -> Maybe<&2, Regex>

The pattern, or None for a syntax error. A leading (?i) folds case over the whole pattern, by Unicode simple case folding as in RE2; no other flag is known.

def word source · line 1853 · raw

@m:Maybe<&2, Char> -> Bool

def assert.ok source · line 1860 · raw

@k:U32 -> @+prev:Maybe<&2, Char> -> @+next:Maybe<&2, Char> -> Bool

def close.assert source · line 1880 · raw

@ok:Bool -> @+pc:U32 -> @caps:List<&2, Maybe<&2, U32>> -> @stack:List<&2, Th> -> @seen:Trie<Unit> -> @out:List<&2, Th> -> Cl

def close.inst source · line 1887 · raw

@i:Maybe<&2, Inst> -> @+pc:U32 -> @+caps:List<&2, Maybe<&2, U32>> -> @stack:List<&2, Th> -> @seen:Trie<Unit> -> @out:List<&2, Th> -> @+pos:U32 -> @+prev:Maybe<&2, Char> -> @+next:Maybe<&2, Char> -> Cl

def close.seen source · line 1906 · raw

@hit:Bool -> @+prog:Trie<Inst> -> @+pc:U32 -> @caps:List<&2, Maybe<&2, U32>> -> @stack:List<&2, Th> -> @seen:Trie<Unit> -> @out:List<&2, Th> -> @+pos:U32 -> @+prev:Maybe<&2, Char> -> @+next:Maybe<&2, Char> -> Cl

ponytail: trie lookup and membership cost O(log m) per thread step, so a char costs O(m log m) for m instructions; a sparse set over an Array would make a step O(1).

def close.step source · line 1913 · raw

@th:Th -> @stack:List<&2, Th> -> @+seen:Trie<Unit> -> @out:List<&2, Th> -> @+prog:Trie<Inst> -> @+pos:U32 -> @+prev:Maybe<&2, Char> -> @+next:Maybe<&2, Char> -> Cl

def close source · line 1918 · raw

@fuel:Nat -> @+prog:Trie<Inst> -> @+pos:U32 -> @+prev:Maybe<&2, Char> -> @+next:Maybe<&2, Char> -> @st:Cl -> List<&2, Th>

fuel: each pc expands once and pushes at most two threads.

def scan.set source · line 1935 · raw

@hit:Bool -> @+pc:U32 -> @caps:List<&2, Maybe<&2, U32>> -> @items:List<&2, Th> -> @best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> Sc

def scan.char source · line 1942 · raw

@c:Maybe<&2, Char> -> @neg:Bool -> @set:List<&2, Item> -> @+pc:U32 -> @caps:List<&2, Maybe<&2, U32>> -> @items:List<&2, Th> -> @best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> Sc

def scan.hit source · line 1950 · raw

@any:Bool -> @caps:List<&2, Maybe<&2, U32>> -> @items:List<&2, Th> -> Sc

any: only whether a match exists counts, so a match also drops the earlier threads.

def scan.inst source · line 1957 · raw

@i:Maybe<&2, Inst> -> @c:Maybe<&2, Char> -> @+any:Bool -> @+pc:U32 -> @caps:List<&2, Maybe<&2, U32>> -> @items:List<&2, Th> -> @best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> Sc

def scan.go source · line 1966 · raw

@stop:Bool -> @th:Th -> @+prog:Trie<Inst> -> @c:Maybe<&2, Char> -> @+any:Bool -> @items:List<&2, Th> -> @best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> Sc

def scan.step source · line 1974 · raw

@st:Sc -> @th:Th -> @+prog:Trie<Inst> -> @c:Maybe<&2, Char> -> @+any:Bool -> Sc

def scan source · line 1978 · raw

@xs:List<&2, Th> -> @+prog:Trie<Inst> -> @+c:Maybe<&2, Char> -> @+any:Bool -> @st:Sc -> Sc

def seed source · line 1990 · raw

@best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> @xs:List<&2, Th> -> @init:List<&2, Maybe<&2, U32>> -> List<&2, Th>

Until a match is found, a new thread starts at each position, below every other.

def seed.skip source · line 1998 · raw

@items:List<&2, Th> -> @best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> @start:Maybe<&2, List<&2, Inst>> -> @next:Maybe<&2, Char> -> Bool

No live thread and no match yet: the seed is the only thread, and it dies unless next is in start.

def run.seed source · line 2007 · raw

@skip:Bool -> @items:List<&2, Th> -> @+best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+pos:U32 -> @+prev:Maybe<&2, Char> -> @+next:Maybe<&2, Char> -> Vm

def run.close source · line 2014 · raw

@sc:Sc -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+pos:U32 -> @+prev:Maybe<&2, Char> -> @+next:Maybe<&2, Char> -> Vm

def run.step source · line 2018 · raw

@st:Vm -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+pos:U32 -> @+c:Char -> @+next:Maybe<&2, Char> -> Vm

def run.end source · line 2022 · raw

@sc:Sc -> Maybe<&2, List<&2, Maybe<&2, U32>>>

def lead.has source · line 2027 · raw

@+c:U32 -> @+m:Asc -> @+sets:List<&2, Inst> -> Bool

Whether c is in lead: by the table for ASCII, by the sets past it.

def head.in source · line 2035 · raw

@s:String -> @+m:Asc -> @+sets:List<&2, Inst> -> Bool

Whether the head of s is in lead; the end of the text counts as in it, so a pass stops there.

def skip.str source · line 2044 · raw

@s:String -> @hit:Bool -> @+m:Asc -> @+sets:List<&2, Inst> -> @+n:U32 -> @+prev:U32 -> Pass

Pass the chars of s outside lead; hit: whether s's head is in lead; n counts the chars passed, prev is the last one passed.

def skip.lead source · line 2056 · raw

@lead:Maybe<&2, List<&2, Inst>> -> @asc:Maybe<&2, Asc> -> @+s:String -> @+c:Char -> Pass

Without lead every char may start a match, so none is passed.

def str.drop source · line 2065 · raw

@n:Nat -> @+s:String -> String

def Pass.n source · line 2076 · raw

@ps:Pass -> U32

def Pass.prev source · line 2080 · raw

@ps:Pass -> U32

def run source · line 2088 · raw

@fuel:Nat -> @s:String -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+any:Bool -> @+pos:U32 -> @st:Vm -> Maybe<&2, List<&2, Maybe<&2, U32>>>

pos: the position of s's head. Once a match exists and no thread is live, the rest of s cannot change it. With no thread live and no match yet, a char outside lead cannot start one, so the chars up to the next one in lead pass without a step: the seed there sees the char before it as prev. fuel: each round eats at least one char.

def seed.id source · line 2114 · raw

U32

The seed thread's index, and the id of a state the full cache could not add.

def vm.pcs source · line 2142 · raw

@xs:List<&2, Th> -> List<&2, U32>

def vm.key source · line 2149 · raw

@st:Vm -> Sk

def pcs.eq source · line 2153 · raw

@xs:List<&2, U32> -> @ys:List<&2, U32> -> Bool

def sk.eq source · line 2162 · raw

@a:Sk -> @b:Sk -> Bool

def pcs.hash source · line 2167 · raw

@xs:List<&2, U32> -> @+h:U32 -> U32

def sk.hash source · line 2174 · raw

@k:Sk -> U32

def ix.find source · line 2178 · raw

@xs:List<&2, Ix> -> @+k:Sk -> U32

def intern.bucket source · line 2185 · raw

@m:Maybe<&2, List<&2, Ix>> -> @+k:Sk -> U32

def intern.add source · line 2192 · raw

@m:Maybe<&2, List<&2, Ix>> -> @+k:Sk -> @+n:U32 -> List<&2, Ix>

def intern.if source · line 2199 · raw

@miss:Bool -> @+found:U32 -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+k:Sk -> @+hash:U32 -> Ik

def intern.full source · line 2206 · raw

@room:Bool -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+k:Sk -> Ik

def intern source · line 2216 · raw

@+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+cap:U32 -> @+k:Sk -> Ik

A full cache is not searched; the plain Pike VM handles the remaining text.

def lead.sets source · line 2236 · raw

@m:Maybe<&2, List<&2, Inst>> -> List<&2, Inst>

The sets of lead; none without it.

def asc.or source · line 2244 · raw

@m:Maybe<&2, Asc> -> Asc

The table of asc; empty without it.

def byte.at source · line 2252 · raw

@+w:U32 -> @+i:U32 -> U32

Byte i of a buffer, from the word that holds it.

def dk.none source · line 2255 · raw

U32

def dk.of source · line 2258 · raw

@+wb:Bool -> @+c:U32 -> U32

def dk.prev source · line 2262 · raw

@+k:U32 -> Maybe<&2, Char>

A char of kind k, as an assertion reads it.

def dk.ths source · line 2272 · raw

@xs:List<&2, U32> -> List<&2, Th>

The threads of a state, the seed below them. A DFA keeps no captures.

def dk.key source · line 2280 · raw

@+k:U32 -> @pcs:List<&2, U32> -> Sk

A state's key: its kind, then its pcs.

def dk.kind source · line 2283 · raw

@k:Sk -> U32

def dk.pcs source · line 2290 · raw

@k:Sk -> List<&2, U32>

def dk.sk source · line 2298 · raw

@lead:Maybe<&2, List<&2, Inst>> -> @asc:Maybe<&2, Asc> -> Bool

Whether idle states may skip: lead and its table exist.

def dt.of source · line 2309 · raw

@sc:Sc -> Dt

def dt.hit source · line 2313 · raw

@d:Dt -> Bool

def dt.pcs source · line 2317 · raw

@d:Dt -> List<&2, U32>

def dfa.go source · line 2322 · raw

@+prog:Trie<Inst> -> @+fuel:Nat -> @+key:Sk -> @+c:Maybe<&2, Char> -> Dt

The step from the state key on c; None is the end of the text.

def dfa.ik source · line 2326 · raw

@hit:Bool -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+cap:U32 -> @+key:Sk -> Ik

The next state, interned, unless a match ended.

def ik.keys source · line 2333 · raw

@k:Ik -> Trie<List<&2, Ix>>

def ik.n source · line 2337 · raw

@k:Ik -> U32

def ik.id source · line 2341 · raw

@k:Ik -> U32

def dk.keys source · line 2346 · raw

@+cap:U32 -> Trie<List<&2, Ix>>

The index with the idle states.

def dk.sts source · line 2350 · raw

@+depth:Nat -> Array<Sk>

The states by id, with the idle states.

def dfa.store source · line 2354 · raw

@cache:Bool -> @tab:Array<U32> -> @+idx:U32 -> @+e:U32 -> Array<U32>

A learned step into the table: 1 a match, 2 + the next id, 0 unknown. Wide chars are not cached.

def dfa.put source · line 2361 · raw

@ok:Bool -> @sts:Array<Sk> -> @+id:U32 -> @+key:Sk -> Array<Sk>

def dfa.entry source · line 2369 · raw

@+hit:Bool -> @+id:U32 -> U32

The table entry for a learned step.

def dfa.learn source · line 2378 · raw

@r:Pair(Array<Sk>, Sk) -> @tab:Array<U32> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+id:U32 -> @+c:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+wb:Bool -> @+cap:U32 -> Dl

Learn the step from state id on c; r holds the states and id's key.

def dk.cap source · line 2388 · raw

@+len:U32 -> U32

The cache size for a text of len chars: states, and the depths of the table and the state array.

def dk.tab source · line 2391 · raw

@+len:U32 -> Nat

def dk.depth source · line 2394 · raw

@+len:U32 -> Nat

def dr.end source · line 2404 · raw

@hit:Bool -> @+p:U32 -> Dr

def dfas.end source · line 2411 · raw

@r:Pair(Array<Sk>, Sk) -> @+p:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> Dr

def str.head source · line 2416 · raw

@s:String -> U32

The head of s as a table column; a wide char or the end reads a column it then ignores.

def dfas source · line 2441 · raw

@fuel:Nat -> @+mode:Ds -> @z:Dz -> @+s:String -> @rt:Pair(Array<U32>, U32) -> @sts:Array<Sk> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+i:U32 -> @+id:U32 -> @+q:U32 -> @+p:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+wb:Bool -> @+lead:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+am:Asc -> @+sets:List<&2, Inst> -> @+sk:Bool -> @+cap:U32 -> Dr

The DFA over a String; mode picks the round. rt: the table and, in DsRead, its entry for id and s's head. i: the position of s's head, q the char before it (in DsLearn and DsTake, i is q's position); p: the last idle point. fuel: each char takes at most three rounds. Each value the next round takes is bound first, so no round delays work into it.

def str.prev.if source · line 2516 · raw

@zero:Bool -> @+p:U32 -> @+s:String -> Maybe<&2, Char>

The char before position p of s, or None at 0.

def exec.pike source · line 2524 · raw

@+s:String -> @+p:U32 -> @+total:U32 -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+any:Bool -> Maybe<&2, List<&2, Maybe<&2, U32>>>

The Pike VM from position p of s; total: the length of s.

def exec.dr source · line 2529 · raw

@d:Dr -> @+any:Bool -> @+s:String -> @+total:U32 -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> Maybe<&2, List<&2, Maybe<&2, U32>>>

After the DFA: with any, a match found is the answer; else the Pike VM runs from the idle point.

def spans source · line 2545 · raw

@caps:List<&2, Maybe<&2, U32>> -> List<&2, Maybe<&2, Span>>

def find.spans source · line 2554 · raw

@m:Maybe<&2, List<&2, Maybe<&2, U32>>> -> Maybe<&2, List<&2, Maybe<&2, Span>>>

def str.code source · line 2561 · raw

@m:Maybe<&2, Char> -> U32

def exec.at source · line 2572 · raw

@+k:U32 -> @+r:String -> @+s:String -> @+any:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+slots:Nat -> @+start:Maybe<&2, List<&2, Inst>> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+plain:Bool -> Maybe<&2, List<&2, Maybe<&2, U32>>>

The DFA, then the Pike VM, from position k of s: no match starts before k, and r is s from k. Past the start only a program without word boundaries comes here, so the DFA's first state is idle of kind 1, whatever the char before k. slots: capture slots to keep; is_match keeps none, so each ISave is free.

def exec.lit source · line 2584 · raw

@found:Bool -> @+r:String -> @+s:String -> @+any:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+slots:Nat -> @+start:Maybe<&2, List<&2, Inst>> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+plain:Bool -> Maybe<&2, List<&2, Maybe<&2, U32>>>

found: whether s holds a literal, r being s from the first, where the automata start.

def exec.need source · line 2591 · raw

@m:Maybe<&2, Need> -> @+s:String -> @+any:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+slots:Nat -> @+start:Maybe<&2, List<&2, Inst>> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+plain:Bool -> Maybe<&2, List<&2, Maybe<&2, U32>>>

def need.used source · line 2600 · raw

@m:Maybe<&2, Need> -> @gate:Bool -> Maybe<&2, Need>

The Need a String search uses: none without gate.

def exec source · line 2605 · raw

@re:Regex -> @+s:String -> @+any:Bool -> Maybe<&2, List<&2, Maybe<&2, U32>>>

With gate, a text without a required literal has no match, and no automaton runs; else the automata start at the first literal.

def find source · line 2610 · raw

@re:Regex -> @+s:String -> Maybe<&2, List<&2, Maybe<&2, Span>>>

The leftmost match in s: the span of group 0, then of each group; None for a group that did not take part.

def is_match.vm source · line 2614 · raw

@re:Regex -> @+s:String -> Bool

The Pike VM form of is_match: stops at the first match of any priority and records no captures.

def bits.take source · line 2621 · raw

@hit:Bool -> @+follow:U32 -> @+fin:Bool -> @+end:Bool -> @acc:Bs -> Bs

def bits.char source · line 2629 · raw

@live:Bool -> @+c:U32 -> @neg:Bool -> @items:List<&2, Item> -> @+follow:U32 -> @+fin:Bool -> @+end:Bool -> @acc:Bs -> Bs

def bits.step source · line 2637 · raw

@xs:List<&2, Bit> -> @+cur:U32 -> @+c:U32 -> @acc:Bs -> Bs

ponytail: one test per set in the program, not a table lookup; use per-byte tables if sets grow many.

def bits.idle source · line 2645 · raw

@start:Maybe<&2, List<&2, Inst>> -> @+cur:U32 -> @+atn:U32 -> @+c:U32 -> Bool

Only the sets live at a fresh start wait on c, and c starts none of them: nothing moves.

def bits.go source · line 2653 · raw

@idle:Bool -> @+sets:List<&2, Bit> -> @+atn:U32 -> @+hit1:Bool -> @+cur:U32 -> @+c:U32 -> Bs

hit1: a match starts and ends at the end of the text, so end starts from it.

def bits.run source · line 2663 · raw

@s:String -> @+sets:List<&2, Bit> -> @+start:Maybe<&2, List<&2, Inst>> -> @+atn:U32 -> @+hit1:Bool -> @r:Bs -> Bool

r: the sets live at s's head, whether a match was found, and whether one ends at the end of the text, if the text ends here. Inside the text an assertion can only fail, so fin implies end, and a match at fin is final.

def bits.is_match source · line 2676 · raw

@b:Bits -> @start:Maybe<&2, List<&2, Inst>> -> @+k:U32 -> @r:String -> Bool

From position k of s, no match starting before k: a fresh state past the start, as an idle step leaves.

def bits.lit source · line 2682 · raw

@found:Bool -> @+r:String -> @+s:String -> @b:Bits -> @start:Maybe<&2, List<&2, Inst>> -> Bool

As exec.lit.

def bits.need source · line 2689 · raw

@m:Maybe<&2, Need> -> @+s:String -> @b:Bits -> @start:Maybe<&2, List<&2, Inst>> -> Bool

def is_match.bits source · line 2698 · raw

@re:Regex -> @+s:String -> Maybe<&2, Bool>

The bit NFA form of is_match, or None when the program is too large or has a word boundary.

def is_match.pick source · line 2706 · raw

@m:Maybe<&2, Bool> -> @re:Regex -> @+s:String -> Bool

def is_match source · line 2714 · raw

@+re:Regex -> @+s:String -> Bool

Whether s has a match; the bit NFA runs when the program allows it, else the Pike VM.

def Dc.char source · line 2727 · raw

@d:Dc -> Maybe<&2, Char>

def pk.if source · line 2734 · raw

@ok:Bool -> @a:Array<U32> -> @+i:U32 -> Pair(Array<U32>, U32)

def pk source · line 2742 · raw

@a:Array<U32> -> @+len:U32 -> @+i:U32 -> Pair(Array<U32>, U32)

Byte i, or 0 past len, which is no continuation byte.

def cont source · line 2745 · raw

@+b:U32 -> Bool

def dec.pick source · line 2748 · raw

@ok2:Bool -> @ok3:Bool -> @ok4:Bool -> @+c2:U32 -> @+c3:U32 -> @+c4:U32 -> Dc

def dec.n source · line 2764 · raw

@+b0:U32 -> @+b1:U32 -> @+b2:U32 -> @+b3:U32 -> Dc

Overlong forms, surrogates, and code points past U+10FFFF are invalid.

def dec.b3 source · line 2776 · raw

@+b0:U32 -> @+b1:U32 -> @+b2:U32 -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Dc)

def dec.b2 source · line 2780 · raw

@+len:U32 -> @+i:U32 -> @+b0:U32 -> @+b1:U32 -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Dc)

def dec.b1 source · line 2784 · raw

@+len:U32 -> @+i:U32 -> @+b0:U32 -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Dc)

def dec.lead source · line 2788 · raw

@ascii:Bool -> @+len:U32 -> @+i:U32 -> @+b0:U32 -> @a:Array<U32> -> Pair(Array<U32>, Dc)

def dec.at source · line 2795 · raw

@+len:U32 -> @+i:U32 -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Dc)

def dec.if source · line 2799 · raw

@ok:Bool -> @a:Array<U32> -> @+len:U32 -> @+i:U32 -> Pair(Array<U32>, Dc)

def dec source · line 2807 · raw

@a:Array<U32> -> @+len:U32 -> @+i:U32 -> Pair(Array<U32>, Dc)

The char at byte i, or DEnd at len.

def probe.of source · line 2810 · raw

@+m:Asc -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Bool)

def probe.if source · line 2815 · raw

@ok:Bool -> @a:Array<U32> -> @+k:U32 -> @+m:Asc -> Pair(Array<U32>, Bool)

Past len counts as a hit, so a skip stops there.

def probe source · line 2822 · raw

@a:Array<U32> -> @+len:U32 -> @+k:U32 -> @+m:Asc -> Pair(Array<U32>, Bool)

def skip source · line 2826 · raw

@fuel:Nat -> @r:Pair(Array<U32>, Bool) -> @+len:U32 -> @+k:U32 -> @+m:Asc -> Pair(Array<U32>, U32)

The first offset at or after k whose byte may start a match, or len; r holds the probe of k.

def skip.from source · line 2839 · raw

@a:Array<U32> -> @+len:U32 -> @+k:U32 -> @+m:Asc -> Pair(Array<U32>, U32)

def rb.step source · line 2846 · raw

@r:Pair(Array<U32>, Dc) -> @+j:U32 -> @st:Vm -> @+c:U32 -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> Rb

def prev.byte source · line 2852 · raw

@r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Maybe<&2, Char>)

The char before byte k as an assertion reads it: None at 0, an ASCII byte as itself, and U+FFFD, which is no word char, for a byte of a wider char. k is on a char boundary.

def prev.if source · line 2856 · raw

@z:Bool -> @a:Array<U32> -> @+k:U32 -> Pair(Array<U32>, Maybe<&2, Char>)

def prev.at source · line 2863 · raw

@a:Array<U32> -> @+k:U32 -> Pair(Array<U32>, Maybe<&2, Char>)

def rb.seed.at source · line 2866 · raw

@r:Pair(Array<U32>, Maybe<&2, Char>) -> @+k:U32 -> @+d:Dc -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> Rb

def rb.seed source · line 2871 · raw

@r:Pair(Array<U32>, Dc) -> @+k:U32 -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> Rb

A fresh seed at k.

def rb.skip source · line 2875 · raw

@r:Pair(Array<U32>, U32) -> @+len:U32 -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> Rb

def rb.idle source · line 2883 · raw

@asc:Maybe<&2, Asc> -> @a:Array<U32> -> @+len:U32 -> @+j:U32 -> @+c:U32 -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> Rb

No thread is live and no match exists. With asc, the seed at the char before j was skipped because that char cannot start a match: jump to the next byte that may, and seed there with the byte before it as prev. Without asc, the seed died on an assertion, so step on as usual; prev matters then.

def runb source · line 2891 · raw

@fuel:Nat -> @r:Rb -> @+len:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+any:Bool -> Pair(Array<U32>, Maybe<&2, List<&2, Maybe<&2, U32>>>)

fuel: each step eats at least one byte, and the last one sees DEnd.

def sym.caps source · line 2922 · raw

@+slots:Nat -> @+i:U32 -> List<&2, Maybe<&2, U32>>

def sym.ths source · line 2925 · raw

@xs:List<&2, Th> -> @+slots:Nat -> @+i:U32 -> List<&2, Th>

def sym.src source · line 2933 · raw

@xs:List<&2, Maybe<&2, U32>> -> U32

The index in the last slot.

def sym.saves source · line 2943 · raw

@xs:List<&2, Maybe<&2, U32>> -> @+k:U32 -> List<&2, U32>

The slots before the last that hold a position.

def sym.outs source · line 2954 · raw

@xs:List<&2, Th> -> List<&2, Op>

def sym.fresh source · line 2961 · raw

@xs:List<&2, Op> -> Bool

def op.same source · line 2968 · raw

@saves:List<&2, U32> -> @+src:U32 -> @+pc:U32 -> @+i:U32 -> @+old:U32 -> Bool

def ops.same source · line 2975 · raw

@xs:List<&2, Op> -> @ths:List<&2, Th> -> @+i:U32 -> Bool

def tr.of source · line 2984 · raw

@same:Bool -> @+next:U32 -> @+hit:U32 -> @+outs:List<&2, Op> -> @+fresh:Bool -> Tr

def sym.lr source · line 2991 · raw

@+hit:U32 -> @+done:Bool -> @v:Vm -> Lr

def sym.hit source · line 2996 · raw

@stop:Bool -> @best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> U32

def sym.close source · line 3009 · raw

@sc:Sc -> @+done:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+slots:Nat -> @+c:U32 -> Lr

The closure after the char, inside the text: prev and next are any chars, and start is None so the seed always runs; replay.vm skips a fresh start the way seed.skip does.

def sym.best source · line 3014 · raw

@best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> Maybe<&2, List<&2, Maybe<&2, U32>>>

Once a match is found no seed starts, so a done state scans with some best.

def learn source · line 3021 · raw

@st:Vm -> @+c:U32 -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+slots:Nat -> @+any:Bool -> Lr

def caps.at source · line 3025 · raw

@m:Maybe<&2, Th> -> @+init:List<&2, Maybe<&2, U32>> -> List<&2, Maybe<&2, U32>>

def caps.of.if source · line 3032 · raw

@seed:Bool -> @+src:U32 -> @+ths:List<&2, Th> -> @+init:List<&2, Maybe<&2, U32>> -> List<&2, Maybe<&2, U32>>

def caps.of source · line 3039 · raw

@+src:U32 -> @+ths:List<&2, Th> -> @+init:List<&2, Maybe<&2, U32>> -> List<&2, Maybe<&2, U32>>

def saves.put source · line 3042 · raw

@xs:List<&2, U32> -> @caps:List<&2, Maybe<&2, U32>> -> @+pos:U32 -> List<&2, Maybe<&2, U32>>

def replay source · line 3049 · raw

@xs:List<&2, Op> -> @+ths:List<&2, Th> -> @+init:List<&2, Maybe<&2, U32>> -> @+pos:U32 -> List<&2, Th>

def replay.best source · line 3056 · raw

@none:Bool -> @+hit:U32 -> @+ths:List<&2, Th> -> @+init:List<&2, Maybe<&2, U32>> -> @best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> Maybe<&2, List<&2, Maybe<&2, U32>>>

def replay.fresh source · line 3064 · raw

@skip:Bool -> @outs:List<&2, Op> -> @+ths:List<&2, Th> -> @+init:List<&2, Maybe<&2, U32>> -> @+pos:U32 -> Vm

fresh: no match yet and every thread starts at the seed; skip it when next cannot start a match.

def replay.vm source · line 3072 · raw

@fresh:Bool -> @+hit:U32 -> @outs:List<&2, Op> -> @st:Vm -> @+init:List<&2, Maybe<&2, U32>> -> @+pos:U32 -> @+start:Maybe<&2, List<&2, Inst>> -> @+next:Maybe<&2, Char> -> Vm

A learned transition on the real threads; next is the char after the new position.

def rq.ik source · line 3086 · raw

@ik:Ik -> @a:Array<U32> -> @tab:Array<Tr> -> @+j:U32 -> @+d:Dc -> @st:Vm -> Rq

def rq.of source · line 3090 · raw

@r:Rb -> @tab:Array<Tr> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+cap:U32 -> Rq

def rq.store source · line 3094 · raw

@ik:Ik -> @a:Array<U32> -> @tab:Array<Tr> -> @+idx:U32 -> @+old:U32 -> @+hit:U32 -> @+outs:List<&2, Op> -> @+fresh:Bool -> @+j:U32 -> @+d:Dc -> @st:Vm -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> Rq

def rq.learn source · line 3100 · raw

@lr:Lr -> @a:Array<U32> -> @tab:Array<Tr> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+idx:U32 -> @+old:U32 -> @+j:U32 -> @+d:Dc -> @st:Vm -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+cap:U32 -> Rq

def rq.real source · line 3105 · raw

@room:Bool -> @a:Array<U32> -> @tab:Array<Tr> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+j:U32 -> @+d:Dc -> @+st:Vm -> @+cap:U32 -> Rq

With a full cache, skip building the key too.

def spin.byte source · line 3120 · raw

@last:Bool -> @a:Array<U32> -> @+i:U32 -> Pair(Array<U32>, U32)

def spin.tr source · line 3127 · raw

@ascii:Bool -> @tab:Array<Tr> -> @+id:U32 -> @+c:U32 -> Pair(Array<Tr>, Tr)

def spin.state.tr source · line 3134 · raw

@r:Pair(Array<Tr>, Tr) -> @a:Array<U32> -> @+i:U32 -> SpinStep

def spin.state source · line 3138 · raw

@r:Pair(Array<U32>, U32) -> @tab:Array<Tr> -> @+i:U32 -> @+id:U32 -> @+cap:U32 -> SpinStep

def spin source · line 3142 · raw

@fuel:Nat -> @s:SpinStep -> @+len:U32 -> @+id:U32 -> @+cap:U32 -> Spin

def ar.fill source · line 3162 · raw

@xs:List<&2, Th> -> @a:Array<Th> -> @+i:U32 -> Array<Th>

def ar.reset.size source · line 3169 · raw

@fits:Bool -> @ths:List<&2, Th> -> @best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> @old:Array<Th> -> @spare:Array<Th> -> @+count:U32 -> @+cap:U32 -> @+init:List<&2, Maybe<&2, U32>> -> Ar

def ar.reset.put source · line 3177 · raw

@vm:Vm -> @old:Array<Th> -> @spare:Array<Th> -> @+cap:U32 -> @+init:List<&2, Maybe<&2, U32>> -> Ar

def ar.reset source · line 3182 · raw

@vm:Vm -> @ar:Ar -> @+init:List<&2, Maybe<&2, U32>> -> Ar

def ar.new source · line 3186 · raw

@vm:Vm -> @+init:List<&2, Maybe<&2, U32>> -> Ar

def ar.list.go source · line 3189 · raw

@fuel:Nat -> @r:Pair(Array<Th>, Th) -> @+i:U32 -> @acc:List<&2, Th> -> Pair(Array<Th>, List<&2, Th>)

def ar.vm.put source · line 3198 · raw

@r:Pair(Array<Th>, List<&2, Th>) -> @spare:Array<Th> -> @+count:U32 -> @+cap:U32 -> @+best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> Pair(Ar, Vm)

def ar.vm source · line 3202 · raw

@ar:Ar -> Pair(Ar, Vm)

def ar.src.get source · line 3206 · raw

@r:Pair(Array<Th>, Th) -> Pair(Array<Th>, List<&2, Maybe<&2, U32>>)

def ar.src source · line 3210 · raw

@seed:Bool -> @old:Array<Th> -> @+src:U32 -> @+init:List<&2, Maybe<&2, U32>> -> Pair(Array<Th>, List<&2, Maybe<&2, U32>>)

def ar.put source · line 3217 · raw

@r:Pair(Array<Th>, List<&2, Maybe<&2, U32>>) -> @spare:Array<Th> -> @+pc:U32 -> @saves:List<&2, U32> -> @+pos:U32 -> @+i:U32 -> Pair(Array<Th>, Array<Th>)

def ar.replay source · line 3221 · raw

@xs:List<&2, Op> -> @r:Pair(Array<Th>, Array<Th>) -> @+init:List<&2, Maybe<&2, U32>> -> @+pos:U32 -> @+i:U32 -> @+cap:U32 -> @best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> Ar

def ar.best.get source · line 3230 · raw

@r:Pair(Array<Th>, List<&2, Maybe<&2, U32>>) -> Pair(Array<Th>, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def ar.best.none source · line 3234 · raw

@no_hit:Bool -> @old:Array<Th> -> @+hit:U32 -> @+init:List<&2, Maybe<&2, U32>> -> @best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> Pair(Array<Th>, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def ar.replay.best source · line 3241 · raw

@r:Pair(Array<Th>, Maybe<&2, List<&2, Maybe<&2, U32>>>) -> @spare:Array<Th> -> @outs:List<&2, Op> -> @+cap:U32 -> @+init:List<&2, Maybe<&2, U32>> -> @+pos:U32 -> Ar

def ar.cached.fresh source · line 3245 · raw

@skip:Bool -> @ar:Ar -> @outs:List<&2, Op> -> @+init:List<&2, Maybe<&2, U32>> -> @+pos:U32 -> Ar

def ar.cached source · line 3255 · raw

@fresh:Bool -> @+hit:U32 -> @outs:List<&2, Op> -> @ar:Ar -> @+init:List<&2, Maybe<&2, U32>> -> @+pos:U32 -> @+start:Maybe<&2, List<&2, Inst>> -> @+next:Maybe<&2, Char> -> Ar

A cached transition was learned in this run, so the buffers already fit its outputs.

def qa.status.if source · line 3269 · raw

@zero:Bool -> @old:Array<Th> -> @spare:Array<Th> -> @+count:U32 -> @+cap:U32 -> @best:Maybe<&2, List<&2, Maybe<&2, U32>>> -> Qst

def qa.status source · line 3280 · raw

@ar:Ar -> Qst

def qa.seed source · line 3287 · raw

@r:Rq -> @+init:List<&2, Maybe<&2, U32>> -> Qa

def qa.from.state source · line 3291 · raw

@cached:Bool -> @st:Vm -> @ar:Ar -> @+init:List<&2, Maybe<&2, U32>> -> Qst

def qa.from source · line 3298 · raw

@r:Rq -> @ar:Ar -> @+init:List<&2, Maybe<&2, U32>> -> @+cap:U32 -> Qa

def qa.learn.vm source · line 3302 · raw

@r:Pair(Ar, Vm) -> @a:Array<U32> -> @tab:Array<Tr> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+idx:U32 -> @+j:U32 -> @+d:Dc -> @+c:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> @+cap:U32 -> Qa

def qa.real.vm source · line 3306 · raw

@r:Pair(Ar, Vm) -> @s:Pair(Array<U32>, Dc) -> @+j:U32 -> @tab:Array<Tr> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+c:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+cap:U32 -> Qa

def qa.real source · line 3311 · raw

@s:Pair(Array<U32>, Dc) -> @+j:U32 -> @tab:Array<Tr> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @ar:Ar -> @+c:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+cap:U32 -> Qa

def qa.cached source · line 3314 · raw

@r:Pair(Array<Tr>, Tr) -> @a:Array<U32> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+idx:U32 -> @+j:U32 -> @+d:Dc -> @ar:Ar -> @+c:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> @+cap:U32 -> Qa

def qa.pick source · line 3324 · raw

@ok:Bool -> @a:Array<U32> -> @tab:Array<Tr> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+id:U32 -> @+j:U32 -> @+d:Dc -> @ar:Ar -> @+c:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> @+cap:U32 -> Qa

def qa.step source · line 3332 · raw

@s:Pair(Array<U32>, Dc) -> @+j:U32 -> @tab:Array<Tr> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+id:U32 -> @ar:Ar -> @+c:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> @+cap:U32 -> Qa

def qa.spin.read source · line 3336 · raw

@s:Pair(Array<U32>, Dc) -> @tab:Array<Tr> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+id:U32 -> @+i:U32 -> @ar:Qst -> Qa

def qa.spin.dec source · line 3340 · raw

@moved:Bool -> @a:Array<U32> -> @tab:Array<Tr> -> @+len:U32 -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+id:U32 -> @+i:U32 -> @d:Dc -> @ar:Qst -> Qa

def qa.spin.at source · line 3347 · raw

@s:Spin -> @+old:U32 -> @+len:U32 -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+id:U32 -> @d:Dc -> @ar:Qst -> Qa

def qa.spin.if source · line 3351 · raw

@same:Bool -> @a:Array<U32> -> @tab:Array<Tr> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+id:U32 -> @+i:U32 -> @d:Dc -> @ar:Qst -> @+fuel:Nat -> @+len:U32 -> @+cap:U32 -> Qa

def qa.spin source · line 3358 · raw

@r:Qa -> @+fuel:Nat -> @+len:U32 -> @+cap:U32 -> Qa

def qa.end.vm source · line 3362 · raw

@st:Vm -> @a:Array<U32> -> @+prog:Trie<Inst> -> @+any:Bool -> Pair(Array<U32>, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def qa.end source · line 3366 · raw

@r:Pair(Ar, Vm) -> @a:Array<U32> -> @+prog:Trie<Inst> -> @+any:Bool -> Pair(Array<U32>, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def qa.end.status source · line 3370 · raw

@st:Qst -> @a:Array<U32> -> @+prog:Trie<Inst> -> @+any:Bool -> Pair(Array<U32>, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def runqa source · line 3382 · raw

@+fuel:Nat -> @r:Qa -> @+len:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+any:Bool -> @+slots:Nat -> @+cap:U32 -> Pair(Array<U32>, Maybe<&2, List<&2, Maybe<&2, U32>>>)

Each step consumes a byte; after the cache fills, continue in the plain Pike VM.

def exec.bytes.fin source · line 3404 · raw

@+len:U32 -> @r:Pair(Array<U32>, Maybe<&2, List<&2, Maybe<&2, U32>>>) -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def exec.bytes.go.if source · line 3409 · raw

@use:Bool -> @+len:U32 -> @+from:U32 -> @buf:Array<U32> -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+any:Bool -> @+slots:Nat -> Pair(Array<U32>, Maybe<&2, List<&2, Maybe<&2, U32>>>)

Short large programs use the plain VM; long large programs can use 2048 states.

def exec.bytes.go source · line 3419 · raw

@plain:Bool -> @+len:U32 -> @+from:U32 -> @buf:Array<U32> -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+any:Bool -> @+slots:Nat -> Pair(Array<U32>, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def dc.c source · line 3424 · raw

@d:Dc -> U32

The DFA over Bytes -------------------

def dc.w source · line 3431 · raw

@d:Dc -> U32

def dc.pack source · line 3439 · raw

@d:Dc -> U32

A decoded char packed in one word: its width above bit 24, its code point below; 0 at the end.

def dec.pack.of source · line 3446 · raw

@r:Pair(Array<U32>, Dc) -> Pair(Array<U32>, U32)

def dec.pack source · line 3450 · raw

@a:Array<U32> -> @+len:U32 -> @+i:U32 -> Pair(Array<U32>, U32)

def skip.wide source · line 3456 · raw

@fuel:Nat -> @+ph:U32 -> @r:Pair(Array<U32>, U32) -> @+len:U32 -> @+k:U32 -> @+m:Asc -> @+sets:List<&2, Inst> -> Pair(Array<U32>, U32)

Skip from k to the next char that may start a match: ASCII bytes by the table m, wide chars by the sets of lead. ph: 1 r holds the table skip's offset, so decode the char there; 0 r holds the char at k, packed; 2 r holds the answer. fuel: every two rounds pass at least one byte.

def dfa.mode source · line 3483 · raw

@+id:U32 -> @+i:U32 -> @+len:U32 -> @+sk:Bool -> @+ready:Db -> Db

The round after a step to state id, the next char at i: DbFull when the cache is full, DbEnd at the end of the text, DbSkip in an idle state that skips, else ready (DbRead when the next read is primed, else DbPrime).

def dfab.end source · line 3491 · raw

@r:Pair(Array<Sk>, Sk) -> @a:Array<U32> -> @+p:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> Pair(Array<U32>, Dr)

def dfab.learn source · line 3503 · raw

@rd:Pair(Array<U32>, Dc) -> @r:Pair(Array<Sk>, Sk) -> @tab:Array<U32> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+id:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+wb:Bool -> @+cap:U32 -> Dlb

def dfab source · line 3525 · raw

@fuel:Nat -> @+mode:Db -> @z:Dzb -> @ra:Pair(Array<U32>, U32) -> @rt:Pair(Array<U32>, U32) -> @sts:Array<Sk> -> @+keys:Trie<List<&2, Ix>> -> @+n:U32 -> @+len:U32 -> @+i:U32 -> @+id:U32 -> @+p:U32 -> @+b:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+wb:Bool -> @+am:Asc -> @+sets:List<&2, Inst> -> @+sk:Bool -> @+cap:U32 -> Pair(Array<U32>, Dr)

The DFA over the bytes of a, up to len; mode picks the round. A read hands back the array beside the value, and a round may not take apart a computed value, so each round passes its reads to the next: ra the buffer and, in DbRead, the byte after b; rt the table and, in DbRead, its entry for id and b. p: the last idle point. fuel: each byte takes at most six rounds. Each value the next round takes is bound first, so no round delays work into it.

def dfab.init source · line 3620 · raw

@r:Pair(Array<U32>, U32) -> @+len:U32 -> @+from:U32 -> @+prog:Trie<Inst> -> @+cfuel:Nat -> @+wb:Bool -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> Pair(Array<U32>, Dr)

The DFA from byte from: the state there is idle, of the kind of the byte before.

def exec.bytes.hit source · line 3628 · raw

@any:Bool -> @a:Array<U32> -> @+len:U32 -> @+p:U32 -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+slots:Nat -> Pair(Array<U32>, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def exec.bytes.dr source · line 3636 · raw

@r:Pair(Array<U32>, Dr) -> @+len:U32 -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+any:Bool -> @+slots:Nat -> Pair(Array<U32>, Maybe<&2, List<&2, Maybe<&2, U32>>>)

After the DFA: with any, a match found is the answer; else the Pike VM runs from the idle point.

def exec.bytes.from source · line 3647 · raw

@b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+k:U32 -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

The DFA, then the Pike VM, from byte k, a char boundary: no match starts before k.

def exec.bytes.run source · line 3651 · raw

@b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def blit.go source · line 3658 · raw

@l:List<&2, List<&2, U32>> -> @ok:Bool -> @r:Pair(Array<U32>, U32) -> @+len:U32 -> @+k:U32 -> Pair(Array<U32>, Bool)

Whether the bytes from k spell the literal l; ok: whether those before k did; r: byte k.

def banc.at source · line 3673 · raw

@fits:Bool -> @l:List<&2, List<&2, U32>> -> @a:Array<U32> -> @+len:U32 -> @+j:U32 -> Pair(Array<U32>, Bool)

Whether the literal l starts at byte j, when it fits before the anchor place.

def blits.step source · line 3680 · raw

@ok:Bool -> @x:Anc -> @a:Array<U32> -> @+len:U32 -> @+k:U32 -> Pair(Array<U32>, Bool)

def blits.go source · line 3689 · raw

@xs:List<&2, Anc> -> @r:Pair(Array<U32>, Bool) -> @+len:U32 -> @+k:U32 -> Pair(Array<U32>, Bool)

Whether a literal of xs has its anchor at byte k; r holds whether one already did.

def blits.u source · line 3697 · raw

@r:Pair(Array<U32>, Bool) -> Pair(Array<U32>, U32)

def swar.has source · line 3703 · raw

@xs:List<&2, U32> -> @+w:U32 -> @+acc:U32 -> U32

The top bit of each byte of w that equals a byte of xs is set in the result. A false mark can follow a true one in the same word, never stand alone.

def wprobe.of source · line 3711 · raw

@+first:List<&2, U32> -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, Bool)

def wprobe.if source · line 3716 · raw

@ok:Bool -> @a:Array<U32> -> @+wi:U32 -> @+first:List<&2, U32> -> Pair(Array<U32>, Bool)

Whether word wi has a byte in first; past nw counts as one, so a skip stops there.

def wprobe source · line 3723 · raw

@a:Array<U32> -> @+wi:U32 -> @+nw:U32 -> @+first:List<&2, U32> -> Pair(Array<U32>, Bool)

def wskip source · line 3727 · raw

@fuel:Nat -> @r:Pair(Array<U32>, Bool) -> @+wi:U32 -> @+nw:U32 -> @+first:List<&2, U32> -> Pair(Array<U32>, U32)

The first word at or after wi with a byte in first, or nw; r holds the probe of wi.

def bfind source · line 3745 · raw

@fuel:Nat -> @+ph:U32 -> @r:Pair(Array<U32>, U32) -> @+len:U32 -> @+wi:U32 -> @+j:U32 -> @+m:U32 -> @+first:List<&2, U32> -> @+ls:List<&2, Anc> -> @+nw:U32 -> Pair(Array<U32>, Maybe<&2, U32>)

The first byte offset that is the anchor place of a literal of ls, a word of four bytes at a time; first: the anchors' bytes. ph: 0 skip the words from wi with no byte in first; 3 take the word found, in r; 4 mark the bytes of word wi, in r, that are in first; 1 test the literals around byte j of word wi when m marks it; 2 take that test, in r; 5 found at byte j of word wi; 6 none. nw: the number of words. fuel: each word with a marked byte takes at most twelve rounds.

def bfind.start source · line 3784 · raw

@a:Array<U32> -> @+len:U32 -> @+xs:List<&2, Anc> -> Pair(Array<U32>, Maybe<&2, U32>)

def bk.pick source · line 3790 · raw

@+k:U32 -> @+b0:U32 -> @+b1:U32 -> @+b2:U32 -> @+b3:U32 -> U32

The last char boundary at or before k, from the bytes k, k-1, k-2, k-3: a byte that is no continuation byte starts a char, and no char spans more than four bytes.

def bk.a3 source · line 3793 · raw

@+len:U32 -> @+k:U32 -> @+b0:U32 -> @+b1:U32 -> @+b2:U32 -> @r:Pair(Array<U32>, U32) -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>)

def bk.a2 source · line 3797 · raw

@+len:U32 -> @+k:U32 -> @+b0:U32 -> @+b1:U32 -> @r:Pair(Array<U32>, U32) -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>)

def bk.a1 source · line 3801 · raw

@+len:U32 -> @+k:U32 -> @+b0:U32 -> @r:Pair(Array<U32>, U32) -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>)

def bk.a0 source · line 3805 · raw

@+len:U32 -> @+k:U32 -> @r:Pair(Array<U32>, U32) -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>)

def need.fromb.k source · line 3809 · raw

@m:Maybe<&2, U32> -> @a:Array<U32> -> @+len:U32 -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>)

def need.fromb source · line 3816 · raw

@r:Pair(Array<U32>, Maybe<&2, U32>) -> @far:Maybe<&2, U32> -> @+len:U32 -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>)

def need.atb source · line 3822 · raw

@m:Maybe<&2, Need> -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>)

The first byte a match may start at, a char boundary, or None when b has no match: the first anchor place where a literal holds, less big and far.

def rev.best source · line 3832 · raw

@hit:Bool -> @+i:U32 -> @prev:Maybe<&2, U32> -> Maybe<&2, U32>

def rev.bits.after source · line 3846 · raw

@step:Bs -> @a:Array<U32> -> @best:Maybe<&2, U32> -> @+i:U32 -> RevBits

def rev.bits.char source · line 3850 · raw

@valid:Bool -> @a:Array<U32> -> @+mask:U32 -> @best:Maybe<&2, U32> -> @+c:U32 -> @+i:U32 -> @+sets:List<&2, Bit> -> RevBits

def rev.bits.read source · line 3857 · raw

@r:Pair(Array<U32>, U32) -> @+mask:U32 -> @best:Maybe<&2, U32> -> @+i:U32 -> @+sets:List<&2, Bit> -> RevBits

def rev.bits.walk source · line 3861 · raw

@fuel:Nat -> @r:RevBits -> @+i:U32 -> @+sets:List<&2, Bit> -> RevBits

def rev.bits.result source · line 3873 · raw

@done:Bool -> @r:RevBits -> Rv

def rev.bits.run source · line 3877 · raw

@a:Array<U32> -> @+end:U32 -> @bits:Bits -> Rv

def rev.min source · line 3890 · raw

@m:Maybe<&2, U32> -> @prev:Maybe<&2, U32> -> Maybe<&2, U32>

def rev.seek source · line 3901 · raw

@r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>) -> @best:Maybe<&2, U32> -> RevPhase

def rev.abort source · line 3905 · raw

@r:RevPhase -> RevFound

def rev.candidates source · line 3912 · raw

@fuel:Nat -> @r:RevPhase -> @+needle:String -> @+bits:Bits -> RevFound

def exec.bytes.at source · line 3932 · raw

@b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+k:U32 -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def rev.confirm.best source · line 3936 · raw

@best:Maybe<&2, U32> -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def rev.confirm source · line 3944 · raw

@r:RevFound -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def exec.bytes.candidate source · line 3952 · raw

@r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>) -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def exec.bytes.reverse source · line 3960 · raw

@r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>) -> @bits:Bits -> @+needle:String -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def exec.bytes.select source · line 3964 · raw

@rev:Maybe<&2, Bits> -> @r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>) -> @+needle:String -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def exec.bytes.must.hit source · line 3972 · raw

@b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @rev:Maybe<&2, Bits> -> @+c:U32 -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def exec.bytes.must source · line 3976 · raw

@m:Maybe<&2, U32> -> @rev:Maybe<&2, Bits> -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def exec.bytes.zero source · line 3984 · raw

@zero:Bool -> @+k:U32 -> @m:Maybe<&2, U32> -> @rev:Maybe<&2, Bits> -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

From byte 0 the required byte and the reverse scan apply as before; past it the DFA starts there.

def exec.bytes.pick source · line 3991 · raw

@k:Maybe<&2, U32> -> @m:Maybe<&2, U32> -> @rev:Maybe<&2, Bits> -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def exec.bytes.need source · line 3998 · raw

@r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>) -> @m:Maybe<&2, U32> -> @rev:Maybe<&2, Bits> -> @+plain:Bool -> @+prog:Trie<Inst> -> @+fuel:Nat -> @+init:List<&2, Maybe<&2, U32>> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+lead:Maybe<&2, List<&2, Inst>> -> @+any:Bool -> @+slots:Nat -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

def exec.bytes source · line 4003 · raw

@re:Regex -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+any:Bool -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>)

A buffer without a required literal has no match, and no automaton runs.

def find.bytes.fin source · line 4008 · raw

@r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>) -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, Span>>>)

def find.bytes source · line 4013 · raw

@re:Regex -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, Span>>>)

find over UTF-8 bytes: the buffer back, and spans as byte offsets.

def is_match.bytes.fin source · line 4016 · raw

@r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, List<&2, Maybe<&2, U32>>>) -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Bool)

def is_match.bytes.vm source · line 4020 · raw

@re:Regex -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Bool)

def rt.at source · line 4027 · raw

@r:Pair(Array<U32>, Dc) -> @+j:U32 -> @st:Bs -> Rt

def rt.skip source · line 4031 · raw

@r:Pair(Array<U32>, U32) -> @+len:U32 -> @+atn:U32 -> @+hit1:Bool -> Rt

def rt.next source · line 4036 · raw

@idle:Bool -> @asc:Maybe<&2, Asc> -> @a:Array<U32> -> @+len:U32 -> @+j:U32 -> @+sets:List<&2, Bit> -> @+atn:U32 -> @+hit1:Bool -> @+cur:U32 -> @+c:U32 -> Rt

idle: only the sets live at a fresh start wait on c, and c starts none of them.

def bitsb source · line 4047 · raw

@fuel:Nat -> @r:Rt -> @+len:U32 -> @+sets:List<&2, Bit> -> @+start:Maybe<&2, List<&2, Inst>> -> @+asc:Maybe<&2, Asc> -> @+atn:U32 -> @+hit1:Bool -> Pair(Array<U32>, Bool)

def bits.bytes.fin source · line 4065 · raw

@+len:U32 -> @r:Pair(Array<U32>, Bool) -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, Bool>)

def bits.bytes source · line 4070 · raw

@b:Bits -> @start:Maybe<&2, List<&2, Inst>> -> @asc:Maybe<&2, Asc> -> @+len:U32 -> @buf:Array<U32> -> @+k:U32 -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, Bool>)

From byte k, a char boundary, as bits.is_match from a position.

def bits.bytes.k source · line 4075 · raw

@m:Maybe<&2, U32> -> @x:Bits -> @start:Maybe<&2, List<&2, Inst>> -> @asc:Maybe<&2, Asc> -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, Bool>)

def bits.bytes.at source · line 4083 · raw

@r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>) -> @x:Bits -> @start:Maybe<&2, List<&2, Inst>> -> @asc:Maybe<&2, Asc> -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, Bool>)

def bits.bytes.if source · line 4087 · raw

@m:Maybe<&2, Bits> -> @need:Maybe<&2, Need> -> @start:Maybe<&2, List<&2, Inst>> -> @asc:Maybe<&2, Asc> -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, Bool>)

def is_match.bytes.bits source · line 4095 · raw

@re:Regex -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, Bool>)

The bit NFA form of is_match over Bytes, or None when the program does not allow it.

def is_match.bytes.pick source · line 4099 · raw

@r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, Bool>) -> @re:Regex -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Bool)

def is_match.bytes source · line 4108 · raw

@+re:Regex -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Bool)

is_match over UTF-8 bytes: the buffer back, and whether it has a match.