summaryrefslogtreecommitdiff
path: root/regnodes.h
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2023-01-15 13:00:46 +0100
committerYves Orton <demerphq@gmail.com>2023-03-13 21:26:08 +0800
commit17e3e02ad120eabda2bdb6c297a70d53294437ef (patch)
tree6fc99228c2a34c7ee5ec892de4c1f1a980e2f240 /regnodes.h
parent59db194299c94c6707095797c3df0e2f67ff82b2 (diff)
downloadperl-17e3e02ad120eabda2bdb6c297a70d53294437ef.tar.gz
regex engine - simplify regnode structures and make them consistent
This eliminates the regnode_2L data structure, and merges it with the older regnode_2 data structure. At the same time it makes each "arg" property of the various regnode types that have one be consistently structured as an anonymous union like this: union { U32 arg1u; I32 arg2i; struct { U16 arg1a; U16 arg1b; }; }; We then expose four macros for accessing each slot: ARG1u() ARG1i() and ARG1a() and ARG1b(). Code then explicitly designates which they want. The old logic used ARG() to access an U32 arg1, and ARG1() to access an I32 arg1, which was confusing to say the least. The regnode_2L structure had a U32 arg1, and I32 arg2, and the regnode_2 data strucutre had two I32 args. With the new set of macros we use the regnode_2 for both, and use the appropriate macros to show whether we want to signed or unsigned values. This also renames the regnode_4 to regnode_3. The 3 stands for "three 32-bit args". However as each slot can also store two U16s, a regnode_3 can hold up to 6 U16s, or as 3 I32's, or a combination. For instance the CURLY style nodes use regnode_3 to store 4 values, ARG1i() for min count, ARG2i() for max count and ARG3a() and ARG3b() for parens before and inside the quantifier. It also changes the functions reganode() to reg1node() and changes reg2Lanode() to reg2node(). The 2L thing was just confusing.
Diffstat (limited to 'regnodes.h')
-rw-r--r--regnodes.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/regnodes.h b/regnodes.h
index 77e8e66c0a..a675874378 100644
--- a/regnodes.h
+++ b/regnodes.h
@@ -10,7 +10,7 @@
/* typedefs for regex nodes - one typedef per node type */
-typedef struct regnode_2L tregnode_ACCEPT;
+typedef struct regnode_2 tregnode_ACCEPT;
typedef struct regnode_1 tregnode_AHOCORASICK;
typedef struct regnode_charclass tregnode_AHOCORASICKC;
typedef struct regnode_charclass tregnode_ANYOF;
@@ -30,20 +30,20 @@ typedef struct regnode tregnode_BOUNDA;
typedef struct regnode tregnode_BOUNDL;
typedef struct regnode tregnode_BOUNDU;
typedef struct regnode_1 tregnode_BRANCH;
-typedef struct regnode_2L tregnode_BRANCHJ;
+typedef struct regnode_2 tregnode_BRANCHJ;
typedef struct regnode_1 tregnode_CLOSE;
typedef struct regnode tregnode_CLUMP;
typedef struct regnode_1 tregnode_COMMIT;
-typedef struct regnode_4 tregnode_CURLY;
-typedef struct regnode_4 tregnode_CURLYM;
-typedef struct regnode_4 tregnode_CURLYN;
-typedef struct regnode_4 tregnode_CURLYX;
+typedef struct regnode_3 tregnode_CURLY;
+typedef struct regnode_3 tregnode_CURLYM;
+typedef struct regnode_3 tregnode_CURLYN;
+typedef struct regnode_3 tregnode_CURLYX;
typedef struct regnode_1 tregnode_CUTGROUP;
typedef struct regnode_1 tregnode_DEFINEP;
typedef struct regnode tregnode_END;
typedef struct regnode tregnode_ENDLIKE;
typedef struct regnode tregnode_EOS;
-typedef struct regnode_2L tregnode_EVAL;
+typedef struct regnode_2 tregnode_EVAL;
typedef struct regnode tregnode_EXACT;
typedef struct regnode tregnode_EXACTF;
typedef struct regnode tregnode_EXACTFAA;
@@ -56,7 +56,7 @@ typedef struct regnode tregnode_EXACTFU_REQ8;
typedef struct regnode tregnode_EXACTFU_S_EDGE;
typedef struct regnode tregnode_EXACTL;
typedef struct regnode tregnode_EXACT_REQ8;
-typedef struct regnode_2L tregnode_GOSUB;
+typedef struct regnode_2 tregnode_GOSUB;
typedef struct regnode tregnode_GPOS;
typedef struct regnode_1 tregnode_GROUPP;
typedef struct regnode_1 tregnode_GROUPPN;