Module: sems Branch: sayer/dsm_lang Commit: 3b67569f6973e280fab61b7b3cc87f882a560212 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=3b67569f6973e280fab61b7b3cc87f882a560212
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Sun Jan 23 01:48:31 2011 +0100 reindent --- apps/dsm/DSMChartReader.cpp | 175 +++++++++++++++++++++---------------------- apps/dsm/DSMStateEngine.h | 24 +++--- 2 files changed, 99 insertions(+), 100 deletions(-) diff --git a/apps/dsm/DSMChartReader.cpp b/apps/dsm/DSMChartReader.cpp index 0b54b18..7069e18 100644 --- a/apps/dsm/DSMChartReader.cpp +++ b/apps/dsm/DSMChartReader.cpp @@ -264,7 +264,8 @@ bool DSMChartReader::decode(DSMStateDiagram* e, const string& chart, f->name = token.substr(0, b_pos); continue; } else { - ERROR("Parse error -- function declarations must have a name followed by parentheses, e.g., 'function foo()'\n"); + ERROR("Parse error -- function declarations must have a name followed " + "by parentheses, e.g., 'function foo()'\n"); return false; } } @@ -285,7 +286,7 @@ bool DSMChartReader::decode(DSMStateDiagram* e, const string& chart, } DSMConditionTree* ct = dynamic_cast<DSMConditionTree*>(stack_top); - if (ct) { + if (ct) { if (token == "[") { stack.push_back(new DSMConditionList()); continue; @@ -308,9 +309,7 @@ bool DSMChartReader::decode(DSMStateDiagram* e, const string& chart, } continue; } - } - - + } State* state = dynamic_cast<State*>(stack_top); if (state) { @@ -345,100 +344,100 @@ bool DSMChartReader::decode(DSMStateDiagram* e, const string& chart, continue; } - ActionList* al = dynamic_cast<ActionList*>(stack_top); - if (al) { - if (token == ";") { - continue; - } - if (token == "{") { - continue; - } + ActionList* al = dynamic_cast<ActionList*>(stack_top); + if (al) { + if (token == ";") { + continue; + } + if (token == "{") { + continue; + } - if ((token == "}") || (token == "->")) { + if ((token == "}") || (token == "->")) { stack.pop_back(); if (stack.empty()) { - ERROR("no item for action list\n"); - delete al; - return false; + ERROR("no item for action list\n"); + delete al; + return false; } - if (al->al_type == ActionList::AL_func) { - DSMFunction* f = dynamic_cast<DSMFunction*>(&(*stack.back())); - if (!f) { - ERROR("no DSMFunction for action list\n"); - delete al; - return false; - } - f->actions = al->actions; - } else if (al->al_type == ActionList::AL_if || - al->al_type == ActionList::AL_else) { - DSMConditionTree* ct = dynamic_cast<DSMConditionTree*>(&(*stack.back())); - if (!ct) { - ERROR("no DSMConditionTree for action list\n"); - delete al; - return false; - } + if (al->al_type == ActionList::AL_func) { + DSMFunction* f = dynamic_cast<DSMFunction*>(&(*stack.back())); + if (!f) { + ERROR("no DSMFunction for action list\n"); + delete al; + return false; + } + f->actions = al->actions; + } else if (al->al_type == ActionList::AL_if || + al->al_type == ActionList::AL_else) { + DSMConditionTree* ct = dynamic_cast<DSMConditionTree*>(&(*stack.back())); + if (!ct) { + ERROR("no DSMConditionTree for action list\n"); + delete al; + return false; + } - if (al->al_type == ActionList::AL_if) { - ct->run_if_true = al->actions; - } else if (al->al_type == ActionList::AL_else) { - ct->run_if_false = al->actions; + if (al->al_type == ActionList::AL_if) { + ct->run_if_true = al->actions; + } else if (al->al_type == ActionList::AL_else) { + ct->run_if_false = al->actions; } - } else if (al->al_type == ActionList::AL_enter || - al->al_type == ActionList::AL_exit) { - State* s = dynamic_cast<State*>(&(*stack.back())); - if (!s) { - ERROR("no State for action list\n"); - delete al; - return false; - } - - if (al->al_type == ActionList::AL_enter) { - s->pre_actions = al->actions; - } else if (al->al_type == ActionList::AL_exit) { - s->post_actions = al->actions; + } else if (al->al_type == ActionList::AL_enter || + al->al_type == ActionList::AL_exit) { + State* s = dynamic_cast<State*>(&(*stack.back())); + if (!s) { + ERROR("no State for action list\n"); + delete al; + return false; + } + + if (al->al_type == ActionList::AL_enter) { + s->pre_actions = al->actions; + } else if (al->al_type == ActionList::AL_exit) { + s->post_actions = al->actions; } } else if (al->al_type == ActionList::AL_trans) { - DSMTransition* t = dynamic_cast<DSMTransition*>(&(*stack.back())); - if (!t) { - ERROR("no DSMTransition for action list\n"); - delete al; - return false; - } - t->actions = al->actions; - } else { - ERROR("internal: unknown transition list type\n"); - } - delete al; - continue; + DSMTransition* t = dynamic_cast<DSMTransition*>(&(*stack.back())); + if (!t) { + ERROR("no DSMTransition for action list\n"); + delete al; + return false; + } + t->actions = al->actions; + } else { + ERROR("internal: unknown transition list type\n"); + } + delete al; + continue; } - if (token == "if") { - //token is condition tree - stack.push_back(new DSMConditionTree()); - continue; - } else { - DSMFunction* f = functionFromToken(token); - if (f) { - DBG("adding actions from function '%s'\n", f->name.c_str()); - DBG("al.size is %zd before", al->actions.size()); - for (vector<DSMElement*>::iterator it=f->actions.begin(); it != f->actions.end(); it++) { - DSMElement* a = *it; - owner->transferElem(a); - al->actions.push_back(a); - } - DBG("al.size is %zd after", al->actions.size()); - } else { - DBG("adding action '%s'\n", token.c_str()); - DSMAction* a = actionFromToken(token); - if (!a) - return false; - owner->transferElem(a); - al->actions.push_back(a); - } - continue; - } - } + if (token == "if") { + //token is condition tree + stack.push_back(new DSMConditionTree()); + continue; + } else { + DSMFunction* f = functionFromToken(token); + if (f) { + DBG("adding actions from function '%s'\n", f->name.c_str()); + DBG("al.size is %zd before", al->actions.size()); + for (vector<DSMElement*>::iterator it=f->actions.begin(); it != f->actions.end(); it++) { + DSMElement* a = *it; + owner->transferElem(a); + al->actions.push_back(a); + } + DBG("al.size is %zd after", al->actions.size()); + } else { + DBG("adding action '%s'\n", token.c_str()); + DSMAction* a = actionFromToken(token); + if (!a) + return false; + owner->transferElem(a); + al->actions.push_back(a); + } + continue; + } + } DSMConditionList* cl = dynamic_cast<DSMConditionList*>(stack_top); diff --git a/apps/dsm/DSMStateEngine.h b/apps/dsm/DSMStateEngine.h index a5fa6a7..c2150d4 100644 --- a/apps/dsm/DSMStateEngine.h +++ b/apps/dsm/DSMStateEngine.h @@ -136,7 +136,7 @@ class DSMAction class DSMTransition; -class State +class State : public DSMElement { public: State(); @@ -147,7 +147,7 @@ class State vector<DSMTransition> transitions; }; -class DSMTransition +class DSMTransition : public DSMElement { public: DSMTransition(); @@ -161,20 +161,20 @@ class DSMTransition bool is_exception; }; -class DSMConditionTree +class DSMConditionTree : public DSMElement { - public: - vector<DSMCondition*> conditions; - vector<DSMElement*> run_if_true; - vector<DSMElement*> run_if_false; - bool is_exception; + public: + vector<DSMCondition*> conditions; + vector<DSMElement*> run_if_true; + vector<DSMElement*> run_if_false; + bool is_exception; }; -class DSMFunction +class DSMFunction : public DSMElement { - public: - string name; - vector<DSMElement*> actions; + public: + string name; + vector<DSMElement*> actions; }; class DSMModule; _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
