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