summaryrefslogtreecommitdiff
path: root/regnodes.h
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2012-06-27 13:48:16 -0600
committerKarl Williamson <public@khwilliamson.com>2012-06-29 22:22:42 -0600
commit693fefec6759ebf0a9ec40a0f59346d86831349c (patch)
treed12041ac3714d0ae4c14ce2391f280380f038183 /regnodes.h
parent8c1182fda8158a86281b1ea6464176d1c68f2f18 (diff)
downloadperl-693fefec6759ebf0a9ec40a0f59346d86831349c.tar.gz
regcomp.c: Simply some node calculations
For the node types that have differing versions depending on the character set regex modifiers, /d, /l, /u, /a, and /aa, we can use the enum values as offsets from the base node number to derive the correct one. This eliminates a number of tests. Because there is no DIGITU node type, I added placeholders for it (and NDIGITU) to avoid some special casing of it (more important in future commits). We currently have many available node types, so can afford to waste these two.
Diffstat (limited to 'regnodes.h')
-rw-r--r--regnodes.h306
1 files changed, 158 insertions, 148 deletions
diff --git a/regnodes.h b/regnodes.h
index ff3ba3f3ef..84096d6c8e 100644
--- a/regnodes.h
+++ b/regnodes.h
@@ -6,8 +6,8 @@
/* Regops and State definitions */
-#define REGNODE_MAX 112
-#define REGMATCH_STATE_MAX 152
+#define REGNODE_MAX 114
+#define REGMATCH_STATE_MAX 154
#define END 0 /* 0000 End of program. */
#define SUCCEED 1 /* 0x01 Return from a subroutine, basically. */
@@ -50,78 +50,80 @@
#define NSPACEA 38 /* 0x26 Match [^ \t\n\f\r] */
#define DIGIT 39 /* 0x27 Match any numeric character using native charset semantics for non-utf8 */
#define DIGITL 40 /* 0x28 Match any numeric character in locale */
-#define DIGITA 41 /* 0x29 Match [0-9] */
-#define NDIGIT 42 /* 0x2a Match any non-numeric character using native charset semantics for non-utf8 */
-#define NDIGITL 43 /* 0x2b Match any non-numeric character in locale */
-#define NDIGITA 44 /* 0x2c Match [^0-9] */
-#define CLUMP 45 /* 0x2d Match any extended grapheme cluster sequence */
-#define BRANCH 46 /* 0x2e Match this alternative, or the next... */
-#define BACK 47 /* 0x2f Match "", "next" ptr points backward. */
-#define EXACT 48 /* 0x30 Match this string (preceded by length). */
-#define EXACTF 49 /* 0x31 Match this non-UTF-8 string (not guaranteed to be folded) using /id rules (w/len). */
-#define EXACTFL 50 /* 0x32 Match this string (not guaranteed to be folded) using /il rules (w/len). */
-#define EXACTFU 51 /* 0x33 Match this string (folded iff in UTF-8, length in folding doesn't change if not in UTF-8) using /iu rules (w/len). */
-#define EXACTFA 52 /* 0x34 Match this string (not guaranteed to be folded) using /iaa rules (w/len). */
-#define EXACTFU_SS 53 /* 0x35 Match this string (folded iff in UTF-8, length in folding may change even if not in UTF-8) using /iu rules (w/len). */
-#define EXACTFU_TRICKYFOLD 54 /* 0x36 Match this folded UTF-8 string using /iu rules */
-#define NOTHING 55 /* 0x37 Match empty string. */
-#define TAIL 56 /* 0x38 Match empty string. Can jump here from outside. */
-#define STAR 57 /* 0x39 Match this (simple) thing 0 or more times. */
-#define PLUS 58 /* 0x3a Match this (simple) thing 1 or more times. */
-#define CURLY 59 /* 0x3b Match this simple thing {n,m} times. */
-#define CURLYN 60 /* 0x3c Capture next-after-this simple thing */
-#define CURLYM 61 /* 0x3d Capture this medium-complex thing {n,m} times. */
-#define CURLYX 62 /* 0x3e Match this complex thing {n,m} times. */
-#define WHILEM 63 /* 0x3f Do curly processing and see if rest matches. */
-#define OPEN 64 /* 0x40 Mark this point in input as start of */
-#define CLOSE 65 /* 0x41 Analogous to OPEN. */
-#define REF 66 /* 0x42 Match some already matched string */
-#define REFF 67 /* 0x43 Match already matched string, folded using native charset semantics for non-utf8 */
-#define REFFL 68 /* 0x44 Match already matched string, folded in loc. */
-#define REFFU 69 /* 0x45 Match already matched string, folded using unicode semantics for non-utf8 */
-#define REFFA 70 /* 0x46 Match already matched string, folded using unicode semantics for non-utf8, no mixing ASCII, non-ASCII */
-#define NREF 71 /* 0x47 Match some already matched string */
-#define NREFF 72 /* 0x48 Match already matched string, folded using native charset semantics for non-utf8 */
-#define NREFFL 73 /* 0x49 Match already matched string, folded in loc. */
-#define NREFFU 74 /* 0x4a Match already matched string, folded using unicode semantics for non-utf8 */
-#define NREFFA 75 /* 0x4b Match already matched string, folded using unicode semantics for non-utf8, no mixing ASCII, non-ASCII */
-#define IFMATCH 76 /* 0x4c Succeeds if the following matches. */
-#define UNLESSM 77 /* 0x4d Fails if the following matches. */
-#define SUSPEND 78 /* 0x4e "Independent" sub-RE. */
-#define IFTHEN 79 /* 0x4f Switch, should be preceded by switcher . */
-#define GROUPP 80 /* 0x50 Whether the group matched. */
-#define LONGJMP 81 /* 0x51 Jump far away. */
-#define BRANCHJ 82 /* 0x52 BRANCH with long offset. */
-#define EVAL 83 /* 0x53 Execute some Perl code. */
-#define MINMOD 84 /* 0x54 Next operator is not greedy. */
-#define LOGICAL 85 /* 0x55 Next opcode should set the flag only. */
-#define RENUM 86 /* 0x56 Group with independently numbered parens. */
-#define TRIE 87 /* 0x57 Match many EXACT(F[ALU]?)? at once. flags==type */
-#define TRIEC 88 /* 0x58 Same as TRIE, but with embedded charclass data */
-#define AHOCORASICK 89 /* 0x59 Aho Corasick stclass. flags==type */
-#define AHOCORASICKC 90 /* 0x5a Same as AHOCORASICK, but with embedded charclass data */
-#define GOSUB 91 /* 0x5b recurse to paren arg1 at (signed) ofs arg2 */
-#define GOSTART 92 /* 0x5c recurse to start of pattern */
-#define NGROUPP 93 /* 0x5d Whether the group matched. */
-#define INSUBP 94 /* 0x5e Whether we are in a specific recurse. */
-#define DEFINEP 95 /* 0x5f Never execute directly. */
-#define ENDLIKE 96 /* 0x60 Used only for the type field of verbs */
-#define OPFAIL 97 /* 0x61 Same as (?!) */
-#define ACCEPT 98 /* 0x62 Accepts the current matched string. */
-#define VERB 99 /* 0x63 Used only for the type field of verbs */
-#define PRUNE 100 /* 0x64 Pattern fails at this startpoint if no-backtracking through this */
-#define MARKPOINT 101 /* 0x65 Push the current location for rollback by cut. */
-#define SKIP 102 /* 0x66 On failure skip forward (to the mark) before retrying */
-#define COMMIT 103 /* 0x67 Pattern fails outright if backtracking through this */
-#define CUTGROUP 104 /* 0x68 On failure go to the next alternation in the group */
-#define KEEPS 105 /* 0x69 $& begins here. */
-#define LNBREAK 106 /* 0x6a generic newline pattern */
-#define VERTWS 107 /* 0x6b vertical whitespace (Perl 6) */
-#define NVERTWS 108 /* 0x6c not vertical whitespace (Perl 6) */
-#define HORIZWS 109 /* 0x6d horizontal whitespace (Perl 6) */
-#define NHORIZWS 110 /* 0x6e not horizontal whitespace (Perl 6) */
-#define OPTIMIZED 111 /* 0x6f Placeholder for dump. */
-#define PSEUDO 112 /* 0x70 Pseudo opcode for internal use. */
+#define PLACEHOLDER1 41 /* 0x29 placeholder for missing DIGITU */
+#define DIGITA 42 /* 0x2a Match [0-9] */
+#define NDIGIT 43 /* 0x2b Match any non-numeric character using native charset semantics for non-utf8 */
+#define NDIGITL 44 /* 0x2c Match any non-numeric character in locale */
+#define PLACEHOLDER2 45 /* 0x2d placeholder for missing NDIGITU */
+#define NDIGITA 46 /* 0x2e Match [^0-9] */
+#define CLUMP 47 /* 0x2f Match any extended grapheme cluster sequence */
+#define BRANCH 48 /* 0x30 Match this alternative, or the next... */
+#define BACK 49 /* 0x31 Match "", "next" ptr points backward. */
+#define EXACT 50 /* 0x32 Match this string (preceded by length). */
+#define EXACTF 51 /* 0x33 Match this non-UTF-8 string (not guaranteed to be folded) using /id rules (w/len). */
+#define EXACTFL 52 /* 0x34 Match this string (not guaranteed to be folded) using /il rules (w/len). */
+#define EXACTFU 53 /* 0x35 Match this string (folded iff in UTF-8, length in folding doesn't change if not in UTF-8) using /iu rules (w/len). */
+#define EXACTFA 54 /* 0x36 Match this string (not guaranteed to be folded) using /iaa rules (w/len). */
+#define EXACTFU_SS 55 /* 0x37 Match this string (folded iff in UTF-8, length in folding may change even if not in UTF-8) using /iu rules (w/len). */
+#define EXACTFU_TRICKYFOLD 56 /* 0x38 Match this folded UTF-8 string using /iu rules */
+#define NOTHING 57 /* 0x39 Match empty string. */
+#define TAIL 58 /* 0x3a Match empty string. Can jump here from outside. */
+#define STAR 59 /* 0x3b Match this (simple) thing 0 or more times. */
+#define PLUS 60 /* 0x3c Match this (simple) thing 1 or more times. */
+#define CURLY 61 /* 0x3d Match this simple thing {n,m} times. */
+#define CURLYN 62 /* 0x3e Capture next-after-this simple thing */
+#define CURLYM 63 /* 0x3f Capture this medium-complex thing {n,m} times. */
+#define CURLYX 64 /* 0x40 Match this complex thing {n,m} times. */
+#define WHILEM 65 /* 0x41 Do curly processing and see if rest matches. */
+#define OPEN 66 /* 0x42 Mark this point in input as start of */
+#define CLOSE 67 /* 0x43 Analogous to OPEN. */
+#define REF 68 /* 0x44 Match some already matched string */
+#define REFF 69 /* 0x45 Match already matched string, folded using native charset semantics for non-utf8 */
+#define REFFL 70 /* 0x46 Match already matched string, folded in loc. */
+#define REFFU 71 /* 0x47 Match already matched string, folded using unicode semantics for non-utf8 */
+#define REFFA 72 /* 0x48 Match already matched string, folded using unicode semantics for non-utf8, no mixing ASCII, non-ASCII */
+#define NREF 73 /* 0x49 Match some already matched string */
+#define NREFF 74 /* 0x4a Match already matched string, folded using native charset semantics for non-utf8 */
+#define NREFFL 75 /* 0x4b Match already matched string, folded in loc. */
+#define NREFFU 76 /* 0x4c Match already matched string, folded using unicode semantics for non-utf8 */
+#define NREFFA 77 /* 0x4d Match already matched string, folded using unicode semantics for non-utf8, no mixing ASCII, non-ASCII */
+#define IFMATCH 78 /* 0x4e Succeeds if the following matches. */
+#define UNLESSM 79 /* 0x4f Fails if the following matches. */
+#define SUSPEND 80 /* 0x50 "Independent" sub-RE. */
+#define IFTHEN 81 /* 0x51 Switch, should be preceded by switcher . */
+#define GROUPP 82 /* 0x52 Whether the group matched. */
+#define LONGJMP 83 /* 0x53 Jump far away. */
+#define BRANCHJ 84 /* 0x54 BRANCH with long offset. */
+#define EVAL 85 /* 0x55 Execute some Perl code. */
+#define MINMOD 86 /* 0x56 Next operator is not greedy. */
+#define LOGICAL 87 /* 0x57 Next opcode should set the flag only. */
+#define RENUM 88 /* 0x58 Group with independently numbered parens. */
+#define TRIE 89 /* 0x59 Match many EXACT(F[ALU]?)? at once. flags==type */
+#define TRIEC 90 /* 0x5a Same as TRIE, but with embedded charclass data */
+#define AHOCORASICK 91 /* 0x5b Aho Corasick stclass. flags==type */
+#define AHOCORASICKC 92 /* 0x5c Same as AHOCORASICK, but with embedded charclass data */
+#define GOSUB 93 /* 0x5d recurse to paren arg1 at (signed) ofs arg2 */
+#define GOSTART 94 /* 0x5e recurse to start of pattern */
+#define NGROUPP 95 /* 0x5f Whether the group matched. */
+#define INSUBP 96 /* 0x60 Whether we are in a specific recurse. */
+#define DEFINEP 97 /* 0x61 Never execute directly. */
+#define ENDLIKE 98 /* 0x62 Used only for the type field of verbs */
+#define OPFAIL 99 /* 0x63 Same as (?!) */
+#define ACCEPT 100 /* 0x64 Accepts the current matched string. */
+#define VERB 101 /* 0x65 Used only for the type field of verbs */
+#define PRUNE 102 /* 0x66 Pattern fails at this startpoint if no-backtracking through this */
+#define MARKPOINT 103 /* 0x67 Push the current location for rollback by cut. */
+#define SKIP 104 /* 0x68 On failure skip forward (to the mark) before retrying */
+#define COMMIT 105 /* 0x69 Pattern fails outright if backtracking through this */
+#define CUTGROUP 106 /* 0x6a On failure go to the next alternation in the group */
+#define KEEPS 107 /* 0x6b $& begins here. */
+#define LNBREAK 108 /* 0x6c generic newline pattern */
+#define VERTWS 109 /* 0x6d vertical whitespace (Perl 6) */
+#define NVERTWS 110 /* 0x6e not vertical whitespace (Perl 6) */
+#define HORIZWS 111 /* 0x6f horizontal whitespace (Perl 6) */
+#define NHORIZWS 112 /* 0x70 not horizontal whitespace (Perl 6) */
+#define OPTIMIZED 113 /* 0x71 Placeholder for dump. */
+#define PSEUDO 114 /* 0x72 Pseudo opcode for internal use. */
/* ------------ States ------------- */
#define TRIE_next (REGNODE_MAX + 1) /* state for TRIE */
#define TRIE_next_fail (REGNODE_MAX + 2) /* state for TRIE */
@@ -211,9 +213,11 @@ EXTCONST U8 PL_regkind[] = {
NSPACE, /* NSPACEA */
DIGIT, /* DIGIT */
DIGIT, /* DIGITL */
+ NOTHING, /* PLACEHOLDER1 */
DIGIT, /* DIGITA */
NDIGIT, /* NDIGIT */
NDIGIT, /* NDIGITL */
+ NOTHING, /* PLACEHOLDER2 */
NDIGIT, /* NDIGITA */
CLUMP, /* CLUMP */
BRANCH, /* BRANCH */
@@ -372,9 +376,11 @@ static const U8 regarglen[] = {
0, /* NSPACEA */
0, /* DIGIT */
0, /* DIGITL */
+ 0, /* PLACEHOLDER1 */
0, /* DIGITA */
0, /* NDIGIT */
0, /* NDIGITL */
+ 0, /* PLACEHOLDER2 */
0, /* NDIGITA */
0, /* CLUMP */
0, /* BRANCH */
@@ -490,9 +496,11 @@ static const char reg_off_by_arg[] = {
0, /* NSPACEA */
0, /* DIGIT */
0, /* DIGITL */
+ 0, /* PLACEHOLDER1 */
0, /* DIGITA */
0, /* NDIGIT */
0, /* NDIGITL */
+ 0, /* PLACEHOLDER2 */
0, /* NDIGITA */
0, /* CLUMP */
0, /* BRANCH */
@@ -613,78 +621,80 @@ EXTCONST char * const PL_reg_name[] = {
"NSPACEA", /* 0x26 */
"DIGIT", /* 0x27 */
"DIGITL", /* 0x28 */
- "DIGITA", /* 0x29 */
- "NDIGIT", /* 0x2a */
- "NDIGITL", /* 0x2b */
- "NDIGITA", /* 0x2c */
- "CLUMP", /* 0x2d */
- "BRANCH", /* 0x2e */
- "BACK", /* 0x2f */
- "EXACT", /* 0x30 */
- "EXACTF", /* 0x31 */
- "EXACTFL", /* 0x32 */
- "EXACTFU", /* 0x33 */
- "EXACTFA", /* 0x34 */
- "EXACTFU_SS", /* 0x35 */
- "EXACTFU_TRICKYFOLD", /* 0x36 */
- "NOTHING", /* 0x37 */
- "TAIL", /* 0x38 */
- "STAR", /* 0x39 */
- "PLUS", /* 0x3a */
- "CURLY", /* 0x3b */
- "CURLYN", /* 0x3c */
- "CURLYM", /* 0x3d */
- "CURLYX", /* 0x3e */
- "WHILEM", /* 0x3f */
- "OPEN", /* 0x40 */
- "CLOSE", /* 0x41 */
- "REF", /* 0x42 */
- "REFF", /* 0x43 */
- "REFFL", /* 0x44 */
- "REFFU", /* 0x45 */
- "REFFA", /* 0x46 */
- "NREF", /* 0x47 */
- "NREFF", /* 0x48 */
- "NREFFL", /* 0x49 */
- "NREFFU", /* 0x4a */
- "NREFFA", /* 0x4b */
- "IFMATCH", /* 0x4c */
- "UNLESSM", /* 0x4d */
- "SUSPEND", /* 0x4e */
- "IFTHEN", /* 0x4f */
- "GROUPP", /* 0x50 */
- "LONGJMP", /* 0x51 */
- "BRANCHJ", /* 0x52 */
- "EVAL", /* 0x53 */
- "MINMOD", /* 0x54 */
- "LOGICAL", /* 0x55 */
- "RENUM", /* 0x56 */
- "TRIE", /* 0x57 */
- "TRIEC", /* 0x58 */
- "AHOCORASICK", /* 0x59 */
- "AHOCORASICKC", /* 0x5a */
- "GOSUB", /* 0x5b */
- "GOSTART", /* 0x5c */
- "NGROUPP", /* 0x5d */
- "INSUBP", /* 0x5e */
- "DEFINEP", /* 0x5f */
- "ENDLIKE", /* 0x60 */
- "OPFAIL", /* 0x61 */
- "ACCEPT", /* 0x62 */
- "VERB", /* 0x63 */
- "PRUNE", /* 0x64 */
- "MARKPOINT", /* 0x65 */
- "SKIP", /* 0x66 */
- "COMMIT", /* 0x67 */
- "CUTGROUP", /* 0x68 */
- "KEEPS", /* 0x69 */
- "LNBREAK", /* 0x6a */
- "VERTWS", /* 0x6b */
- "NVERTWS", /* 0x6c */
- "HORIZWS", /* 0x6d */
- "NHORIZWS", /* 0x6e */
- "OPTIMIZED", /* 0x6f */
- "PSEUDO", /* 0x70 */
+ "PLACEHOLDER1", /* 0x29 */
+ "DIGITA", /* 0x2a */
+ "NDIGIT", /* 0x2b */
+ "NDIGITL", /* 0x2c */
+ "PLACEHOLDER2", /* 0x2d */
+ "NDIGITA", /* 0x2e */
+ "CLUMP", /* 0x2f */
+ "BRANCH", /* 0x30 */
+ "BACK", /* 0x31 */
+ "EXACT", /* 0x32 */
+ "EXACTF", /* 0x33 */
+ "EXACTFL", /* 0x34 */
+ "EXACTFU", /* 0x35 */
+ "EXACTFA", /* 0x36 */
+ "EXACTFU_SS", /* 0x37 */
+ "EXACTFU_TRICKYFOLD", /* 0x38 */
+ "NOTHING", /* 0x39 */
+ "TAIL", /* 0x3a */
+ "STAR", /* 0x3b */
+ "PLUS", /* 0x3c */
+ "CURLY", /* 0x3d */
+ "CURLYN", /* 0x3e */
+ "CURLYM", /* 0x3f */
+ "CURLYX", /* 0x40 */
+ "WHILEM", /* 0x41 */
+ "OPEN", /* 0x42 */
+ "CLOSE", /* 0x43 */
+ "REF", /* 0x44 */
+ "REFF", /* 0x45 */
+ "REFFL", /* 0x46 */
+ "REFFU", /* 0x47 */
+ "REFFA", /* 0x48 */
+ "NREF", /* 0x49 */
+ "NREFF", /* 0x4a */
+ "NREFFL", /* 0x4b */
+ "NREFFU", /* 0x4c */
+ "NREFFA", /* 0x4d */
+ "IFMATCH", /* 0x4e */
+ "UNLESSM", /* 0x4f */
+ "SUSPEND", /* 0x50 */
+ "IFTHEN", /* 0x51 */
+ "GROUPP", /* 0x52 */
+ "LONGJMP", /* 0x53 */
+ "BRANCHJ", /* 0x54 */
+ "EVAL", /* 0x55 */
+ "MINMOD", /* 0x56 */
+ "LOGICAL", /* 0x57 */
+ "RENUM", /* 0x58 */
+ "TRIE", /* 0x59 */
+ "TRIEC", /* 0x5a */
+ "AHOCORASICK", /* 0x5b */
+ "AHOCORASICKC", /* 0x5c */
+ "GOSUB", /* 0x5d */
+ "GOSTART", /* 0x5e */
+ "NGROUPP", /* 0x5f */
+ "INSUBP", /* 0x60 */
+ "DEFINEP", /* 0x61 */
+ "ENDLIKE", /* 0x62 */
+ "OPFAIL", /* 0x63 */
+ "ACCEPT", /* 0x64 */
+ "VERB", /* 0x65 */
+ "PRUNE", /* 0x66 */
+ "MARKPOINT", /* 0x67 */
+ "SKIP", /* 0x68 */
+ "COMMIT", /* 0x69 */
+ "CUTGROUP", /* 0x6a */
+ "KEEPS", /* 0x6b */
+ "LNBREAK", /* 0x6c */
+ "VERTWS", /* 0x6d */
+ "NVERTWS", /* 0x6e */
+ "HORIZWS", /* 0x6f */
+ "NHORIZWS", /* 0x70 */
+ "OPTIMIZED", /* 0x71 */
+ "PSEUDO", /* 0x72 */
/* ------------ States ------------- */
"TRIE_next", /* REGNODE_MAX +0x01 */
"TRIE_next_fail", /* REGNODE_MAX +0x02 */
@@ -789,7 +799,7 @@ EXTCONST U8 PL_varies[] __attribute__deprecated__ = {
EXTCONST U8 PL_varies_bitmask[];
#else
EXTCONST U8 PL_varies_bitmask[] = {
- 0x00, 0x00, 0x40, 0x00, 0x00, 0xE0, 0x00, 0xFE, 0xFC, 0xCF, 0x04, 0x00, 0x00, 0x00, 0x00
+ 0x00, 0x00, 0x40, 0x00, 0x00, 0x80, 0x03, 0xF8, 0xF3, 0x3F, 0x13, 0x00, 0x00, 0x00, 0x00
};
#endif /* DOINIT */
@@ -813,7 +823,7 @@ EXTCONST U8 PL_simple[] __attribute__deprecated__ = {
EXTCONST U8 PL_simple_bitmask[];
#else
EXTCONST U8 PL_simple_bitmask[] = {
- 0x00, 0x00, 0xBC, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00
+ 0x00, 0x00, 0xBC, 0xFF, 0xFF, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x01
};
#endif /* DOINIT */