Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

statement.hh

Go to the documentation of this file.
00001 // -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; -*- 00002 00003 /* libutap - Uppaal Timed Automata Parser. 00004 Copyright (C) 2002 Uppsala University and Aalborg University. 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public License 00008 as published by the Free Software Foundation; either version 2.1 of 00009 the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, but 00012 WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00019 USA 00020 */ 00021 00022 #ifndef UTAP_STATEMENT_H 00023 #define UTAP_STATEMENT_H 00024 00025 #include "utap/expression.hh" 00026 #include "utap/symbols.hh" 00027 #include "utap/system.hh" 00028 00029 namespace UTAP 00030 { 00031 class StatementVisitor; 00032 00033 class Statement 00034 { 00035 public: 00036 virtual ~Statement() {}; 00037 virtual int32_t accept(StatementVisitor *visitor) = 0; 00038 protected: 00039 Statement(frame_t); 00040 }; 00041 00042 class EmptyStatement: public Statement 00043 { 00044 public: 00045 EmptyStatement(frame_t frame); 00046 int32_t accept(StatementVisitor *visitor); 00047 }; 00048 00049 class ExprStatement: public Statement 00050 { 00051 public: 00052 expression_t expr; 00053 ExprStatement(frame_t frame, expression_t); 00054 int32_t accept(StatementVisitor *visitor); 00055 }; 00056 00057 class ForStatement: public Statement 00058 { 00059 public: 00060 expression_t init; 00061 expression_t cond; 00062 expression_t step; 00063 Statement *stat; 00064 ForStatement(frame_t frame, expression_t, 00065 expression_t, expression_t, Statement*); 00066 int32_t accept(StatementVisitor *visitor); 00067 }; 00068 00069 class WhileStatement: public Statement 00070 { 00071 public: 00072 expression_t cond; 00073 Statement *stat; 00074 WhileStatement(frame_t frame, expression_t, Statement*); 00075 int32_t accept(StatementVisitor *visitor); 00076 }; 00077 00078 class DoWhileStatement: public Statement 00079 { 00080 public: 00081 Statement *stat; 00082 expression_t cond; 00083 DoWhileStatement(frame_t frameId, Statement*, expression_t); 00084 int32_t accept(StatementVisitor *visitor); 00085 }; 00086 00087 class BlockStatement: public Statement, public declarations_t 00088 { 00089 public: 00090 typedef std::vector<Statement *>::const_iterator const_iterator; 00091 typedef std::vector<Statement *>::iterator iterator; 00092 protected: 00093 std::vector<Statement*> stats; 00094 public: 00095 BlockStatement(frame_t frame); 00096 virtual ~BlockStatement(); 00097 virtual int32_t accept(StatementVisitor *visitor); 00098 00099 void push_stat(Statement* stat); 00100 Statement* pop_stat(); 00101 const_iterator begin() const; 00102 const_iterator end() const; 00103 iterator begin(); 00104 iterator end(); 00105 }; 00106 00107 class SwitchStatement: public BlockStatement 00108 { 00109 public: 00110 expression_t cond; 00111 SwitchStatement(frame_t frame, expression_t); 00112 virtual int32_t accept(StatementVisitor *visitor); 00113 }; 00114 00115 class CaseStatement: public BlockStatement 00116 { 00117 public: 00118 expression_t cond; 00119 CaseStatement(frame_t frame, expression_t); 00120 virtual int32_t accept(StatementVisitor *visitor); 00121 }; 00122 00123 class DefaultStatement: public BlockStatement 00124 { 00125 public: 00126 DefaultStatement(frame_t frame); 00127 virtual int32_t accept(StatementVisitor *visitor); 00128 }; 00129 00130 class IfStatement: public Statement 00131 { 00132 public: 00133 expression_t cond; 00134 Statement *trueCase; 00135 Statement *falseCase; 00136 IfStatement(frame_t frame, expression_t, Statement*, 00137 Statement* falseStat=NULL); 00138 virtual int32_t accept(StatementVisitor *visitor); 00139 }; 00140 00141 class BreakStatement: public Statement 00142 { 00143 public: 00144 BreakStatement(frame_t frame); 00145 virtual int32_t accept(StatementVisitor *visitor); 00146 }; 00147 00148 class ContinueStatement: public Statement 00149 { 00150 public: 00151 ContinueStatement(frame_t frame); 00152 virtual int32_t accept(StatementVisitor *visitor); 00153 }; 00154 00155 class ReturnStatement: public Statement 00156 { 00157 public: 00158 expression_t value; 00159 ReturnStatement(frame_t frame); 00160 ReturnStatement(frame_t frame, expression_t); 00161 virtual int32_t accept(StatementVisitor *visitor); 00162 }; 00163 00164 class StatementVisitor 00165 { 00166 public: 00167 virtual ~StatementVisitor() {}; 00168 virtual int32_t visitEmptyStatement(EmptyStatement *stat)=0; 00169 virtual int32_t visitExprStatement(ExprStatement *stat)=0; 00170 virtual int32_t visitForStatement(ForStatement *stat)=0; 00171 virtual int32_t visitWhileStatement(WhileStatement *stat)=0; 00172 virtual int32_t visitDoWhileStatement(DoWhileStatement *stat)=0; 00173 virtual int32_t visitBlockStatement(BlockStatement *stat)=0; 00174 virtual int32_t visitSwitchStatement(SwitchStatement *stat)=0; 00175 virtual int32_t visitCaseStatement(CaseStatement *stat)=0; 00176 virtual int32_t visitDefaultStatement(DefaultStatement *stat)=0; 00177 virtual int32_t visitIfStatement(IfStatement *stat)=0; 00178 virtual int32_t visitBreakStatement(BreakStatement *stat)=0; 00179 virtual int32_t visitContinueStatement(ContinueStatement *stat)=0; 00180 virtual int32_t visitReturnStatement(ReturnStatement *stat)=0; 00181 00182 protected: 00183 StatementVisitor(){}; 00184 }; 00185 00186 } 00187 #endif

Generated on Sat May 15 12:33:41 2004 for libutap by doxygen 1.3.7