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