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;
17 virtual ~CharacterIndexer() {
24 explicit RESearch(CharClassify
*charClassTable
);
25 // No dynamic allocation so default copy constructor and assignment operator are OK.
26 void Clear() noexcept
;
27 void GrabMatches(const CharacterIndexer
&ci
);
28 const char *Compile(const char *pattern
, Sci::Position length
, bool caseSensitive
, bool posix
) noexcept
;
29 int Execute(const CharacterIndexer
&ci
, Sci::Position lp
, Sci::Position endp
);
31 static constexpr int MAXTAG
= 10;
32 static constexpr int NOTFOUND
= -1;
34 Sci::Position bopat
[MAXTAG
];
35 Sci::Position eopat
[MAXTAG
];
36 std::string pat
[MAXTAG
];
40 static constexpr int MAXNFA
= 4096;
41 // The following constants are not meant to be changeable.
42 // They are for readability only.
43 static constexpr int MAXCHR
= 256;
44 static constexpr int CHRBIT
= 8;
45 static constexpr int BITBLK
= MAXCHR
/ CHRBIT
;
47 void ChSet(unsigned char c
) noexcept
;
48 void ChSetWithCase(unsigned char c
, bool caseSensitive
) noexcept
;
49 int GetBackslashExpression(const char *pattern
, int &incr
) noexcept
;
51 Sci::Position
PMatch(const CharacterIndexer
&ci
, Sci::Position lp
, Sci::Position endp
, char *ap
);
54 Sci::Position tagstk
[MAXTAG
]; /* subpat tag stack */
55 char nfa
[MAXNFA
]; /* automaton */
57 unsigned char bittab
[BITBLK
]; /* bit table for CCL pre-set bits */
59 CharClassify
*charClass
;
60 bool iswordc(unsigned char x
) const noexcept
{
61 return charClass
->IsWord(x
);