|
|
@ -142,6 +142,34 @@ bool CmpStrEx(const std::string& expr, const std::string& str) |
|
|
|
|
|
|
|
|
|
|
|
State(const std::string& str):root(Parse(str)),s(str) {InitCursors(root.get());} |
|
|
|
State(const std::string& str):root(Parse(str)),s(str) {InitCursors(root.get());} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string Name() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const struct Block* b=root.get(); |
|
|
|
|
|
|
|
std::string res; |
|
|
|
|
|
|
|
while(true) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Processing current block
|
|
|
|
|
|
|
|
switch(b->type) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case(Block::TEXT): {res+=s.substr(b->b,b->e-b->b); break;} |
|
|
|
|
|
|
|
case(Block::OPTIONAL): {b=b->child.get(); goto next;} |
|
|
|
|
|
|
|
case(Block::VARIANTS): {b=b->child.get(); goto next;} |
|
|
|
|
|
|
|
case(Block::DELIM): {b=b->parent; break;} |
|
|
|
|
|
|
|
default: {} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Go to next block
|
|
|
|
|
|
|
|
while(true) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(nullptr!=b->next) {b=b->next.get(); goto next;} |
|
|
|
|
|
|
|
if(nullptr!=b->parent) b=b->parent; |
|
|
|
|
|
|
|
else break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(nullptr==b->next && nullptr==b->parent) break; |
|
|
|
|
|
|
|
next: ; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CmpSmb(const char c) |
|
|
|
bool CmpSmb(const char c) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -197,6 +225,7 @@ bool CmpStrEx(const std::string& expr, const std::string& str) |
|
|
|
|
|
|
|
|
|
|
|
// Main function
|
|
|
|
// Main function
|
|
|
|
struct State st(expr); |
|
|
|
struct State st(expr); |
|
|
|
|
|
|
|
std::cout<<"Name is "<<st.Name()<<std::endl; |
|
|
|
|
|
|
|
|
|
|
|
// Dump code
|
|
|
|
// Dump code
|
|
|
|
{ |
|
|
|
{ |
|
|
|