This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Typo in utf8.h
[perl5.git] / regexp.h
CommitLineData
a0d0e21e
LW
1/* regexp.h
2 */
3
378cc40b
LW
4/*
5 * Definitions etc. for regexp(3) routines.
6 *
7 * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
8 * not the System V one.
9 */
10
378cc40b 11
c277df42
IZ
12struct regnode {
13 U8 flags;
14 U8 type;
15 U16 next_off;
16};
17
18typedef struct regnode regnode;
19
cad2e5aa 20struct reg_substr_data;
2779dcf1 21
0ee3c8d0
JH
22struct reg_data;
23
378cc40b 24typedef struct regexp {
cf93c79d
IZ
25 I32 *startp;
26 I32 *endp;
c277df42 27 regnode *regstclass;
2779dcf1 28 struct reg_substr_data *substrs;
cf93c79d 29 char *precomp; /* pre-compilation regular expression */
c277df42 30 struct reg_data *data; /* Additional data. */
cf93c79d
IZ
31 char *subbeg; /* saved or original string
32 so \digit works forever. */
33 I32 sublen; /* Length of string pointed by subbeg */
34 I32 refcnt;
35 I32 minlen; /* mininum possible length of $& */
36 I32 prelen; /* length of precomp */
37 U32 nparens; /* number of parentheses */
38 U32 lastparen; /* last paren matched */
39 U32 reganch; /* Internal use only +
40 Tainted information used by regexec? */
c277df42 41 regnode program[1]; /* Unwarranted chumminess with compiler. */
378cc40b
LW
42} regexp;
43
cad2e5aa
JH
44#define ROPT_ANCH (ROPT_ANCH_BOL|ROPT_ANCH_MBOL|ROPT_ANCH_GPOS|ROPT_ANCH_SBOL)
45#define ROPT_ANCH_SINGLE (ROPT_ANCH_SBOL|ROPT_ANCH_GPOS)
a0ed51b3
LW
46#define ROPT_ANCH_BOL 0x00001
47#define ROPT_ANCH_MBOL 0x00002
cad2e5aa
JH
48#define ROPT_ANCH_SBOL 0x00004
49#define ROPT_ANCH_GPOS 0x00008
50#define ROPT_SKIP 0x00010
51#define ROPT_IMPLICIT 0x00020 /* Converted .* to ^.* */
52#define ROPT_NOSCAN 0x00040 /* Check-string always at start. */
53#define ROPT_GPOS_SEEN 0x00080
54#define ROPT_CHECK_ALL 0x00100
55#define ROPT_LOOKBEHIND_SEEN 0x00200
56#define ROPT_EVAL_SEEN 0x00400
3baa4c62 57#define ROPT_SANY_SEEN 0x00800
a0ed51b3 58
8782bef2 59/* 0xf800 of reganch is used by PMf_COMPILETIME */
c277df42 60
a0ed51b3
LW
61#define ROPT_UTF8 0x10000
62#define ROPT_NAUGHTY 0x20000 /* how exponential is this pattern? */
cf93c79d 63#define ROPT_COPY_DONE 0x40000 /* subbeg is a copy of the string */
bc9a0d2c 64#define ROPT_TAINTED_SEEN 0x80000
a0ed51b3 65
cad2e5aa
JH
66#define RE_USE_INTUIT_NOML 0x0100000 /* Best to intuit before matching */
67#define RE_USE_INTUIT_ML 0x0200000
68#define REINT_AUTORITATIVE_NOML 0x0400000 /* Can trust a positive answer */
69#define REINT_AUTORITATIVE_ML 0x0800000
70#define REINT_ONCE_NOML 0x1000000 /* Intuit can succed once only. */
71#define REINT_ONCE_ML 0x2000000
72#define RE_INTUIT_ONECHAR 0x4000000
73#define RE_INTUIT_TAIL 0x8000000
74
75#define RE_USE_INTUIT (RE_USE_INTUIT_NOML|RE_USE_INTUIT_ML)
76#define REINT_AUTORITATIVE (REINT_AUTORITATIVE_NOML|REINT_AUTORITATIVE_ML)
77#define REINT_ONCE (REINT_ONCE_NOML|REINT_ONCE_ML)
78
c277df42 79#define RX_MATCH_TAINTED(prog) ((prog)->reganch & ROPT_TAINTED_SEEN)
72311751
GS
80#define RX_MATCH_TAINTED_on(prog) ((prog)->reganch |= ROPT_TAINTED_SEEN)
81#define RX_MATCH_TAINTED_off(prog) ((prog)->reganch &= ~ROPT_TAINTED_SEEN)
82#define RX_MATCH_TAINTED_set(prog, t) ((t) \
83 ? RX_MATCH_TAINTED_on(prog) \
84 : RX_MATCH_TAINTED_off(prog))
c277df42 85
cf93c79d
IZ
86#define RX_MATCH_COPIED(prog) ((prog)->reganch & ROPT_COPY_DONE)
87#define RX_MATCH_COPIED_on(prog) ((prog)->reganch |= ROPT_COPY_DONE)
88#define RX_MATCH_COPIED_off(prog) ((prog)->reganch &= ~ROPT_COPY_DONE)
89#define RX_MATCH_COPIED_set(prog,t) ((t) \
90 ? RX_MATCH_COPIED_on(prog) \
91 : RX_MATCH_COPIED_off(prog))
92
cad2e5aa
JH
93#define REXEC_COPY_STR 0x01 /* Need to copy the string. */
94#define REXEC_CHECKED 0x02 /* check_substr already checked. */
95#define REXEC_SCREAM 0x04 /* use scream table. */
96#define REXEC_IGNOREPOS 0x08 /* \G matches at start. */
cf93c79d 97#define REXEC_NOT_FIRST 0x10 /* This is another iteration of //g. */
cad2e5aa 98#define REXEC_ML 0x20 /* $* was set. */
c277df42 99
155aba94 100#define ReREFCNT_inc(re) ((void)(re && re->refcnt++), re)
cad2e5aa 101#define ReREFCNT_dec(re) CALLREGFREE(aTHX_ re)
cf93c79d
IZ
102
103#define FBMcf_TAIL_DOLLAR 1
cad2e5aa
JH
104#define FBMcf_TAIL_DOLLARM 2
105#define FBMcf_TAIL_Z 4
106#define FBMcf_TAIL_z 8
107#define FBMcf_TAIL (FBMcf_TAIL_DOLLAR|FBMcf_TAIL_DOLLARM|FBMcf_TAIL_Z|FBMcf_TAIL_z)
cf93c79d
IZ
108
109#define FBMrf_MULTILINE 1
cad2e5aa
JH
110
111struct re_scream_pos_data_s;