Distributed under the LGPL
*/
#include <stack>
-#include <msp/core/error.h>
+#include <msp/core/except.h>
#include "formatter.h"
#include "regex.h"
using namespace std;
-#include <iostream>
-
namespace {
/**
if(flag)
{
- if(static_cast<unsigned char>(*i)<=LAST_INSTRUCTION_)
- result+=MATCH_CHAR;
+ result+=MATCH_CHAR;
result+=*i;
}
}
string::const_iterator end=iter;
- for(; (end!=str.end() && *end!=']'); ++end);
+ for(; (end!=str.end() && (end==iter || *end!=']')); ++end);
if(end==str.end())
throw InvalidParameterValue("Unmatched '['");
uint8_t mask[32]={0};
unsigned type=0;
bool range=false;
- unsigned char first, last;
+ unsigned char first=0, last=0;
for(string::const_iterator i=iter; i!=end; ++i)
{
unsigned char c=*i;
bool negate_match=false;
for(; j->citer!=code.end();)
{
- Instruction instr=static_cast<Instruction>(*j->citer);
- if(instr>LAST_INSTRUCTION_)
- instr=MATCH_CHAR;
- else
- ++j->citer;
+ Instruction instr=static_cast<Instruction>(*j->citer++);
if(instr==NEGATE)
negate_match=true;
{
if(!g1.match)
return false;
-
+
// Any match is better than no match
if(!g2.match)
return true;
string Regex::disassemble_instruction(Code::const_iterator &i) const
{
- Instruction instr=static_cast<Instruction>(*i);
- if(instr>=LAST_INSTRUCTION_)
- instr=MATCH_CHAR;
- else
- ++i;
+ Instruction instr=static_cast<Instruction>(*i++);
ostringstream result;
switch(instr)
case MATCH_ANY:
result<<"MATCH_ANY";
break;
- case FIRST_INSTRUCTION_:
- case LAST_INSTRUCTION_:
+ default:
result<<"UNKNOWN "<<instr;
}