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