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 Sci::Position
MovePositionOutsideChar(Sci::Position pos
, [[maybe_unused
]] Sci::Position moveDir
) const noexcept
=0;
23 explicit RESearch(CharClassify
*charClassTable
);
24 // No dynamic allocation so default copy constructor and assignment operator are OK.
26 const char *Compile(const char *pattern
, Sci::Position length
, bool caseSensitive
, bool posix
);
27 int Execute(const CharacterIndexer
&ci
, Sci::Position lp
, Sci::Position endp
);
28 void SetLineRange(Sci::Position startPos
, Sci::Position endPos
) noexcept
{
29 lineStartPos
= startPos
;
33 static constexpr int MAXTAG
= 10;
34 static constexpr int NOTFOUND
= -1;
36 using MatchPositions
= std::array
<Sci::Position
, MAXTAG
>;
42 static constexpr int MAXNFA
= 4096;
43 // The following constants are not meant to be changeable.
44 // They are for readability only.
45 static constexpr int MAXCHR
= 256;
46 static constexpr int CHRBIT
= 8;
47 static constexpr int BITBLK
= MAXCHR
/ CHRBIT
;
49 void ChSet(unsigned char c
) noexcept
;
50 void ChSetWithCase(unsigned char c
, bool caseSensitive
) noexcept
;
51 int GetBackslashExpression(const char *pattern
, int &incr
) noexcept
;
53 Sci::Position
PMatch(const CharacterIndexer
&ci
, Sci::Position lp
, Sci::Position endp
, const char *ap
);
55 // positions to match line start and line end
56 Sci::Position lineStartPos
;
57 Sci::Position lineEndPos
;
58 char nfa
[MAXNFA
]; /* automaton */
61 std::array
<unsigned char, BITBLK
> bittab
{}; /* bit table for CCL pre-set bits */
62 CharClassify
*charClass
;
63 bool iswordc(unsigned char x
) const noexcept
{
64 return charClass
->IsWord(x
);