1 /* Definitions for data structures callers pass the regex library.
2 Copyright (C) 1985, 1989 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
18 /* Define number of parens for which we record the beginnings and ends.
19 This affects how much space the `struct re_registers' type takes up. */
24 /* These bits are used in the obscure_syntax variable to choose among
25 alternative regexp syntaxes. */
27 /* 1 means plain parentheses serve as grouping, and backslash
28 parentheses are needed for literal searching.
29 0 means backslash-parentheses are grouping, and plain parentheses
30 are for literal searching. */
31 #define RE_NO_BK_PARENS 1
33 /* 1 means plain | serves as the "or"-operator, and \| is a literal.
34 0 means \| serves as the "or"-operator, and | is a literal. */
35 #define RE_NO_BK_VBAR 2
37 /* 0 means plain + or ? serves as an operator, and \+, \? are literals.
38 1 means \+, \? are operators and plain +, ? are literals. */
39 #define RE_BK_PLUS_QM 4
41 /* 1 means | binds tighter than ^ or $.
42 0 means the contrary. */
43 #define RE_TIGHT_VBAR 8
45 /* 1 means treat \n as an _OR operator
46 0 means treat it as a normal character */
47 #define RE_NEWLINE_OR 16
49 /* 0 means that a special characters (such as *, ^, and $) always have
50 their special meaning regardless of the surrounding context.
51 1 means that special characters may act as normal characters in some
52 contexts. Specifically, this applies to:
53 ^ - only special at the beginning, or after ( or |
54 $ - only special at the end, or before ) or |
55 *, +, ? - only special when not after the beginning, (, or | */
56 #define RE_CONTEXT_INDEP_OPS 32
58 /* Now define combinations of bits for the standard possibilities. */
59 #define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
60 #define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR)
61 #define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
62 #define RE_SYNTAX_EMACS 0
64 /* This data structure is used to represent a compiled pattern. */
66 struct re_pattern_buffer
68 char *buffer
; /* Space holding the compiled pattern commands. */
69 int allocated
; /* Size of space that buffer points to */
70 int used
; /* Length of portion of buffer actually occupied */
71 char *fastmap
; /* Pointer to fastmap, if any, or zero if none. */
72 /* re_search uses the fastmap, if there is one,
73 to skip quickly over totally implausible characters */
74 char *translate
; /* Translate table to apply to all characters before comparing.
75 Or zero for no translation.
76 The translation is applied to a pattern when it is compiled
77 and to data when it is matched. */
78 char fastmap_accurate
;
79 /* Set to zero when a new pattern is stored,
80 set to one when the fastmap is updated from it. */
81 char can_be_null
; /* Set to one by compiling fastmap
82 if this pattern might match the null string.
83 It does not necessarily match the null string
84 in that case, but if this is zero, it cannot.
85 2 as value means can match null string
86 but at end of range or before a character
87 listed in the fastmap. */
90 /* Structure to store "register" contents data in.
92 Pass the address of such a structure as an argument to re_match, etc.,
93 if you want this information back.
95 start[i] and end[i] record the string matched by \( ... \) grouping i,
96 for i from 1 to RE_NREGS - 1.
97 start[0] and end[0] record the entire string matched. */
105 /* These are the command codes that appear in compiled regular expressions, one per byte.
106 Some command codes are followed by argument bytes.
107 A command code can specify any interpretation whatever for its arguments.
108 Zero-bytes may appear in the compiled regular expression. */
113 exactn
, /* followed by one byte giving n, and then by n literal bytes */
114 begline
, /* fails unless at beginning of line */
115 endline
, /* fails unless at end of line */
116 jump
, /* followed by two bytes giving relative address to jump to */
117 on_failure_jump
, /* followed by two bytes giving relative address of place
118 to resume at in case of failure. */
119 finalize_jump
, /* Throw away latest failure point and then jump to address. */
120 maybe_finalize_jump
, /* Like jump but finalize if safe to do so.
121 This is used to jump back to the beginning
122 of a repeat. If the command that follows
123 this jump is clearly incompatible with the
124 one at the beginning of the repeat, such that
125 we can be sure that there is no use backtracking
126 out of repetitions already completed,
128 dummy_failure_jump
, /* jump, and push a dummy failure point.
129 This failure point will be thrown away
130 if an attempt is made to use it for a failure.
131 A + construct makes this before the first repeat. */
132 anychar
, /* matches any one character */
133 charset
, /* matches any one char belonging to specified set.
134 First following byte is # bitmap bytes.
135 Then come bytes for a bit-map saying which chars are in.
136 Bits in each byte are ordered low-bit-first.
137 A character is in the set if its bit is 1.
138 A character too large to have a bit in the map
139 is automatically not in the set */
140 charset_not
, /* similar but match any character that is NOT one of those specified */
141 start_memory
, /* starts remembering the text that is matched
142 and stores it in a memory register.
143 followed by one byte containing the register number.
144 Register numbers must be in the range 0 through NREGS. */
145 stop_memory
, /* stops remembering the text that is matched
146 and stores it in a memory register.
147 followed by one byte containing the register number.
148 Register numbers must be in the range 0 through NREGS. */
149 duplicate
, /* match a duplicate of something remembered.
150 Followed by one byte containing the index of the memory register. */
151 before_dot
, /* Succeeds if before dot */
152 at_dot
, /* Succeeds if at dot */
153 after_dot
, /* Succeeds if after dot */
154 begbuf
, /* Succeeds if at beginning of buffer */
155 endbuf
, /* Succeeds if at end of buffer */
156 wordchar
, /* Matches any word-constituent character */
157 notwordchar
, /* Matches any char that is not a word-constituent */
158 wordbeg
, /* Succeeds if at word beginning */
159 wordend
, /* Succeeds if at word end */
160 wordbound
, /* Succeeds if at a word boundary */
161 notwordbound
, /* Succeeds if not at a word boundary */
162 syntaxspec
, /* Matches any character whose syntax is specified.
163 followed by a byte which contains a syntax code, Sword or such like */
164 notsyntaxspec
/* Matches any character whose syntax differs from the specified. */
167 extern char *re_compile_pattern ();
168 /* Is this really advertised? */
169 extern void re_compile_fastmap ();
170 extern int re_search (), re_search_2 ();
171 extern int re_match (), re_match_2 ();
173 /* 4.2 bsd compatibility (yuck) */
174 extern char *re_comp ();
175 extern int re_exec ();
178 extern char *re_syntax_table
;
181 extern int re_set_syntax ();
This page took 0.0335 seconds and 4 git commands to generate.