This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix typos (spelling errors) in mpeix/*.
[perl5.git] / regcomp.sym
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 #
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
21 END         END,        no        ; End of program.
22 SUCCEED     END,        no        ; Return from a subroutine, basically.
23
24 #* Anchors:
25
26 BOL         BOL,        no        ; Match "" at beginning of line.
27 MBOL        BOL,        no        ; Same, assuming multiline.
28 SBOL        BOL,        no        ; Same, assuming singleline.
29 EOS         EOL,        no        ; Match "" at end of string.
30 EOL         EOL,        no        ; Match "" at end of line.
31 MEOL        EOL,        no        ; Same, assuming multiline.
32 SEOL        EOL,        no        ; Same, assuming singleline.
33 BOUND       BOUND,      no        ; Match "" at any word boundary
34 BOUNDL      BOUND,      no        ; Match "" at any word boundary
35 NBOUND      NBOUND,     no        ; Match "" at any word non-boundary
36 NBOUNDL     NBOUND,     no        ; Match "" at any word non-boundary
37 GPOS        GPOS,       no        ; Matches where last m//g left off.
38
39 #* [Special] alternatives:
40
41 REG_ANY     REG_ANY,    no 0 S    ; Match any one character (except newline).
42 SANY        REG_ANY,    no 0 S    ; Match any one character.
43 CANY        REG_ANY,    no 0 S    ; Match any one byte.
44 ANYOF       ANYOF,      sv 0 S    ; Match character in (or not in) this class, folding is native charset for non-utf8.
45 ALNUM       ALNUM,      no 0 S    ; Match any alphanumeric character
46 ALNUML      ALNUM,      no 0 S    ; Match any alphanumeric char in locale
47 NALNUM      NALNUM,     no 0 S    ; Match any non-alphanumeric character
48 NALNUML     NALNUM,     no 0 S    ; Match any non-alphanumeric char in locale
49 SPACE       SPACE,      no 0 S    ; Match any whitespace character
50 SPACEL      SPACE,      no 0 S    ; Match any whitespace char in locale
51 NSPACE      NSPACE,     no 0 S    ; Match any non-whitespace character
52 NSPACEL     NSPACE,     no 0 S    ; Match any non-whitespace char in locale
53 DIGIT       DIGIT,      no 0 S    ; Match any numeric character
54 DIGITL      DIGIT,      no 0 S    ; Match any numeric character in locale
55 NDIGIT      NDIGIT,     no 0 S    ; Match any non-numeric character
56 NDIGITL     NDIGIT,     no 0 S    ; Match any non-numeric character in locale
57 CLUMP       CLUMP,      no 0 V    ; Match any extended grapheme cluster sequence
58
59 #* Alternation
60
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.
68 #
69 BRANCH      BRANCH,     node 0 V  ; Match this alternative, or the next...
70
71 #*Back pointer
72
73 # BACK          Normal "next" pointers all implicitly point forward; BACK
74 #               exists to make loop structures possible.
75 # not used
76 BACK        BACK,       no 0 V    ; Match "", "next" ptr points backward.
77
78 #*Literals
79
80 EXACT       EXACT,      str       ; Match this string (preceded by length).
81 EXACTF      EXACT,      str       ; Match this string, folded, native charset semantics for non-utf8 (prec. by length).
82 EXACTFL     EXACT,      str       ; Match this string, folded in locale (w/len).
83 EXACTFU     EXACT,      str       ; Match this string, folded, Unicode semantics for non-utf8 (prec. by length).
84
85 #*Do nothing types
86
87 NOTHING     NOTHING,    no        ; Match empty string.
88 # A variant of above which delimits a group, thus stops optimizations
89 TAIL        NOTHING,    no        ; Match empty string. Can jump here from outside.
90
91 #*Loops
92
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.
97 #
98 STAR        STAR,       node 0 V  ; Match this (simple) thing 0 or more times.
99 PLUS        PLUS,       node 0 V  ; Match this (simple) thing 1 or more times.
100
101 CURLY       CURLY,      sv 2 V    ; Match this simple thing {n,m} times.
102 CURLYN      CURLY,      no 2 V    ; Capture next-after-this simple thing 
103 CURLYM      CURLY,      no 2 V    ; Capture this medium-complex thing {n,m} times. 
104 CURLYX      CURLY,      sv 2 V    ; Match this complex thing {n,m} times.
105
106 # This terminator creates a loop structure for CURLYX
107 WHILEM      WHILEM,     no 0 V    ; Do curly processing and see if rest matches.
108
109 #*Buffer related
110
111 # OPEN,CLOSE,GROUPP     ...are numbered at compile time.
112 OPEN        OPEN,       num 1     ; Mark this point in input as start of #n.
113 CLOSE       CLOSE,      num 1     ; Analogous to OPEN.
114
115 REF         REF,        num 1 V   ; Match some already matched string
116 REFF        REF,        num 1 V   ; Match already matched string, folded using native charset semantics for non-utf8
117 REFFL       REF,        num 1 V   ; Match already matched string, folded in loc.
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
121 REFFU       REF,        num 1 V   ; Match already matched string, folded using unicode semantics for non-utf8
122
123 #*Named references.  Code in regcomp.c assumes that these all are after the numbered references
124 NREF        REF,        no-sv 1 V ; Match some already matched string
125 NREFF       REF,        no-sv 1 V ; Match already matched string, folded using native charset semantics for non-utf8
126 NREFFL      REF,        no-sv 1 V ; Match already matched string, folded in loc.
127 NREFFU      REF,        num   1 V ; Match already matched string, folded using unicode semantics for non-utf8
128
129 IFMATCH     BRANCHJ,    off 1 . 2 ; Succeeds if the following matches.
130 UNLESSM     BRANCHJ,    off 1 . 2 ; Fails if the following matches.
131 SUSPEND     BRANCHJ,    off 1 V 1 ; "Independent" sub-RE.
132 IFTHEN      BRANCHJ,    off 1 V 1 ; Switch, should be preceeded by switcher .
133 GROUPP      GROUPP,     num 1     ; Whether the group matched.
134
135 #*Support for long RE
136
137 LONGJMP     LONGJMP,    off 1 . 1 ; Jump far away.
138 BRANCHJ     BRANCHJ,    off 1 V 1 ; BRANCH with long offset.
139
140 #*The heavy worker
141
142 EVAL        EVAL,       evl 1     ; Execute some Perl code.
143
144 #*Modifiers
145
146 MINMOD      MINMOD,     no        ; Next operator is not greedy.
147 LOGICAL     LOGICAL,    no        ; Next opcode should set the flag only.
148
149 # This is not used yet
150 RENUM       BRANCHJ,    off 1 . 1 ; Group with independently numbered parens.
151
152 #*Trie Related
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
157
158 TRIE        TRIE,       trie 1    ; Match many EXACT(F[LU]?)? at once. flags==type
159 TRIEC       TRIE,trie charclass   ; Same as TRIE, but with embedded charclass data
160
161 # For start classes, contains an added fail table.
162 AHOCORASICK     TRIE,   trie 1    ; Aho Corasick stclass. flags==type
163 AHOCORASICKC    TRIE,trie charclass   ; Same as AHOCORASICK, but with embedded charclass data
164
165 #*Regex Subroutines
166 GOSUB       GOSUB,      num/ofs 2L    ; recurse to paren arg1 at (signed) ofs arg2
167 GOSTART     GOSTART,    no        ; recurse to start of pattern
168
169 #*Special conditionals
170 NGROUPP     NGROUPP,    no-sv 1   ; Whether the group matched.            
171 INSUBP      INSUBP,     num 1     ; Whether we are in a specific recurse.  
172 DEFINEP     DEFINEP,    none 1    ; Never execute directly.               
173
174 #*Bactracking Verbs
175 ENDLIKE     ENDLIKE,    none      ; Used only for the type field of verbs
176 OPFAIL      ENDLIKE,    none      ; Same as (?!)
177 ACCEPT      ENDLIKE,    parno 1   ; Accepts the current matched string.
178
179
180 #*Verbs With Arguments
181 VERB        VERB,       no-sv 1   ; Used only for the type field of verbs
182 PRUNE       VERB,       no-sv 1   ; Pattern fails at this startpoint if no-backtracking through this 
183 MARKPOINT   VERB,       no-sv 1   ; Push the current location for rollback by cut.
184 SKIP        VERB,       no-sv 1   ; On failure skip forward (to the mark) before retrying
185 COMMIT      VERB,       no-sv 1   ; Pattern fails outright if backtracking through this
186 CUTGROUP    VERB,       no-sv 1   ; On failure go to the next alternation in the group
187
188 #*Control what to keep in $&.
189 KEEPS       KEEPS,      no        ; $& begins here.
190
191 #*New charclass like patterns
192 LNBREAK     LNBREAK,    none      ; generic newline pattern
193 VERTWS      VERTWS,     none 0 S  ; vertical whitespace         (Perl 6)
194 NVERTWS     NVERTWS,    none 0 S  ; not vertical whitespace     (Perl 6)
195 HORIZWS     HORIZWS,    none 0 S  ; horizontal whitespace       (Perl 6)
196 NHORIZWS    NHORIZWS,   none 0 S  ; not horizontal whitespace   (Perl 6)
197
198 FOLDCHAR    FOLDCHAR,   codepoint 1 ; codepoint with tricky case folding properties.
199
200
201 # NEW STUFF SOMEWHERE ABOVE THIS LINE
202
203 ################################################################################
204
205 #*SPECIAL  REGOPS
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
209 OPTIMIZED   NOTHING,    off       ; Placeholder for dump.
210
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".
216 PSEUDO      PSEUDO,     off       ; Pseudo opcode for internal use.
217
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 #
228 TRIE            next:FAIL
229 EVAL            AB:FAIL
230 CURLYX          end:FAIL
231 WHILEM          A_pre,A_min,A_max,B_min,B_max:FAIL
232 BRANCH          next:FAIL
233 CURLYM          A,B:FAIL
234 IFMATCH         A:FAIL
235 CURLY           B_min_known,B_min,B_max:FAIL
236 COMMIT          next:FAIL
237 MARKPOINT       next:FAIL
238 SKIP            next:FAIL
239 CUTGROUP        next:FAIL
240 KEEPS           next:FAIL