2009-04-24 23:35:41 +00:00
|
|
|
// Scintilla source code edit control
|
|
|
|
/** @file RESearch.h
|
|
|
|
** Interface to the regular expression search library.
|
|
|
|
**/
|
|
|
|
// Written by Neil Hodgson <neilh@scintilla.org>
|
|
|
|
// Based on the work of Ozan S. Yigit.
|
|
|
|
// This file is in the public domain.
|
|
|
|
|
|
|
|
#ifndef RESEARCH_H
|
|
|
|
#define RESEARCH_H
|
|
|
|
|
|
|
|
namespace Scintilla {
|
|
|
|
|
|
|
|
class CharacterIndexer {
|
|
|
|
public:
|
2019-05-04 18:14:48 +00:00
|
|
|
virtual char CharAt(Sci::Position index) const=0;
|
2009-04-24 23:35:41 +00:00
|
|
|
virtual ~CharacterIndexer() {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class RESearch {
|
|
|
|
|
|
|
|
public:
|
2015-06-07 21:19:26 +00:00
|
|
|
explicit RESearch(CharClassify *charClassTable);
|
2019-05-04 18:14:48 +00:00
|
|
|
// No dynamic allocation so default copy constructor and assignment operator are OK.
|
2009-04-24 23:35:41 +00:00
|
|
|
~RESearch();
|
2015-06-07 21:19:26 +00:00
|
|
|
void Clear();
|
2019-05-04 18:14:48 +00:00
|
|
|
void GrabMatches(const CharacterIndexer &ci);
|
|
|
|
const char *Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix);
|
|
|
|
int Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
enum { MAXTAG=10 };
|
|
|
|
enum { NOTFOUND=-1 };
|
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
Sci::Position bopat[MAXTAG];
|
|
|
|
Sci::Position eopat[MAXTAG];
|
2013-08-28 00:44:27 +00:00
|
|
|
std::string pat[MAXTAG];
|
2009-04-24 23:35:41 +00:00
|
|
|
|
|
|
|
private:
|
2019-07-21 13:26:02 +00:00
|
|
|
|
|
|
|
enum { MAXNFA = 4096 };
|
|
|
|
// The following enums are not meant to be changeable.
|
|
|
|
// They are for readability only.
|
|
|
|
enum { MAXCHR = 256 };
|
|
|
|
enum { CHRBIT = 8 };
|
|
|
|
enum { BITBLK = MAXCHR / CHRBIT };
|
|
|
|
|
2009-04-24 23:35:41 +00:00
|
|
|
void ChSet(unsigned char c);
|
|
|
|
void ChSetWithCase(unsigned char c, bool caseSensitive);
|
2009-04-25 23:38:15 +00:00
|
|
|
int GetBackslashExpression(const char *pattern, int &incr);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
Sci::Position PMatch(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp, char *ap);
|
2009-04-24 23:35:41 +00:00
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
Sci::Position bol;
|
|
|
|
Sci::Position tagstk[MAXTAG]; /* subpat tag stack */
|
2009-04-24 23:35:41 +00:00
|
|
|
char nfa[MAXNFA]; /* automaton */
|
|
|
|
int sta;
|
|
|
|
unsigned char bittab[BITBLK]; /* bit table for CCL pre-set bits */
|
|
|
|
int failure;
|
|
|
|
CharClassify *charClass;
|
2013-08-28 00:44:27 +00:00
|
|
|
bool iswordc(unsigned char x) const {
|
2009-04-24 23:35:41 +00:00
|
|
|
return charClass->IsWord(x);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|