mediawiki-extensions-AbuseF.../parser_native/afeval.h
Andrew Garrett b283904b81 AbuseFilter native parser:
* Revert r38187 for now:
** Introduced a memory leak.
** Used an unnecessary library. The point is taken, and this will be fixed in a few days (using glibc instead).
* Fix logic error in boolean ops.
* Integrate with the PHP abuse filter using AbuseFilterParserNative class.
* Fix memory leak.
* Fix a few miscellaneous bugs
2008-07-31 16:28:24 +00:00

41 lines
1.1 KiB
C++
Executable file

#include "afparser.h"
#include "afutils.h"
// #include "aftypes.h"
#include <map>
class FilterEvaluator {
public:
void reset();
void setVar( string key, AFPData value );
void setVars( map<string,AFPData> values );
bool evaluateFilter( string code );
protected:
bool move();
bool move( int shift );
void doLevelEntry( AFPData* result );
void doLevelSet( AFPData* result );
void doLevelBoolOps( AFPData* result );
void doLevelCompares( AFPData* result );
void doLevelMulRels( AFPData* result );
void doLevelSumRels( AFPData* result );
void doLevelPow( AFPData* result );
void doLevelBoolInvert( AFPData* result );
void doLevelSpecialWords( AFPData* result );
void doLevelUnarys( AFPData* result );
void doLevelBraces( AFPData* result );
void doLevelFunction( AFPData* result );
void doLevelAtom( AFPData* result );
AFPToken cur;
vector<AFPToken> tokens;
map<string, vector<AFPToken> > tokenCache;
unsigned int pos;
string code;
map<string,AFPData> vars;
bool forceResult;
};
// typedef AFPData (*AFPFunction) (vector<AFPData>);
vector<string> getOpsForType( string type );