Commit 994b0dfe authored by miloyip's avatar miloyip

Clean up regex

parent a3869342
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
#include "../rapidjson.h" #include "../rapidjson.h"
#include "stack.h" #include "stack.h"
#ifndef RAPIDJSON_REGEX_VERBOSE
#define RAPIDJSON_REGEX_VERBOSE 0
#endif
RAPIDJSON_NAMESPACE_BEGIN RAPIDJSON_NAMESPACE_BEGIN
namespace internal { namespace internal {
...@@ -62,16 +66,12 @@ public: ...@@ -62,16 +66,12 @@ public:
next->Clear(); next->Clear();
for (const SizeType* s = current->template Bottom<SizeType>(); s != current->template End<SizeType>(); ++s) { for (const SizeType* s = current->template Bottom<SizeType>(); s != current->template End<SizeType>(); ++s) {
const State& sr = GetState(*s); const State& sr = GetState(*s);
// if (sr.out != kRegexInvalidState) if (sr.codepoint == codepoint)
// printf("%c matches %c\n", (char)sr.codepoint, (char)codepoint);
if (sr.out != kRegexInvalidState && sr.codepoint == codepoint)
AddState(stateSet, *next, sr.out); AddState(stateSet, *next, sr.out);
} }
Stack<Allocator>* temp = current; Stack<Allocator>* temp = current;
current = next; current = next;
next = temp; next = temp;
// printf("\n");
} }
Allocator::Free(stateSet); Allocator::Free(stateSet);
...@@ -99,7 +99,7 @@ private: ...@@ -99,7 +99,7 @@ private:
}; };
struct State { struct State {
SizeType out; //!< Equals to kInvalid for match SizeType out; //!< Equals to kInvalid for matching state
SizeType out1; //!< Equals to non-kInvalid for split SizeType out1; //!< Equals to non-kInvalid for split
unsigned codepoint; unsigned codepoint;
}; };
...@@ -229,7 +229,7 @@ private: ...@@ -229,7 +229,7 @@ private:
Frag* e = operandStack.template Pop<Frag>(1); Frag* e = operandStack.template Pop<Frag>(1);
Patch(e->out, NewState(kRegexInvalidState, kRegexInvalidState, 0)); Patch(e->out, NewState(kRegexInvalidState, kRegexInvalidState, 0));
root_ = e->start; root_ = e->start;
#if 0 #if RAPIDJSON_REGEX_VERBOSE
printf("root: %d\n", root_); printf("root: %d\n", root_);
for (SizeType i = 0; i < stateCount_ ; i++) { for (SizeType i = 0; i < stateCount_ ; i++) {
State& s = GetState(i); State& s = GetState(i);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment