This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Let's undocument -Dusesfio in INSTALL.
[perl5.git] / regcomp.h
index b4f549f..f7082bf 100644 (file)
--- a/regcomp.h
+++ b/regcomp.h
@@ -15,6 +15,12 @@ typedef OP OP_4tree;                 /* Will be redefined later. */
 #define PERL_ENABLE_EXTENDED_TRIE_OPTIMISATION 1
 #define PERL_ENABLE_POSITIVE_ASSERTION_STUDY 1
 #define PERL_ENABLE_EXPERIMENTAL_REGEX_OPTIMISATIONS 0
+/* Unless the next line is uncommented it is illegal to combine lazy 
+   matching with possessive matching. Frankly it doesn't make much sense 
+   to allow it as X*?+ matches nothing, X+?+ matches a single char only, 
+   and X{min,max}?+ matches min times only.
+ */
+/* #define REG_ALLOW_MINMOD_SUSPEND */
 
 /*
  * The "internal use only" fields in regexp.h are present to pass info from
@@ -86,6 +92,8 @@ struct regnode_string {
     char string[1];
 };
 
+/* Argument bearing node - workhorse, 
+   arg1 is often for the data field */
 struct regnode_1 {
     U8 flags;
     U8  type;
@@ -93,6 +101,16 @@ struct regnode_1 {
     U32 arg1;
 };
 
+/* Similar to a regnode_1 but with an extra signed argument */
+struct regnode_2L {
+    U8 flags;
+    U8  type;
+    U16 next_off;
+    U32 arg1;
+    I32 arg2;
+};
+
+/* 'Two field' -- Two 16 bit unsigned args */
 struct regnode_2 {
     U8 flags;
     U8  type;
@@ -101,6 +119,7 @@ struct regnode_2 {
     U16 arg2;
 };
 
+
 #define ANYOF_BITMAP_SIZE      32      /* 256 b/(8 b/B) */
 #define ANYOF_CLASSBITMAP_SIZE  4      /* up to 32 (8*4) named classes */
 
@@ -154,10 +173,12 @@ struct regnode_charclass_class {  /* has [[:blah:]] classes */
 #define ARG(p) ARG_VALUE(ARG_LOC(p))
 #define ARG1(p) ARG_VALUE(ARG1_LOC(p))
 #define ARG2(p) ARG_VALUE(ARG2_LOC(p))
+#define ARG2L(p) ARG_VALUE(ARG2L_LOC(p))
 
 #define ARG_SET(p, val) ARG__SET(ARG_LOC(p), (val))
 #define ARG1_SET(p, val) ARG__SET(ARG1_LOC(p), (val))
 #define ARG2_SET(p, val) ARG__SET(ARG2_LOC(p), (val))
+#define ARG2L_SET(p, val) ARG__SET(ARG2L_LOC(p), (val))
 
 #undef NEXT_OFF
 #undef NODE_ALIGN
@@ -190,7 +211,7 @@ struct regnode_charclass_class {    /* has [[:blah:]] classes */
 #define        ARG_LOC(p)      (((struct regnode_1 *)p)->arg1)
 #define        ARG1_LOC(p)     (((struct regnode_2 *)p)->arg1)
 #define        ARG2_LOC(p)     (((struct regnode_2 *)p)->arg2)
-
+#define ARG2L_LOC(p)   (((struct regnode_2L *)p)->arg2)
 
 #define NODE_STEP_REGNODE      1       /* sizeof(regnode)/sizeof(regnode) */
 #define EXTRA_STEP_2ARGS       EXTRA_SIZE(struct regnode_2)
@@ -328,6 +349,8 @@ struct regnode_charclass_class {    /* has [[:blah:]] classes */
 #define REG_SEEN_EVAL          0x00000008
 #define REG_SEEN_CANY          0x00000010
 #define REG_SEEN_SANY          REG_SEEN_CANY /* src bckwrd cmpt */
+#define REG_SEEN_RECURSE        0x00000020
+#define REG_TOP_LEVEL_BRANCHES  0x00000040
 
 START_EXTERN_C
 
@@ -364,13 +387,26 @@ EXTCONST U8 PL_simple[] = {
 };
 #endif
 
+#ifndef PLUGGABLE_RE_EXTENSION
+#ifndef DOINIT
+EXTCONST regexp_engine PL_core_reg_engine;
+#else /* DOINIT */
+EXTCONST regexp_engine PL_core_reg_engine = { 
+        Perl_pregcomp, 
+        Perl_regexec_flags, 
+        Perl_re_intuit_start,
+        Perl_re_intuit_string, 
+        Perl_pregfree, 
+#if defined(USE_ITHREADS)        
+        Perl_regdupe 
+#endif        
+};
+#endif /* DOINIT */
+#endif /* PLUGGABLE_RE_EXTENSION */
+
+
 END_EXTERN_C
 
-typedef struct re_scream_pos_data_s
-{
-    char **scream_olds;                /* match pos */
-    I32 *scream_pos;           /* Internal iterator of scream. */
-} re_scream_pos_data;
 
 /* .what is a character array with one character for each member of .data
  * The character describes the function of the corresponding .data item:
@@ -383,6 +419,7 @@ typedef struct re_scream_pos_data_s
  *       in the character class
  *   t - trie struct
  *   T - aho-trie struct
+ *   S - sv for named capture lookup
  * 20010712 mjd@plover.com
  * (Remember to update re_dup() and pregfree() if you add any items.)
  */
@@ -482,7 +519,8 @@ struct _reg_trie_data {
                                         for the node following a given word. */
     U16                    *nextword;       /* optional 1 indexed array to support linked list
                                         of duplicate wordnums */
-    U32             laststate;       /* Build only */
+    U32             statecount;      /* Build only - number of states in the states array 
+                                        (including the unused zero state) */
     U32             wordcount;       /* Build only */
 #ifdef DEBUGGING
     STRLEN          charcount;       /* Build only */
@@ -572,7 +610,6 @@ re.pm, especially to the documentation.
 #define RE_DEBUG_COMPILE_OPTIMISE  0x000002
 #define RE_DEBUG_COMPILE_TRIE      0x000004
 #define RE_DEBUG_COMPILE_DUMP      0x000008
-#define RE_DEBUG_COMPILE_OFFSETS   0x000010
 
 /* Execute */
 #define RE_DEBUG_EXECUTE_MASK      0x00FF00
@@ -584,7 +621,9 @@ re.pm, especially to the documentation.
 #define RE_DEBUG_EXTRA_MASK        0xFF0000
 #define RE_DEBUG_EXTRA_TRIE        0x010000
 #define RE_DEBUG_EXTRA_OFFSETS     0x020000
-#define RE_DEBUG_EXTRA_STATE       0x040000
+#define RE_DEBUG_EXTRA_OFFDEBUG    0x040000
+#define RE_DEBUG_EXTRA_STATE       0x080000
+#define RE_DEBUG_EXTRA_OPTIMISE    0x100000
 
 #define RE_DEBUG_FLAG(x) (re_debug_flags & x)
 /* Compile */
@@ -598,8 +637,6 @@ re.pm, especially to the documentation.
     if (re_debug_flags & RE_DEBUG_COMPILE_PARSE) x  )
 #define DEBUG_DUMP_r(x) DEBUG_r( \
     if (re_debug_flags & RE_DEBUG_COMPILE_DUMP) x  )
-#define DEBUG_OFFSETS_r(x) DEBUG_r( \
-    if (re_debug_flags & RE_DEBUG_COMPILE_OFFSETS) x  )
 #define DEBUG_TRIE_COMPILE_r(x) DEBUG_r( \
     if (re_debug_flags & RE_DEBUG_COMPILE_TRIE) x )
 
@@ -616,10 +653,15 @@ re.pm, especially to the documentation.
 /* Extra */
 #define DEBUG_EXTRA_r(x) DEBUG_r( \
     if (re_debug_flags & RE_DEBUG_EXTRA_MASK) x  )
+#define DEBUG_OFFSETS_r(x) DEBUG_r( \
+    if (re_debug_flags & RE_DEBUG_EXTRA_OFFSETS) x  )
 #define DEBUG_STATE_r(x) DEBUG_r( \
     if (re_debug_flags & RE_DEBUG_EXTRA_STATE) x )
+#define DEBUG_OPTIMISE_MORE_r(x) DEBUG_r( \
+    if ((RE_DEBUG_EXTRA_OPTIMISE|RE_DEBUG_COMPILE_OPTIMISE) == \
+         (re_debug_flags & (RE_DEBUG_EXTRA_OPTIMISE|RE_DEBUG_COMPILE_OPTIMISE)) ) x )
 #define MJD_OFFSET_DEBUG(x) DEBUG_r( \
-    if (re_debug_flags & RE_DEBUG_EXTRA_OFFSETS) \
+    if (re_debug_flags & RE_DEBUG_EXTRA_OFFDEBUG) \
         Perl_warn_nocontext x )
 #define DEBUG_TRIE_COMPILE_MORE_r(x) DEBUG_TRIE_COMPILE_r( \
     if (re_debug_flags & RE_DEBUG_EXTRA_TRIE) x )