2005-11-22 12:26:26 +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
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following defines are not meant to be changeable.
|
|
|
|
* They are for readability only.
|
|
|
|
*/
|
|
|
|
#define MAXCHR 256
|
|
|
|
#define CHRBIT 8
|
|
|
|
#define BITBLK MAXCHR/CHRBIT
|
|
|
|
|
|
|
|
class CharacterIndexer {
|
2006-03-11 02:33:39 +00:00
|
|
|
public:
|
2005-11-22 12:26:26 +00:00
|
|
|
virtual char CharAt(int index)=0;
|
|
|
|
virtual ~CharacterIndexer() {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class RESearch {
|
|
|
|
|
|
|
|
public:
|
2006-03-11 02:33:39 +00:00
|
|
|
RESearch(CharClassify *charClassTable);
|
2005-11-22 12:26:26 +00:00
|
|
|
~RESearch();
|
|
|
|
bool GrabMatches(CharacterIndexer &ci);
|
|
|
|
const char *Compile(const char *pat, int length, bool caseSensitive, bool posix);
|
|
|
|
int Execute(CharacterIndexer &ci, int lp, int endp);
|
|
|
|
int Substitute(CharacterIndexer &ci, char *src, char *dst);
|
|
|
|
|
|
|
|
enum {MAXTAG=10};
|
|
|
|
enum {MAXNFA=2048};
|
|
|
|
enum {NOTFOUND=-1};
|
|
|
|
|
|
|
|
int bopat[MAXTAG];
|
|
|
|
int eopat[MAXTAG];
|
|
|
|
char *pat[MAXTAG];
|
|
|
|
|
|
|
|
private:
|
2006-03-11 02:33:39 +00:00
|
|
|
void Init();
|
|
|
|
void Clear();
|
|
|
|
void ChSet(char c);
|
|
|
|
void ChSetWithCase(char c, bool caseSensitive);
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
int PMatch(CharacterIndexer &ci, int lp, int endp, char *ap);
|
|
|
|
|
|
|
|
int bol;
|
2006-03-11 02:33:39 +00:00
|
|
|
int tagstk[MAXTAG]; /* subpat tag stack */
|
|
|
|
char nfa[MAXNFA]; /* automaton */
|
2005-11-22 12:26:26 +00:00
|
|
|
int sta;
|
2006-03-11 02:33:39 +00:00
|
|
|
char bittab[BITBLK]; /* bit table for CCL pre-set bits */
|
2005-11-22 12:26:26 +00:00
|
|
|
int failure;
|
2006-03-11 02:33:39 +00:00
|
|
|
CharClassify *charClass;
|
|
|
|
bool iswordc(unsigned char x) {
|
|
|
|
return charClass->IsWord(x);
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|