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