3 # File has two sections, divided by a line of dashes '-'.
5 # Empty rows after #-comment are removed from input are ignored
7 # First section is for regops, second section is for regmatch-states
9 # Note that the order in this file is important.
11 # Format for first section:
12 # NAME \s+ TYPE, arg-description [num-args] [flags] [longjump-len] ; DESCRIPTION
13 # flag <S> means is REGNODE_SIMPLE; flag <V> means is REGNODE_VARIES
16 # run perl regen.pl after editing this file
17 # Also update perlredebguts.pod
23 END END, no ; End of program.
24 SUCCEED END, no ; Return from a subroutine, basically.
28 BOL BOL, no ; Match "" at beginning of line.
29 MBOL BOL, no ; Same, assuming multiline.
30 SBOL BOL, no ; Same, assuming singleline.
31 EOS EOL, no ; Match "" at end of string.
32 EOL EOL, no ; Match "" at end of line.
33 MEOL EOL, no ; Same, assuming multiline.
34 SEOL EOL, no ; Same, assuming singleline.
35 # The regops that have varieties that vary depending on the character set regex
36 # modifiers have to ordered thusly: /d, /l, /u, /a, /aa. This is because code
37 # in regcomp.c uses the enum value of the modifier as an offset from the /d
38 # version. The complements must come after the non-complements.
39 # BOUND, ALNUM, SPACE, DIGIT, and their complements are affected, as well as
41 BOUND BOUND, no ; Match "" at any word boundary using native charset semantics for non-utf8
42 BOUNDL BOUND, no ; Match "" at any locale word boundary
43 BOUNDU BOUND, no ; Match "" at any word boundary using Unicode semantics
44 BOUNDA BOUND, no ; Match "" at any word boundary using ASCII semantics
45 # All NBOUND nodes are required by code in regexec.c to be greater than all BOUND ones
46 NBOUND NBOUND, no ; Match "" at any word non-boundary using native charset semantics for non-utf8
47 NBOUNDL NBOUND, no ; Match "" at any locale word non-boundary
48 NBOUNDU NBOUND, no ; Match "" at any word non-boundary using Unicode semantics
49 NBOUNDA NBOUND, no ; Match "" at any word non-boundary using ASCII semantics
50 GPOS GPOS, no ; Matches where last m//g left off.
52 #* [Special] alternatives:
54 REG_ANY REG_ANY, no 0 S ; Match any one character (except newline).
55 SANY REG_ANY, no 0 S ; Match any one character.
56 CANY REG_ANY, no 0 S ; Match any one byte.
57 ANYOF ANYOF, sv 0 S ; Match character in (or not in) this class, single char match only
58 ANYOFV ANYOF, sv 0 V ; Match character in (or not in) this class, can match-multiple chars
60 # Order (within each group) of the below is important. See ordering comment
61 # above. The PLACEHOLDERn ones are wasting a value. Right now, we have plenty
62 # to spare, but these would be obvious candidates if ever we ran out of node
64 ALNUM ALNUM, no 0 S ; Match any alphanumeric character using native charset semantics for non-utf8
65 ALNUML ALNUM, no 0 S ; Match any alphanumeric char in locale
66 ALNUMU ALNUM, no 0 S ; Match any alphanumeric char using Unicode semantics
67 ALNUMA ALNUM, no 0 S ; Match [A-Za-z_0-9]
68 NALNUM NALNUM, no 0 S ; Match any non-alphanumeric character using native charset semantics for non-utf8
69 NALNUML NALNUM, no 0 S ; Match any non-alphanumeric char in locale
70 NALNUMU NALNUM, no 0 S ; Match any non-alphanumeric char using Unicode semantics
71 NALNUMA NALNUM, no 0 S ; Match [^A-Za-z_0-9]
72 SPACE SPACE, no 0 S ; Match any whitespace character using native charset semantics for non-utf8
73 SPACEL SPACE, no 0 S ; Match any whitespace char in locale
74 SPACEU SPACE, no 0 S ; Match any whitespace char using Unicode semantics
75 SPACEA SPACE, no 0 S ; Match [ \t\n\f\r]
76 NSPACE NSPACE, no 0 S ; Match any non-whitespace character using native charset semantics for non-utf8
77 NSPACEL NSPACE, no 0 S ; Match any non-whitespace char in locale
78 NSPACEU NSPACE, no 0 S ; Match any non-whitespace char using Unicode semantics
79 NSPACEA NSPACE, no 0 S ; Match [^ \t\n\f\r]
80 DIGIT DIGIT, no 0 S ; Match any numeric character using native charset semantics for non-utf8
81 DIGITL DIGIT, no 0 S ; Match any numeric character in locale
82 PLACEHOLDER1 NOTHING, no ; placeholder for missing DIGITU
83 DIGITA DIGIT, no 0 S ; Match [0-9]
84 NDIGIT NDIGIT, no 0 S ; Match any non-numeric character using native charset semantics for non-utf8
85 NDIGITL NDIGIT, no 0 S ; Match any non-numeric character in locale
86 PLACEHOLDER2 NOTHING, no ; placeholder for missing NDIGITU
87 NDIGITA NDIGIT, no 0 S ; Match [^0-9]
88 # End of order is important (within groups)
90 CLUMP CLUMP, no 0 V ; Match any extended grapheme cluster sequence
94 # BRANCH The set of branches constituting a single choice are hooked
95 # together with their "next" pointers, since precedence prevents
96 # anything being concatenated to any individual branch. The
97 # "next" pointer of the last BRANCH in a choice points to the
98 # thing following the whole choice. This is also where the
99 # final "next" pointer of each individual branch points; each
100 # branch starts with the operand node of a BRANCH node.
102 BRANCH BRANCH, node 0 V ; Match this alternative, or the next...
106 # BACK Normal "next" pointers all implicitly point forward; BACK
107 # exists to make loop structures possible.
109 BACK BACK, no 0 V ; Match "", "next" ptr points backward.
111 #*Literals - NOTE the relative ordering of these types is important do not change it
113 EXACT EXACT, str ; Match this string (preceded by length).
114 EXACTF EXACT, str ; Match this non-UTF-8 string (not guaranteed to be folded) using /id rules (w/len).
115 EXACTFL EXACT, str ; Match this string (not guaranteed to be folded) using /il rules (w/len).
116 EXACTFU EXACT, str ; Match this string (folded iff in UTF-8, length in folding doesn't change if not in UTF-8) using /iu rules (w/len).
117 EXACTFA EXACT, str ; Match this string (not guaranteed to be folded) using /iaa rules (w/len).
118 EXACTFU_SS EXACT, str ; Match this string (folded iff in UTF-8, length in folding may change even if not in UTF-8) using /iu rules (w/len).
119 EXACTFU_TRICKYFOLD EXACT, str ; Match this folded UTF-8 string using /iu rules
123 NOTHING NOTHING, no ; Match empty string.
124 # A variant of above which delimits a group, thus stops optimizations
125 TAIL NOTHING, no ; Match empty string. Can jump here from outside.
129 # STAR,PLUS '?', and complex '*' and '+', are implemented as circular
130 # BRANCH structures using BACK. Simple cases (one character
131 # per match) are implemented with STAR and PLUS for speed
132 # and to minimize recursive plunges.
134 STAR STAR, node 0 V ; Match this (simple) thing 0 or more times.
135 PLUS PLUS, node 0 V ; Match this (simple) thing 1 or more times.
137 CURLY CURLY, sv 2 V ; Match this simple thing {n,m} times.
138 CURLYN CURLY, no 2 V ; Capture next-after-this simple thing
139 CURLYM CURLY, no 2 V ; Capture this medium-complex thing {n,m} times.
140 CURLYX CURLY, sv 2 V ; Match this complex thing {n,m} times.
142 # This terminator creates a loop structure for CURLYX
143 WHILEM WHILEM, no 0 V ; Do curly processing and see if rest matches.
147 # OPEN,CLOSE,GROUPP ...are numbered at compile time.
148 OPEN OPEN, num 1 ; Mark this point in input as start of #n.
149 CLOSE CLOSE, num 1 ; Analogous to OPEN.
151 REF REF, num 1 V ; Match some already matched string
152 REFF REF, num 1 V ; Match already matched string, folded using native charset semantics for non-utf8
153 REFFL REF, num 1 V ; Match already matched string, folded in loc.
154 # N?REFF[AU] could have been implemented using the FLAGS field of the
155 # regnode, but by having a separate node type, we can use the existing switch
156 # statement to avoid some tests
157 REFFU REF, num 1 V ; Match already matched string, folded using unicode semantics for non-utf8
158 REFFA REF, num 1 V ; Match already matched string, folded using unicode semantics for non-utf8, no mixing ASCII, non-ASCII
160 #*Named references. Code in regcomp.c assumes that these all are after the numbered references
161 NREF REF, no-sv 1 V ; Match some already matched string
162 NREFF REF, no-sv 1 V ; Match already matched string, folded using native charset semantics for non-utf8
163 NREFFL REF, no-sv 1 V ; Match already matched string, folded in loc.
164 NREFFU REF, num 1 V ; Match already matched string, folded using unicode semantics for non-utf8
165 NREFFA REF, num 1 V ; Match already matched string, folded using unicode semantics for non-utf8, no mixing ASCII, non-ASCII
167 IFMATCH BRANCHJ, off 1 . 2 ; Succeeds if the following matches.
168 UNLESSM BRANCHJ, off 1 . 2 ; Fails if the following matches.
169 SUSPEND BRANCHJ, off 1 V 1 ; "Independent" sub-RE.
170 IFTHEN BRANCHJ, off 1 V 1 ; Switch, should be preceded by switcher .
171 GROUPP GROUPP, num 1 ; Whether the group matched.
173 #*Support for long RE
175 LONGJMP LONGJMP, off 1 . 1 ; Jump far away.
176 BRANCHJ BRANCHJ, off 1 V 1 ; BRANCH with long offset.
180 EVAL EVAL, evl 1 ; Execute some Perl code.
184 MINMOD MINMOD, no ; Next operator is not greedy.
185 LOGICAL LOGICAL, no ; Next opcode should set the flag only.
187 # This is not used yet
188 RENUM BRANCHJ, off 1 . 1 ; Group with independently numbered parens.
192 # Behave the same as A|LIST|OF|WORDS would. The '..C' variants have
193 # inline charclass data (ascii only), the 'C' store it in the structure.
194 # NOTE: the relative order of the TRIE-like regops is significant
196 TRIE TRIE, trie 1 ; Match many EXACT(F[ALU]?)? at once. flags==type
197 TRIEC TRIE,trie charclass ; Same as TRIE, but with embedded charclass data
199 # For start classes, contains an added fail table.
200 AHOCORASICK TRIE, trie 1 ; Aho Corasick stclass. flags==type
201 AHOCORASICKC TRIE,trie charclass ; Same as AHOCORASICK, but with embedded charclass data
204 GOSUB GOSUB, num/ofs 2L ; recurse to paren arg1 at (signed) ofs arg2
205 GOSTART GOSTART, no ; recurse to start of pattern
207 #*Special conditionals
208 NGROUPP NGROUPP, no-sv 1 ; Whether the group matched.
209 INSUBP INSUBP, num 1 ; Whether we are in a specific recurse.
210 DEFINEP DEFINEP, none 1 ; Never execute directly.
213 ENDLIKE ENDLIKE, none ; Used only for the type field of verbs
214 OPFAIL ENDLIKE, none ; Same as (?!)
215 ACCEPT ENDLIKE, parno 1 ; Accepts the current matched string.
218 #*Verbs With Arguments
219 VERB VERB, no-sv 1 ; Used only for the type field of verbs
220 PRUNE VERB, no-sv 1 ; Pattern fails at this startpoint if no-backtracking through this
221 MARKPOINT VERB, no-sv 1 ; Push the current location for rollback by cut.
222 SKIP VERB, no-sv 1 ; On failure skip forward (to the mark) before retrying
223 COMMIT VERB, no-sv 1 ; Pattern fails outright if backtracking through this
224 CUTGROUP VERB, no-sv 1 ; On failure go to the next alternation in the group
226 #*Control what to keep in $&.
227 KEEPS KEEPS, no ; $& begins here.
229 #*New charclass like patterns
230 LNBREAK LNBREAK, none ; generic newline pattern
232 # regcomp.c expects the node number of the complement to be one greater than
234 VERTWS VERTWS, none 0 S ; vertical whitespace (Perl 6)
235 NVERTWS NVERTWS, none 0 S ; not vertical whitespace (Perl 6)
236 HORIZWS HORIZWS, none 0 S ; horizontal whitespace (Perl 6)
237 NHORIZWS NHORIZWS, none 0 S ; not horizontal whitespace (Perl 6)
240 # NEW STUFF SOMEWHERE ABOVE THIS LINE
242 ################################################################################
246 # This is not really a node, but an optimized away piece of a "long" node.
247 # To simplify debugging output, we mark it as if it were a node
248 OPTIMIZED NOTHING, off ; Placeholder for dump.
250 # Special opcode with the property that no opcode in a compiled program
251 # will ever be of this type. Thus it can be used as a flag value that
252 # no other opcode has been seen. END is used similarly, in that an END
253 # node cant be optimized. So END implies "unoptimizable" and PSEUDO mean
254 # "not seen anything to optimize yet".
255 PSEUDO PSEUDO, off ; Pseudo opcode for internal use.
257 -------------------------------------------------------------------------------
258 # Format for second section:
259 # REGOP \t typelist [ \t typelist] [# Comment]
264 # Anything below is a state
270 WHILEM A_pre,A_min,A_max,B_min,B_max:FAIL
274 CURLY B_min_known,B_min,B_max:FAIL