Commit | Line | Data |
---|---|---|
03363afd YO |
1 | # regcomp.sym |
2 | # | |
3 | # File has two sections, divided by a line of dashes '-'. | |
4 | # | |
5 | # Empty rows after #-comment are removed from input are ignored | |
6 | # | |
486ec47a | 7 | # First section is for regops, second section is for regmatch-states |
03363afd | 8 | # |
3dab1dad YO |
9 | # Note that the order in this file is important. |
10 | # | |
03363afd | 11 | # Format for first section: |
f9ef50a7 | 12 | # NAME \s+ TYPE, arg-description [flags] [num-args] [longjump-len] ; DESCRIPTION |
03363afd | 13 | # |
3dab1dad | 14 | # |
c476f425 | 15 | # run perl regen.pl after editing this file |
570aa4f2 | 16 | # Also update perlredebguts.pod |
3dab1dad | 17 | |
03363afd YO |
18 | |
19 | ||
381b57db | 20 | #* Exit points |
1de06328 | 21 | |
f8abb37e NC |
22 | END END, no ; End of program. |
23 | SUCCEED END, no ; Return from a subroutine, basically. | |
d09b2d29 | 24 | |
381b57db | 25 | #* Anchors: |
1de06328 | 26 | |
f8abb37e NC |
27 | BOL BOL, no ; Match "" at beginning of line. |
28 | MBOL BOL, no ; Same, assuming multiline. | |
29 | SBOL BOL, no ; Same, assuming singleline. | |
30 | EOS EOL, no ; Match "" at end of string. | |
31 | EOL EOL, no ; Match "" at end of line. | |
32 | MEOL EOL, no ; Same, assuming multiline. | |
33 | SEOL EOL, no ; Same, assuming singleline. | |
1e355c70 | 34 | BOUND BOUND, no ; Match "" at any word boundary using native charset semantics for non-utf8 |
f2284805 | 35 | BOUNDL BOUND, no ; Match "" at any locale word boundary |
1e355c70 | 36 | BOUNDU BOUND, no ; Match "" at any word boundary using Unicode semantics |
0c6e81eb | 37 | BOUNDA BOUND, no ; Match "" at any word boundary using ASCII semantics |
63ac0dad | 38 | # All NBOUND nodes are required by a line regexec.c to be greater than all BOUND ones |
1e355c70 | 39 | NBOUND NBOUND, no ; Match "" at any word non-boundary using native charset semantics for non-utf8 |
f2284805 | 40 | NBOUNDL NBOUND, no ; Match "" at any locale word non-boundary |
1e355c70 | 41 | NBOUNDU NBOUND, no ; Match "" at any word non-boundary using Unicode semantics |
0c6e81eb | 42 | NBOUNDA NBOUND, no ; Match "" at any word non-boundary using ASCII semantics |
f8abb37e | 43 | GPOS GPOS, no ; Matches where last m//g left off. |
d09b2d29 | 44 | |
381b57db | 45 | #* [Special] alternatives: |
1de06328 | 46 | |
f9ef50a7 NC |
47 | REG_ANY REG_ANY, no 0 S ; Match any one character (except newline). |
48 | SANY REG_ANY, no 0 S ; Match any one character. | |
49 | CANY REG_ANY, no 0 S ; Match any one byte. | |
0e019ad6 KW |
50 | ANYOF ANYOF, sv 0 S ; Match character in (or not in) this class, single char match only |
51 | ANYOFV ANYOF, sv 0 V ; Match character in (or not in) this class, can match-multiple chars | |
fdf48794 | 52 | ALNUM ALNUM, no 0 S ; Match any alphanumeric character using native charset semantics for non-utf8 |
f9ef50a7 | 53 | ALNUML ALNUM, no 0 S ; Match any alphanumeric char in locale |
fdf48794 | 54 | ALNUMU ALNUM, no 0 S ; Match any alphanumeric char using Unicode semantics |
0c6e81eb | 55 | ALNUMA ALNUM, no 0 S ; Match [A-Za-z_0-9] |
fdf48794 | 56 | NALNUM NALNUM, no 0 S ; Match any non-alphanumeric character using native charset semantics for non-utf8 |
f9ef50a7 | 57 | NALNUML NALNUM, no 0 S ; Match any non-alphanumeric char in locale |
fdf48794 | 58 | NALNUMU NALNUM, no 0 S ; Match any non-alphanumeric char using Unicode semantics |
0c6e81eb | 59 | NALNUMA NALNUM, no 0 S ; Match [^A-Za-z_0-9] |
fdf48794 | 60 | SPACE SPACE, no 0 S ; Match any whitespace character using native charset semantics for non-utf8 |
f9ef50a7 | 61 | SPACEL SPACE, no 0 S ; Match any whitespace char in locale |
fdf48794 | 62 | SPACEU SPACE, no 0 S ; Match any whitespace char using Unicode semantics |
0c6e81eb | 63 | SPACEA SPACE, no 0 S ; Match [ \t\n\f\r] |
fdf48794 | 64 | NSPACE NSPACE, no 0 S ; Match any non-whitespace character using native charset semantics for non-utf8 |
f9ef50a7 | 65 | NSPACEL NSPACE, no 0 S ; Match any non-whitespace char in locale |
fdf48794 | 66 | NSPACEU NSPACE, no 0 S ; Match any non-whitespace char using Unicode semantics |
0c6e81eb | 67 | NSPACEA NSPACE, no 0 S ; Match [^ \t\n\f\r] |
fdf48794 | 68 | DIGIT DIGIT, no 0 S ; Match any numeric character using native charset semantics for non-utf8 |
28b5d7bf | 69 | DIGITL DIGIT, no 0 S ; Match any numeric character in locale |
0c6e81eb | 70 | DIGITA DIGIT, no 0 S ; Match [0-9] |
fdf48794 | 71 | NDIGIT NDIGIT, no 0 S ; Match any non-numeric character using native charset semantics for non-utf8 |
28b5d7bf | 72 | NDIGITL NDIGIT, no 0 S ; Match any non-numeric character in locale |
0c6e81eb | 73 | NDIGITA NDIGIT, no 0 S ; Match [^0-9] |
2448cf39 | 74 | CLUMP CLUMP, no 0 V ; Match any extended grapheme cluster sequence |
d09b2d29 | 75 | |
381b57db | 76 | #* Alternation |
1de06328 | 77 | |
f8abb37e NC |
78 | # BRANCH The set of branches constituting a single choice are hooked |
79 | # together with their "next" pointers, since precedence prevents | |
80 | # anything being concatenated to any individual branch. The | |
81 | # "next" pointer of the last BRANCH in a choice points to the | |
82 | # thing following the whole choice. This is also where the | |
83 | # final "next" pointer of each individual branch points; each | |
84 | # branch starts with the operand node of a BRANCH node. | |
d09b2d29 | 85 | # |
f9ef50a7 | 86 | BRANCH BRANCH, node 0 V ; Match this alternative, or the next... |
d09b2d29 | 87 | |
381b57db | 88 | #*Back pointer |
1de06328 | 89 | |
f8abb37e NC |
90 | # BACK Normal "next" pointers all implicitly point forward; BACK |
91 | # exists to make loop structures possible. | |
d09b2d29 | 92 | # not used |
f9ef50a7 | 93 | BACK BACK, no 0 V ; Match "", "next" ptr points backward. |
d09b2d29 | 94 | |
381b57db | 95 | #*Literals |
1de06328 | 96 | |
f8abb37e | 97 | EXACT EXACT, str ; Match this string (preceded by length). |
2448cf39 | 98 | EXACTF EXACT, str ; Match this string, folded, native charset semantics for non-utf8 (prec. by length). |
f8abb37e | 99 | EXACTFL EXACT, str ; Match this string, folded in locale (w/len). |
01f98ec2 | 100 | EXACTFU EXACT, str ; Match this string, folded, Unicode semantics for non-utf8 (prec. by length). |
7986cb47 | 101 | EXACTFA EXACT, str ; Match this string, folded, Unicode semantics for non-utf8, but no ASCII-range character matches outside ASCII (prec. by length),. |
d09b2d29 | 102 | |
381b57db | 103 | #*Do nothing types |
1de06328 | 104 | |
f8abb37e | 105 | NOTHING NOTHING, no ; Match empty string. |
d09b2d29 | 106 | # A variant of above which delimits a group, thus stops optimizations |
f8abb37e | 107 | TAIL NOTHING, no ; Match empty string. Can jump here from outside. |
d09b2d29 | 108 | |
381b57db | 109 | #*Loops |
1de06328 | 110 | |
f8abb37e NC |
111 | # STAR,PLUS '?', and complex '*' and '+', are implemented as circular |
112 | # BRANCH structures using BACK. Simple cases (one character | |
113 | # per match) are implemented with STAR and PLUS for speed | |
114 | # and to minimize recursive plunges. | |
d09b2d29 | 115 | # |
f9ef50a7 NC |
116 | STAR STAR, node 0 V ; Match this (simple) thing 0 or more times. |
117 | PLUS PLUS, node 0 V ; Match this (simple) thing 1 or more times. | |
d09b2d29 | 118 | |
f9ef50a7 NC |
119 | CURLY CURLY, sv 2 V ; Match this simple thing {n,m} times. |
120 | CURLYN CURLY, no 2 V ; Capture next-after-this simple thing | |
121 | CURLYM CURLY, no 2 V ; Capture this medium-complex thing {n,m} times. | |
122 | CURLYX CURLY, sv 2 V ; Match this complex thing {n,m} times. | |
d09b2d29 IZ |
123 | |
124 | # This terminator creates a loop structure for CURLYX | |
f9ef50a7 | 125 | WHILEM WHILEM, no 0 V ; Do curly processing and see if rest matches. |
d09b2d29 | 126 | |
381b57db | 127 | #*Buffer related |
1de06328 | 128 | |
f8abb37e NC |
129 | # OPEN,CLOSE,GROUPP ...are numbered at compile time. |
130 | OPEN OPEN, num 1 ; Mark this point in input as start of #n. | |
131 | CLOSE CLOSE, num 1 ; Analogous to OPEN. | |
d09b2d29 | 132 | |
f9ef50a7 | 133 | REF REF, num 1 V ; Match some already matched string |
2448cf39 | 134 | REFF REF, num 1 V ; Match already matched string, folded using native charset semantics for non-utf8 |
f9ef50a7 | 135 | REFFL REF, num 1 V ; Match already matched string, folded in loc. |
781aab5c | 136 | # N?REFF[AU] could have been implemented using the FLAGS field of the |
01f98ec2 KW |
137 | # regnode, but by having a separate node type, we can use the existing switch |
138 | # statement to avoid some tests | |
139 | REFFU REF, num 1 V ; Match already matched string, folded using unicode semantics for non-utf8 | |
781aab5c | 140 | REFFA REF, num 1 V ; Match already matched string, folded using unicode semantics for non-utf8, no mixing ASCII, non-ASCII |
d09b2d29 | 141 | |
01f98ec2 KW |
142 | #*Named references. Code in regcomp.c assumes that these all are after the numbered references |
143 | NREF REF, no-sv 1 V ; Match some already matched string | |
144 | NREFF REF, no-sv 1 V ; Match already matched string, folded using native charset semantics for non-utf8 | |
145 | NREFFL REF, no-sv 1 V ; Match already matched string, folded in loc. | |
146 | NREFFU REF, num 1 V ; Match already matched string, folded using unicode semantics for non-utf8 | |
781aab5c | 147 | NREFFA REF, num 1 V ; Match already matched string, folded using unicode semantics for non-utf8, no mixing ASCII, non-ASCII |
1de06328 | 148 | |
f9ef50a7 NC |
149 | IFMATCH BRANCHJ, off 1 . 2 ; Succeeds if the following matches. |
150 | UNLESSM BRANCHJ, off 1 . 2 ; Fails if the following matches. | |
151 | SUSPEND BRANCHJ, off 1 V 1 ; "Independent" sub-RE. | |
486ec47a | 152 | IFTHEN BRANCHJ, off 1 V 1 ; Switch, should be preceded by switcher . |
f8abb37e | 153 | GROUPP GROUPP, num 1 ; Whether the group matched. |
d09b2d29 | 154 | |
381b57db | 155 | #*Support for long RE |
1de06328 | 156 | |
f9ef50a7 NC |
157 | LONGJMP LONGJMP, off 1 . 1 ; Jump far away. |
158 | BRANCHJ BRANCHJ, off 1 V 1 ; BRANCH with long offset. | |
d09b2d29 | 159 | |
381b57db | 160 | #*The heavy worker |
1de06328 | 161 | |
f8abb37e | 162 | EVAL EVAL, evl 1 ; Execute some Perl code. |
d09b2d29 | 163 | |
381b57db | 164 | #*Modifiers |
1de06328 | 165 | |
f8abb37e NC |
166 | MINMOD MINMOD, no ; Next operator is not greedy. |
167 | LOGICAL LOGICAL, no ; Next opcode should set the flag only. | |
d09b2d29 | 168 | |
381b57db | 169 | # This is not used yet |
f9ef50a7 | 170 | RENUM BRANCHJ, off 1 . 1 ; Group with independently numbered parens. |
d09b2d29 | 171 | |
381b57db | 172 | #*Trie Related |
1de06328 YO |
173 | |
174 | # Behave the same as A|LIST|OF|WORDS would. The '..C' variants have | |
175 | # inline charclass data (ascii only), the 'C' store it in the structure. | |
486ec47a | 176 | # NOTE: the relative order of the TRIE-like regops is significant |
ce5e9471 | 177 | |
7986cb47 | 178 | TRIE TRIE, trie 1 ; Match many EXACT(F[ALU]?)? at once. flags==type |
f8abb37e | 179 | TRIEC TRIE,trie charclass ; Same as TRIE, but with embedded charclass data |
3dab1dad | 180 | |
1de06328 | 181 | # For start classes, contains an added fail table. |
f8abb37e NC |
182 | AHOCORASICK TRIE, trie 1 ; Aho Corasick stclass. flags==type |
183 | AHOCORASICKC TRIE,trie charclass ; Same as AHOCORASICK, but with embedded charclass data | |
1de06328 | 184 | |
381b57db | 185 | #*Regex Subroutines |
f8abb37e NC |
186 | GOSUB GOSUB, num/ofs 2L ; recurse to paren arg1 at (signed) ofs arg2 |
187 | GOSTART GOSTART, no ; recurse to start of pattern | |
03363afd | 188 | |
381b57db | 189 | #*Special conditionals |
f8abb37e NC |
190 | NGROUPP NGROUPP, no-sv 1 ; Whether the group matched. |
191 | INSUBP INSUBP, num 1 ; Whether we are in a specific recurse. | |
192 | DEFINEP DEFINEP, none 1 ; Never execute directly. | |
0a4db386 | 193 | |
486ec47a | 194 | #*Backtracking Verbs |
f8abb37e NC |
195 | ENDLIKE ENDLIKE, none ; Used only for the type field of verbs |
196 | OPFAIL ENDLIKE, none ; Same as (?!) | |
197 | ACCEPT ENDLIKE, parno 1 ; Accepts the current matched string. | |
5d458dd8 YO |
198 | |
199 | ||
200 | #*Verbs With Arguments | |
f8abb37e NC |
201 | VERB VERB, no-sv 1 ; Used only for the type field of verbs |
202 | PRUNE VERB, no-sv 1 ; Pattern fails at this startpoint if no-backtracking through this | |
203 | MARKPOINT VERB, no-sv 1 ; Push the current location for rollback by cut. | |
204 | SKIP VERB, no-sv 1 ; On failure skip forward (to the mark) before retrying | |
205 | COMMIT VERB, no-sv 1 ; Pattern fails outright if backtracking through this | |
206 | CUTGROUP VERB, no-sv 1 ; On failure go to the next alternation in the group | |
e2e6a0f1 | 207 | |
ee9b8eae | 208 | #*Control what to keep in $&. |
f8abb37e | 209 | KEEPS KEEPS, no ; $& begins here. |
ee9b8eae | 210 | |
e1d1eefb | 211 | #*New charclass like patterns |
f8abb37e | 212 | LNBREAK LNBREAK, none ; generic newline pattern |
f9ef50a7 NC |
213 | VERTWS VERTWS, none 0 S ; vertical whitespace (Perl 6) |
214 | NVERTWS NVERTWS, none 0 S ; not vertical whitespace (Perl 6) | |
215 | HORIZWS HORIZWS, none 0 S ; horizontal whitespace (Perl 6) | |
216 | NHORIZWS NHORIZWS, none 0 S ; not horizontal whitespace (Perl 6) | |
e1d1eefb | 217 | |
f8abb37e | 218 | FOLDCHAR FOLDCHAR, codepoint 1 ; codepoint with tricky case folding properties. |
7fcd3a28 KW |
219 | |
220 | ||
381b57db | 221 | # NEW STUFF SOMEWHERE ABOVE THIS LINE |
1de06328 | 222 | |
03363afd YO |
223 | ################################################################################ |
224 | ||
7f69552c | 225 | #*SPECIAL REGOPS |
1de06328 YO |
226 | |
227 | # This is not really a node, but an optimized away piece of a "long" node. | |
228 | # To simplify debugging output, we mark it as if it were a node | |
f8abb37e | 229 | OPTIMIZED NOTHING, off ; Placeholder for dump. |
1de06328 | 230 | |
3dab1dad YO |
231 | # Special opcode with the property that no opcode in a compiled program |
232 | # will ever be of this type. Thus it can be used as a flag value that | |
233 | # no other opcode has been seen. END is used similarly, in that an END | |
234 | # node cant be optimized. So END implies "unoptimizable" and PSEUDO mean | |
235 | # "not seen anything to optimize yet". | |
f8abb37e | 236 | PSEUDO PSEUDO, off ; Pseudo opcode for internal use. |
1de06328 | 237 | |
03363afd YO |
238 | ------------------------------------------------------------------------------- |
239 | # Format for second section: | |
240 | # REGOP \t typelist [ \t typelist] [# Comment] | |
241 | # typelist= namelist | |
242 | # = namelist:FAIL | |
243 | # = name:count | |
244 | ||
245 | # Anything below is a state | |
246 | # | |
247 | # | |
f8abb37e NC |
248 | TRIE next:FAIL |
249 | EVAL AB:FAIL | |
250 | CURLYX end:FAIL | |
251 | WHILEM A_pre,A_min,A_max,B_min,B_max:FAIL | |
252 | BRANCH next:FAIL | |
253 | CURLYM A,B:FAIL | |
254 | IFMATCH A:FAIL | |
255 | CURLY B_min_known,B_min,B_max:FAIL | |
256 | COMMIT next:FAIL | |
257 | MARKPOINT next:FAIL | |
258 | SKIP next:FAIL | |
259 | CUTGROUP next:FAIL | |
260 | KEEPS next:FAIL |