]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/RESearch.h
Update Scintilla to version 1.75
[wxWidgets.git] / src / stc / scintilla / src / RESearch.h
1 // Scintilla source code edit control
2 /** @file RESearch.h
3 ** Interface to the regular expression search library.
4 **/
5 // Written by Neil Hodgson <neilh@scintilla.org>
6 // Based on the work of Ozan S. Yigit.
7 // This file is in the public domain.
8
9 #ifndef RESEARCH_H
10 #define RESEARCH_H
11
12 #ifdef SCI_NAMESPACE
13 namespace Scintilla {
14 #endif
15
16 /*
17 * The following defines are not meant to be changeable.
18 * They are for readability only.
19 */
20 #define MAXCHR 256
21 #define CHRBIT 8
22 #define BITBLK MAXCHR/CHRBIT
23
24 class CharacterIndexer {
25 public:
26 virtual char CharAt(int index)=0;
27 virtual ~CharacterIndexer() {
28 }
29 };
30
31 class RESearch {
32
33 public:
34 RESearch(CharClassify *charClassTable);
35 ~RESearch();
36 bool GrabMatches(CharacterIndexer &ci);
37 const char *Compile(const char *pat, int length, bool caseSensitive, bool posix);
38 int Execute(CharacterIndexer &ci, int lp, int endp);
39 int Substitute(CharacterIndexer &ci, char *src, char *dst);
40
41 enum { MAXTAG=10 };
42 enum { MAXNFA=2048 };
43 enum { NOTFOUND=-1 };
44
45 int bopat[MAXTAG];
46 int eopat[MAXTAG];
47 char *pat[MAXTAG];
48
49 private:
50 void Init();
51 void Clear();
52 void ChSet(unsigned char c);
53 void ChSetWithCase(unsigned char c, bool caseSensitive);
54 int GetBackslashExpression(const char *pat, int &incr);
55
56 int PMatch(CharacterIndexer &ci, int lp, int endp, char *ap);
57
58 int bol;
59 int tagstk[MAXTAG]; /* subpat tag stack */
60 char nfa[MAXNFA]; /* automaton */
61 int sta;
62 unsigned char bittab[BITBLK]; /* bit table for CCL pre-set bits */
63 int failure;
64 CharClassify *charClass;
65 bool iswordc(unsigned char x) {
66 return charClass->IsWord(x);
67 }
68 };
69
70 #ifdef SCI_NAMESPACE
71 }
72 #endif
73
74 #endif
75