VirtualBox

source: kBuild/vendor/grep/2.12/src/dfa.h@ 2595

Last change on this file since 2595 was 2595, checked in by bird, 12 years ago

gnu grep version 2.12 (grep-2.12.tar.xz, md5sum=8d2f0346d08b13c18afb81f0e8aa1e2f)

  • Property svn:eol-style set to native
File size: 4.1 KB
Line 
1/* dfa.h - declarations for GNU deterministic regexp compiler
2 Copyright (C) 1988, 1998, 2007, 2009-2012 Free Software Foundation, Inc.
3
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 3, or (at your option)
7 any later version.
8
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.
13
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.,
17 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA */
18
19/* Written June, 1988 by Mike Haertel */
20
21/* Element of a list of strings, at least one of which is known to
22 appear in any R.E. matching the DFA. */
23struct dfamust
24{
25 int exact;
26 char *must;
27 struct dfamust *next;
28};
29
30/* The dfa structure. It is completely opaque. */
31struct dfa;
32
33/* Entry points. */
34
35/* Allocate a struct dfa. The struct dfa is completely opaque.
36 The returned pointer should be passed directly to free() after
37 calling dfafree() on it. */
38extern struct dfa *dfaalloc (void);
39
40/* Return the dfamusts associated with a dfa. */
41extern struct dfamust *dfamusts (struct dfa const *);
42
43/* dfasyntax() takes three arguments; the first sets the syntax bits described
44 earlier in this file, the second sets the case-folding flag, and the
45 third specifies the line terminator. */
46extern void dfasyntax (reg_syntax_t, int, unsigned char);
47
48/* Compile the given string of the given length into the given struct dfa.
49 Final argument is a flag specifying whether to build a searching or an
50 exact matcher. */
51extern void dfacomp (char const *, size_t, struct dfa *, int);
52
53/* Search through a buffer looking for a match to the given struct dfa.
54 Find the first occurrence of a string matching the regexp in the
55 buffer, and the shortest possible version thereof. Return a pointer to
56 the first character after the match, or NULL if none is found. BEGIN
57 points to the beginning of the buffer, and END points to the first byte
58 after its end. Note however that we store a sentinel byte (usually
59 newline) in *END, so the actual buffer must be one byte longer.
60 When NEWLINE is nonzero, newlines may appear in the matching string.
61 If COUNT is non-NULL, increment *COUNT once for each newline processed.
62 Finally, if BACKREF is non-NULL set *BACKREF to indicate whether we
63 encountered a back-reference (1) or not (0). The caller may use this
64 to decide whether to fall back on a backtracking matcher. */
65extern char *dfaexec (struct dfa *d, char const *begin, char *end,
66 int newline, size_t *count, int *backref);
67
68/* Free the storage held by the components of a struct dfa. */
69extern void dfafree (struct dfa *);
70
71/* Entry points for people who know what they're doing. */
72
73/* Initialize the components of a struct dfa. */
74extern void dfainit (struct dfa *);
75
76/* Incrementally parse a string of given length into a struct dfa. */
77extern void dfaparse (char const *, size_t, struct dfa *);
78
79/* Analyze a parsed regexp; second argument tells whether to build a searching
80 or an exact matcher. */
81extern void dfaanalyze (struct dfa *, int);
82
83/* Compute, for each possible character, the transitions out of a given
84 state, storing them in an array of integers. */
85extern void dfastate (ptrdiff_t, struct dfa *, ptrdiff_t []);
86
87/* Error handling. */
88
89/* dfawarn() is called by the regexp routines whenever a regex is compiled
90 that likely doesn't do what the user wanted. It takes a single
91 argument, a NUL-terminated string describing the situation. The user
92 must supply a dfawarn. */
93extern void dfawarn (const char *);
94
95/* dfaerror() is called by the regexp routines whenever an error occurs. It
96 takes a single argument, a NUL-terminated string describing the error.
97 The user must supply a dfaerror. */
98extern _Noreturn void dfaerror (const char *);
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette