Fix for SF bug #1122813: Tab-related crash on posting unload calltips file
[nedit.git] / source / regularExp.h
blobd87e7e11053ea03fea1700d21258cc35c8f742c0
1 /* $Id: regularExp.h,v 1.13 2004/11/26 18:25:51 edg Exp $ */
2 /*******************************************************************************
3 * *
4 * regularExp.h -- Nirvana Editor Regular Expression Package Header File *
5 * *
6 * Copyright 2002 The NEdit Developers *
7 * *
8 * This is free software; you can redistribute it and/or modify it under the *
9 * terms of the GNU General Public License as published by the Free Software *
10 * Foundation; either version 2 of the License, or (at your option) any later *
11 * version. In addition, you may distribute versions of this program linked to *
12 * Motif or Open Motif. See README for details. *
13 * *
14 * This software is distributed in the hope that it will be useful, but WITHOUT *
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
17 * more details. *
18 * *
19 * You should have received a copy of the GNU General Public License along with *
20 * software; if not, write to the Free Software Foundation, Inc., 59 Temple *
21 * Place, Suite 330, Boston, MA 02111-1307 USA *
22 * *
23 * Nirvana Text Editor *
24 * July 31, 2001 *
25 * *
26 *******************************************************************************/
28 #ifndef NEDIT_REGULAREXP_H_INCLUDED
29 #define NEDIT_REGULAREXP_H_INCLUDED
31 /* Number of text capturing parentheses allowed. */
33 #define NSUBEXP 50
35 /* Structure to contain the compiled form of a regular expression plus
36 pointers to matched text. `program' is the actual compiled regex code. */
38 typedef struct regexp {
39 char *startp [NSUBEXP]; /* Captured text starting locations. */
40 char *endp [NSUBEXP]; /* Captured text ending locations. */
41 char *extentpBW; /* Points to the maximum extent of text scanned by
42 ExecRE in front of the string to achieve a match
43 (needed because of positive look-behind.) */
44 char *extentpFW; /* Points to the maximum extent of text scanned by
45 ExecRE to achieve a match (needed because of
46 positive look-ahead.) */
47 int top_branch; /* Zero-based index of the top branch that matches.
48 Used by syntax highlighting only. */
49 char match_start; /* Internal use only. */
50 char anchor; /* Internal use only. */
51 char program [1]; /* Unwarranted chumminess with compiler. */
52 } regexp;
54 /* Flags for CompileRE default settings (Markus Schwarzenberg) */
56 typedef enum {
57 REDFLT_STANDARD = 0,
58 REDFLT_CASE_INSENSITIVE = 1
59 /* REDFLT_MATCH_NEWLINE = 2 Currently not used. */
60 } RE_DEFAULT_FLAG;
62 /* Compiles a regular expression into the internal format used by `ExecRE'. */
64 regexp * CompileRE (
65 const char *exp, /* String containing the regex specification. */
66 char **errorText, /* Text of any error message produced. */
67 int defaultFlags); /* Flags for default RE-operation */
69 /* Match a `regexp' structure against a string. */
71 int ExecRE (
72 regexp *prog, /* Compiled regex. */
73 regexp *cross_regex_backref, /* Pointer to a `regexp' that was used in a
74 previous execution of ExecRE. Used to
75 implement back references across regular
76 expressions for use in syntax
77 highlighting.*/
78 const char *string, /* Text to search within. */
79 const char *end, /* Pointer to the end of `string'. If NULL will
80 scan from `string' until '\0' is found. */
81 int reverse, /* Backward search. */
82 char prev_char, /* Character immediately prior to `string'. Set
83 to '\n' or '\0' if true beginning of text. */
84 char succ_char, /* Character immediately after `end'. Set
85 to '\n' or '\0' if true beginning of text. */
86 const char *delimiters, /* Word delimiters to use (NULL for default) */
87 const char *look_behind_to,/* Boundary for look-behind; defaults to
88 "string" if NULL */
89 const char *match_till); /* Boundary to where match can extend.
90 \0 is assumed to be the boundary if not
91 set. Lookahead can cross the boundary. */
93 /* Perform substitutions after a `regexp' match. */
95 void SubstituteRE (
96 regexp *prog,
97 const char *source,
98 char *dest,
99 int max);
101 /* Builds a default delimiter table that persists across `ExecRE' calls that
102 is identical to `delimiters'. Pass NULL for "default default" set of
103 delimiters. */
105 void SetREDefaultWordDelimiters (
106 char *delimiters);
108 /* Enable (or disable) brace counting quantifiers, e.g. `(foo){0,3}'. */
110 void EnableCountingQuantifier (int is_enabled);
112 #endif /* NEDIT_REGULAREXP_H_INCLUDED */