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