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

statement.h

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.h"
00026 #include "utap/symbols.h"
00027 #include "utap/system.h"
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();
00040     };
00041 
00042     class EmptyStatement: public Statement 
00043     {
00044     public:
00045         EmptyStatement();
00046         int32_t accept(StatementVisitor *visitor);
00047     };
00048 
00049     class ExprStatement: public Statement 
00050     {
00051     public:
00052         expression_t expr;
00053         ExprStatement(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(expression_t, expression_t, expression_t, Statement*);
00065         int32_t accept(StatementVisitor *visitor);
00066     };
00067 
00068     class WhileStatement: public Statement 
00069     {
00070     public:
00071         expression_t cond;
00072         Statement *stat;
00073         WhileStatement(expression_t, Statement*);
00074         int32_t accept(StatementVisitor *visitor);
00075     };
00076 
00077     class DoWhileStatement: public Statement 
00078     {
00079     public:
00080         Statement *stat;
00081         expression_t cond;
00082         DoWhileStatement(Statement*, expression_t);
00083         int32_t accept(StatementVisitor *visitor);
00084     };
00085 
00086     class BlockStatement: public Statement, public declarations_t 
00087     {
00088     public:
00089         typedef std::vector<Statement *>::const_iterator const_iterator;
00090         typedef std::vector<Statement *>::iterator iterator;
00091     protected:
00092         std::vector<Statement*> stats;
00093         frame_t frame;
00094     public:
00095         BlockStatement(frame_t);
00096         virtual ~BlockStatement();
00097         virtual int32_t accept(StatementVisitor *visitor);
00098 
00099         frame_t getFrame() { return frame; }
00100         void push_stat(Statement* stat);
00101         Statement* pop_stat();
00102         const_iterator begin() const;
00103         const_iterator end() const;
00104         iterator begin();
00105         iterator end();
00106     };
00107 
00108     class SwitchStatement: public BlockStatement
00109     {
00110     public:
00111         expression_t cond;
00112         SwitchStatement(frame_t, expression_t);
00113         virtual int32_t accept(StatementVisitor *visitor);  
00114     };
00115 
00116     class CaseStatement: public BlockStatement 
00117     {
00118     public:
00119         expression_t cond;
00120         CaseStatement(frame_t, expression_t);
00121         virtual int32_t accept(StatementVisitor *visitor);
00122     };
00123 
00124     class DefaultStatement: public BlockStatement 
00125     {
00126     public:
00127         DefaultStatement(frame_t);
00128         virtual int32_t accept(StatementVisitor *visitor);
00129     };
00130 
00131     class IfStatement: public Statement 
00132     {
00133     public:
00134         expression_t cond;
00135         Statement *trueCase;
00136         Statement *falseCase;
00137         IfStatement(expression_t, Statement*, 
00138                     Statement* falseStat=NULL);
00139         virtual int32_t accept(StatementVisitor *visitor);
00140     };
00141 
00142     class BreakStatement: public Statement 
00143     {
00144     public:
00145         BreakStatement();
00146         virtual int32_t accept(StatementVisitor *visitor);
00147     };
00148 
00149     class ContinueStatement: public Statement 
00150     {
00151     public:
00152         ContinueStatement();
00153         virtual int32_t accept(StatementVisitor *visitor);
00154     };
00155 
00156     class ReturnStatement: public Statement 
00157     {
00158     public:
00159         expression_t value;
00160         ReturnStatement();
00161         ReturnStatement(expression_t);
00162         virtual int32_t accept(StatementVisitor *visitor);
00163     };
00164 
00165     class StatementVisitor
00166     {
00167     public:
00168         virtual ~StatementVisitor() {};
00169         virtual int32_t visitEmptyStatement(EmptyStatement *stat)=0;
00170         virtual int32_t visitExprStatement(ExprStatement *stat)=0;
00171         virtual int32_t visitForStatement(ForStatement *stat)=0;
00172         virtual int32_t visitWhileStatement(WhileStatement *stat)=0;
00173         virtual int32_t visitDoWhileStatement(DoWhileStatement *stat)=0;
00174         virtual int32_t visitBlockStatement(BlockStatement *stat)=0;
00175         virtual int32_t visitSwitchStatement(SwitchStatement *stat)=0;
00176         virtual int32_t visitCaseStatement(CaseStatement *stat)=0;
00177         virtual int32_t visitDefaultStatement(DefaultStatement *stat)=0;
00178         virtual int32_t visitIfStatement(IfStatement *stat)=0;
00179         virtual int32_t visitBreakStatement(BreakStatement *stat)=0;
00180         virtual int32_t visitContinueStatement(ContinueStatement *stat)=0;
00181         virtual int32_t visitReturnStatement(ReturnStatement *stat)=0;
00182     };
00183 
00184     class AbstractStatementVisitor : public StatementVisitor
00185     {
00186     protected:
00187         virtual int32_t visitStatement(Statement *stat);
00188     public:
00189         virtual int32_t visitEmptyStatement(EmptyStatement *stat);
00190         virtual int32_t visitExprStatement(ExprStatement *stat);
00191         virtual int32_t visitForStatement(ForStatement *stat);
00192         virtual int32_t visitWhileStatement(WhileStatement *stat);
00193         virtual int32_t visitDoWhileStatement(DoWhileStatement *stat);
00194         virtual int32_t visitBlockStatement(BlockStatement *stat);
00195         virtual int32_t visitSwitchStatement(SwitchStatement *stat);
00196         virtual int32_t visitCaseStatement(CaseStatement *stat);
00197         virtual int32_t visitDefaultStatement(DefaultStatement *stat);
00198         virtual int32_t visitIfStatement(IfStatement *stat);
00199         virtual int32_t visitBreakStatement(BreakStatement *stat);
00200         virtual int32_t visitContinueStatement(ContinueStatement *stat);
00201         virtual int32_t visitReturnStatement(ReturnStatement *stat);
00202     };
00203 
00204 }
00205 #endif

Generated on Thu Feb 17 15:20:58 2005 for libutap by  doxygen 1.4.1