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