Copyright © 2007 Mikko Rasa
Distributed under the LGPL
*/
+
#include <stack>
-#include <msp/core/error.h>
+#include <limits>
+#include <msp/core/except.h>
#include "formatter.h"
#include "regex.h"
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==iter || *end!=']')); ++end);
+ for(; (end!=str.end() && (end==iter || *end!=']')); ++end) ;
if(end==str.end())
throw InvalidParameterValue("Unmatched '['");
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;
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;
}