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