This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Teach regex optimiser how to handle (?=) and (?<=) properly.
[perl5.git] / regcomp.sym
1 # Format:
2 # NAME \t TYPE, arg-description [num-args] [longjump-len] \t DESCRIPTION
3
4 # Empty rows and #-comment rows are ignored.
5
6 # Note that the order in this file is important.
7 #
8 # Add new regops to the end, and do not re-order the existing ops.
9 #
10
11 #* Exit points (0,1)
12
13 END             END,    no      End of program.
14 SUCCEED         END,    no      Return from a subroutine, basically.
15
16 #* Anchors: (2..13)
17
18 BOL             BOL,    no      Match "" at beginning of line.
19 MBOL            BOL,    no      Same, assuming multiline.
20 SBOL            BOL,    no      Same, assuming singleline.
21 EOS             EOL,    no      Match "" at end of string.
22 EOL             EOL,    no      Match "" at end of line.
23 MEOL            EOL,    no      Same, assuming multiline.
24 SEOL            EOL,    no      Same, assuming singleline.
25 BOUND           BOUND,  no      Match "" at any word boundary
26 BOUNDL          BOUND,  no      Match "" at any word boundary
27 NBOUND          NBOUND, no      Match "" at any word non-boundary
28 NBOUNDL         NBOUND, no      Match "" at any word non-boundary
29 GPOS            GPOS,   no      Matches where last m//g left off.
30
31 #* [Special] alternatives: (14..30)
32
33 REG_ANY         REG_ANY,    no  Match any one character (except newline).
34 SANY            REG_ANY,    no  Match any one character.
35 CANY            REG_ANY,    no  Match any one byte.
36 ANYOF           ANYOF,  sv      Match character in (or not in) this class.
37 ALNUM           ALNUM,  no      Match any alphanumeric character
38 ALNUML          ALNUM,  no      Match any alphanumeric char in locale
39 NALNUM          NALNUM, no      Match any non-alphanumeric character
40 NALNUML         NALNUM, no      Match any non-alphanumeric char in locale
41 SPACE           SPACE,  no      Match any whitespace character
42 SPACEL          SPACE,  no      Match any whitespace char in locale
43 NSPACE          NSPACE, no      Match any non-whitespace character
44 NSPACEL         NSPACE, no      Match any non-whitespace char in locale
45 DIGIT           DIGIT,  no      Match any numeric character
46 DIGITL          DIGIT,  no      Match any numeric character in locale
47 NDIGIT          NDIGIT, no      Match any non-numeric character
48 NDIGITL         NDIGIT, no      Match any non-numeric character in locale
49 CLUMP           CLUMP,  no      Match any combining character sequence
50
51 #* Alternation (31)
52
53 # BRANCH        The set of branches constituting a single choice are hooked
54 #               together with their "next" pointers, since precedence prevents
55 #               anything being concatenated to any individual branch.  The
56 #               "next" pointer of the last BRANCH in a choice points to the
57 #               thing following the whole choice.  This is also where the
58 #               final "next" pointer of each individual branch points; each
59 #               branch starts with the operand node of a BRANCH node.
60 #
61 BRANCH          BRANCH, node    Match this alternative, or the next...
62
63 #*Back pointer (32)
64
65 # BACK          Normal "next" pointers all implicitly point forward; BACK
66 #               exists to make loop structures possible.
67 # not used
68 BACK            BACK,   no      Match "", "next" ptr points backward.
69
70 #*Literals (33..35)
71
72 EXACT           EXACT,  sv      Match this string (preceded by length).
73 EXACTF          EXACT,  sv      Match this string, folded (prec. by length).
74 EXACTFL         EXACT,  sv      Match this string, folded in locale (w/len).
75
76 #*Do nothing types (36..37)
77
78 NOTHING         NOTHING,no      Match empty string.
79 # A variant of above which delimits a group, thus stops optimizations
80 TAIL            NOTHING,no      Match empty string. Can jump here from outside.
81
82 #*Loops (38..44)
83
84 # STAR,PLUS     '?', and complex '*' and '+', are implemented as circular
85 #               BRANCH structures using BACK.  Simple cases (one character
86 #               per match) are implemented with STAR and PLUS for speed
87 #               and to minimize recursive plunges.
88 #
89 STAR            STAR,   node    Match this (simple) thing 0 or more times.
90 PLUS            PLUS,   node    Match this (simple) thing 1 or more times.
91
92 CURLY           CURLY,  sv 2    Match this simple thing {n,m} times.
93 CURLYN          CURLY,  no 2    Match next-after-this simple thing 
94 #                               {n,m} times, set parenths.
95 CURLYM          CURLY,  no 2    Match this medium-complex thing {n,m} times.
96 CURLYX          CURLY,  sv 2    Match this complex thing {n,m} times.
97
98 # This terminator creates a loop structure for CURLYX
99 WHILEM          WHILEM, no      Do curly processing and see if rest matches.
100
101 #*Buffer related (45..49)
102
103 # OPEN,CLOSE,GROUPP     ...are numbered at compile time.
104 OPEN            OPEN,   num 1   Mark this point in input as start of #n.
105 CLOSE           CLOSE,  num 1   Analogous to OPEN.
106
107 REF             REF,    num 1   Match some already matched string
108 REFF            REF,    num 1   Match already matched string, folded
109 REFFL           REF,    num 1   Match already matched string, folded in loc.
110
111 #*Grouping assertions (50..54)
112
113 IFMATCH         BRANCHJ,off 1 2 Succeeds if the following matches.
114 UNLESSM         BRANCHJ,off 1 2 Fails if the following matches.
115 SUSPEND         BRANCHJ,off 1 1 "Independent" sub-RE.
116 IFTHEN          BRANCHJ,off 1 1 Switch, should be preceeded by switcher .
117 GROUPP          GROUPP, num 1   Whether the group matched.
118
119 #*Support for long RE (55..56)
120
121 LONGJMP         LONGJMP,off 1 1 Jump far away.
122 BRANCHJ         BRANCHJ,off 1 1 BRANCH with long offset.
123
124 #*The heavy worker (57..58)
125
126 EVAL            EVAL,   evl 1   Execute some Perl code.
127
128 #*Modifiers (59..60)
129
130 MINMOD          MINMOD, no      Next operator is not greedy.
131 LOGICAL         LOGICAL,no      Next opcode should set the flag only.
132
133 # This is not used yet (61)
134 RENUM           BRANCHJ,off 1 1 Group with independently numbered parens.
135
136 #*Trie Related (62..64)
137
138 # Behave the same as A|LIST|OF|WORDS would. The '..C' variants have  
139 # inline charclass data (ascii only), the 'C' store it in the structure.
140 # NOTE: the relative order of the TRIE-like regops  is signifigant
141
142 TRIE            TRIE,   trie 1  Match many EXACT(FL?)? at once. flags==type
143 TRIEC           TRIE,   trie charclass  Same as TRIE, but with embedded charclass data
144
145 # For start classes, contains an added fail table.
146 AHOCORASICK     TRIE,   trie 1  Aho Corasick stclass. flags==type
147 AHOCORASICKC    TRIE,   trie charclass  Same as AHOCORASICK, but with embedded charclass data
148
149 # NEW STUFF ABOVE THIS LINE -- Please update counts below. 
150
151 #*Special Nodes (65, 66)
152
153 # This is not really a node, but an optimized away piece of a "long" node.
154 # To simplify debugging output, we mark it as if it were a node
155 OPTIMIZED       NOTHING,off     Placeholder for dump.
156
157 # Special opcode with the property that no opcode in a compiled program
158 # will ever be of this type. Thus it can be used as a flag value that
159 # no other opcode has been seen. END is used similarly, in that an END
160 # node cant be optimized. So END implies "unoptimizable" and PSEUDO mean
161 # "not seen anything to optimize yet".
162 PSEUDO          PSEUDO,off      Pseudo opcode for internal use.
163
164 # NOTHING BELOW HERE