1 // Scintilla source code edit control
3 ** Interface to the regular expression search library.
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.
12 namespace Scintilla::Internal
{
14 class CharacterIndexer
{
16 virtual char CharAt(Sci::Position index
) const=0;
22 explicit RESearch(CharClassify
*charClassTable
);
23 // No dynamic allocation so default copy constructor and assignment operator are OK.
24 void Clear() noexcept
;
25 void GrabMatches(const CharacterIndexer
&ci
);
26 const char *Compile(const char *pattern
, Sci::Position length
, bool caseSensitive
, bool posix
) noexcept
;
27 int Execute(const CharacterIndexer
&ci
, Sci::Position lp
, Sci::Position endp
);
29 static constexpr int MAXTAG
= 10;
30 static constexpr int NOTFOUND
= -1;
32 Sci::Position bopat
[MAXTAG
];
33 Sci::Position eopat
[MAXTAG
];
34 std::string pat
[MAXTAG
];
38 static constexpr int MAXNFA
= 4096;
39 // The following constants are not meant to be changeable.
40 // They are for readability only.
41 static constexpr int MAXCHR
= 256;
42 static constexpr int CHRBIT
= 8;
43 static constexpr int BITBLK
= MAXCHR
/ CHRBIT
;
45 void ChSet(unsigned char c
) noexcept
;
46 void ChSetWithCase(unsigned char c
, bool caseSensitive
) noexcept
;
47 int GetBackslashExpression(const char *pattern
, int &incr
) noexcept
;
49 Sci::Position
PMatch(const CharacterIndexer
&ci
, Sci::Position lp
, Sci::Position endp
, char *ap
);
52 Sci::Position tagstk
[MAXTAG
]; /* subpat tag stack */
53 char nfa
[MAXNFA
]; /* automaton */
55 unsigned char bittab
[BITBLK
]; /* bit table for CCL pre-set bits */
57 CharClassify
*charClass
;
58 bool iswordc(unsigned char x
) const noexcept
{
59 return charClass
->IsWord(x
);