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