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 [flags] [num-args] [longjump-len] ; DESCRIPTION
15 # run perl regen.pl after editing this file
21 END END, no ; End of program.
22 SUCCEED END, no ; Return from a subroutine, basically.
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 locale word boundary
35 NBOUND NBOUND, no ; Match "" at any word non-boundary
36 NBOUNDL NBOUND, no ; Match "" at any locale word non-boundary
37 GPOS GPOS, no ; Matches where last m//g left off.
39 #* [Special] alternatives:
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.
44 ANYOF ANYOF, sv 0 S ; Match character in (or not in) this class, single char match only
45 ANYOFV ANYOF, sv 0 V ; Match character in (or not in) this class, can match-multiple chars
46 ALNUM ALNUM, no 0 S ; Match any alphanumeric character using native charset semantics for non-utf8
47 ALNUML ALNUM, no 0 S ; Match any alphanumeric char in locale
48 ALNUMU ALNUM, no 0 S ; Match any alphanumeric char using Unicode semantics
49 NALNUM NALNUM, no 0 S ; Match any non-alphanumeric character using native charset semantics for non-utf8
50 NALNUML NALNUM, no 0 S ; Match any non-alphanumeric char in locale
51 NALNUMU NALNUM, no 0 S ; Match any non-alphanumeric char using Unicode semantics
52 SPACE SPACE, no 0 S ; Match any whitespace character using native charset semantics for non-utf8
53 SPACEL SPACE, no 0 S ; Match any whitespace char in locale
54 SPACEU SPACE, no 0 S ; Match any whitespace char using Unicode semantics
55 NSPACE NSPACE, no 0 S ; Match any non-whitespace character using native charset semantics for non-utf8
56 NSPACEL NSPACE, no 0 S ; Match any non-whitespace char in locale
57 NSPACEU NSPACE, no 0 S ; Match any non-whitespace char using Unicode semantics
58 DIGIT DIGIT, no 0 S ; Match any numeric character using native charset semantics for non-utf8
59 DIGITL DIGIT, no 0 S ; Match any numeric character in locale
60 DIGITU DIGIT, no 0 S ; Match any numeric character using Unicode semantics
61 NDIGIT NDIGIT, no 0 S ; Match any non-numeric character using native charset semantics for non-utf8
62 NDIGITL NDIGIT, no 0 S ; Match any non-numeric character in locale
63 NDIGITU NDIGIT, no 0 S ; Match any non-numeric character using Unicode semantics
64 CLUMP CLUMP, no 0 V ; Match any extended grapheme cluster sequence
68 # BRANCH The set of branches constituting a single choice are hooked
69 # together with their "next" pointers, since precedence prevents
70 # anything being concatenated to any individual branch. The
71 # "next" pointer of the last BRANCH in a choice points to the
72 # thing following the whole choice. This is also where the
73 # final "next" pointer of each individual branch points; each
74 # branch starts with the operand node of a BRANCH node.
76 BRANCH BRANCH, node 0 V ; Match this alternative, or the next...
80 # BACK Normal "next" pointers all implicitly point forward; BACK
81 # exists to make loop structures possible.
83 BACK BACK, no 0 V ; Match "", "next" ptr points backward.
87 EXACT EXACT, str ; Match this string (preceded by length).
88 EXACTF EXACT, str ; Match this string, folded, native charset semantics for non-utf8 (prec. by length).
89 EXACTFL EXACT, str ; Match this string, folded in locale (w/len).
90 EXACTFU EXACT, str ; Match this string, folded, Unicode semantics for non-utf8 (prec. by length).
94 NOTHING NOTHING, no ; Match empty string.
95 # A variant of above which delimits a group, thus stops optimizations
96 TAIL NOTHING, no ; Match empty string. Can jump here from outside.
100 # STAR,PLUS '?', and complex '*' and '+', are implemented as circular
101 # BRANCH structures using BACK. Simple cases (one character
102 # per match) are implemented with STAR and PLUS for speed
103 # and to minimize recursive plunges.
105 STAR STAR, node 0 V ; Match this (simple) thing 0 or more times.
106 PLUS PLUS, node 0 V ; Match this (simple) thing 1 or more times.
108 CURLY CURLY, sv 2 V ; Match this simple thing {n,m} times.
109 CURLYN CURLY, no 2 V ; Capture next-after-this simple thing
110 CURLYM CURLY, no 2 V ; Capture this medium-complex thing {n,m} times.
111 CURLYX CURLY, sv 2 V ; Match this complex thing {n,m} times.
113 # This terminator creates a loop structure for CURLYX
114 WHILEM WHILEM, no 0 V ; Do curly processing and see if rest matches.
118 # OPEN,CLOSE,GROUPP ...are numbered at compile time.
119 OPEN OPEN, num 1 ; Mark this point in input as start of #n.
120 CLOSE CLOSE, num 1 ; Analogous to OPEN.
122 REF REF, num 1 V ; Match some already matched string
123 REFF REF, num 1 V ; Match already matched string, folded using native charset semantics for non-utf8
124 REFFL REF, num 1 V ; Match already matched string, folded in loc.
125 # REFFU and NREFFU could have been implemented using the FLAGS field of the
126 # regnode, but by having a separate node type, we can use the existing switch
127 # statement to avoid some tests
128 REFFU REF, num 1 V ; Match already matched string, folded using unicode semantics for non-utf8
130 #*Named references. Code in regcomp.c assumes that these all are after the numbered references
131 NREF REF, no-sv 1 V ; Match some already matched string
132 NREFF REF, no-sv 1 V ; Match already matched string, folded using native charset semantics for non-utf8
133 NREFFL REF, no-sv 1 V ; Match already matched string, folded in loc.
134 NREFFU REF, num 1 V ; Match already matched string, folded using unicode semantics for non-utf8
136 IFMATCH BRANCHJ, off 1 . 2 ; Succeeds if the following matches.
137 UNLESSM BRANCHJ, off 1 . 2 ; Fails if the following matches.
138 SUSPEND BRANCHJ, off 1 V 1 ; "Independent" sub-RE.
139 IFTHEN BRANCHJ, off 1 V 1 ; Switch, should be preceded by switcher .
140 GROUPP GROUPP, num 1 ; Whether the group matched.
142 #*Support for long RE
144 LONGJMP LONGJMP, off 1 . 1 ; Jump far away.
145 BRANCHJ BRANCHJ, off 1 V 1 ; BRANCH with long offset.
149 EVAL EVAL, evl 1 ; Execute some Perl code.
153 MINMOD MINMOD, no ; Next operator is not greedy.
154 LOGICAL LOGICAL, no ; Next opcode should set the flag only.
156 # This is not used yet
157 RENUM BRANCHJ, off 1 . 1 ; Group with independently numbered parens.
161 # Behave the same as A|LIST|OF|WORDS would. The '..C' variants have
162 # inline charclass data (ascii only), the 'C' store it in the structure.
163 # NOTE: the relative order of the TRIE-like regops is significant
165 TRIE TRIE, trie 1 ; Match many EXACT(F[LU]?)? at once. flags==type
166 TRIEC TRIE,trie charclass ; Same as TRIE, but with embedded charclass data
168 # For start classes, contains an added fail table.
169 AHOCORASICK TRIE, trie 1 ; Aho Corasick stclass. flags==type
170 AHOCORASICKC TRIE,trie charclass ; Same as AHOCORASICK, but with embedded charclass data
173 GOSUB GOSUB, num/ofs 2L ; recurse to paren arg1 at (signed) ofs arg2
174 GOSTART GOSTART, no ; recurse to start of pattern
176 #*Special conditionals
177 NGROUPP NGROUPP, no-sv 1 ; Whether the group matched.
178 INSUBP INSUBP, num 1 ; Whether we are in a specific recurse.
179 DEFINEP DEFINEP, none 1 ; Never execute directly.
182 ENDLIKE ENDLIKE, none ; Used only for the type field of verbs
183 OPFAIL ENDLIKE, none ; Same as (?!)
184 ACCEPT ENDLIKE, parno 1 ; Accepts the current matched string.
187 #*Verbs With Arguments
188 VERB VERB, no-sv 1 ; Used only for the type field of verbs
189 PRUNE VERB, no-sv 1 ; Pattern fails at this startpoint if no-backtracking through this
190 MARKPOINT VERB, no-sv 1 ; Push the current location for rollback by cut.
191 SKIP VERB, no-sv 1 ; On failure skip forward (to the mark) before retrying
192 COMMIT VERB, no-sv 1 ; Pattern fails outright if backtracking through this
193 CUTGROUP VERB, no-sv 1 ; On failure go to the next alternation in the group
195 #*Control what to keep in $&.
196 KEEPS KEEPS, no ; $& begins here.
198 #*New charclass like patterns
199 LNBREAK LNBREAK, none ; generic newline pattern
200 VERTWS VERTWS, none 0 S ; vertical whitespace (Perl 6)
201 NVERTWS NVERTWS, none 0 S ; not vertical whitespace (Perl 6)
202 HORIZWS HORIZWS, none 0 S ; horizontal whitespace (Perl 6)
203 NHORIZWS NHORIZWS, none 0 S ; not horizontal whitespace (Perl 6)
205 FOLDCHAR FOLDCHAR, codepoint 1 ; codepoint with tricky case folding properties.
208 # NEW STUFF SOMEWHERE ABOVE THIS LINE
210 ################################################################################
214 # This is not really a node, but an optimized away piece of a "long" node.
215 # To simplify debugging output, we mark it as if it were a node
216 OPTIMIZED NOTHING, off ; Placeholder for dump.
218 # Special opcode with the property that no opcode in a compiled program
219 # will ever be of this type. Thus it can be used as a flag value that
220 # no other opcode has been seen. END is used similarly, in that an END
221 # node cant be optimized. So END implies "unoptimizable" and PSEUDO mean
222 # "not seen anything to optimize yet".
223 PSEUDO PSEUDO, off ; Pseudo opcode for internal use.
225 -------------------------------------------------------------------------------
226 # Format for second section:
227 # REGOP \t typelist [ \t typelist] [# Comment]
232 # Anything below is a state
238 WHILEM A_pre,A_min,A_max,B_min,B_max:FAIL
242 CURLY B_min_known,B_min,B_max:FAIL