Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound 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 "expression.hh"
00026 #include "symbols.hh"
00027 
00028 namespace UTAP
00029 {
00030     class StatementVisitor;
00031 
00032     class Statement 
00033     {
00034     protected:
00035         bool returnDefined;
00036         frame_t frame;    
00037     public:
00038         virtual ~Statement() {};
00039         virtual int32_t accept(StatementVisitor *visitor) = 0;
00040 
00041         frame_t getFrame() { return frame; }
00042         void setRetDefined(bool ret) { returnDefined = ret; }
00043         bool retDefined() const { return returnDefined; }    
00044     protected:
00045         Statement(frame_t);
00046     };
00047 
00048     class EmptyStatement: public Statement 
00049     {
00050     public:
00051         EmptyStatement(frame_t frame);
00052         int32_t accept(StatementVisitor *visitor);
00053     };
00054 
00055     class ExprStatement: public Statement 
00056     {
00057     public:
00058         expression_t expr;
00059         ExprStatement(frame_t frame, expression_t);
00060         int32_t accept(StatementVisitor *visitor);
00061     };
00062 
00063     class ForStatement: public Statement 
00064     {
00065     public:
00066         expression_t init;
00067         expression_t cond;
00068         expression_t step;
00069         Statement *stat;
00070         ForStatement(frame_t frame, expression_t, 
00071                      expression_t, expression_t, Statement*);
00072         int32_t accept(StatementVisitor *visitor);
00073     };
00074 
00075     class WhileStatement: public Statement 
00076     {
00077     public:
00078         expression_t cond;
00079         Statement *stat;
00080         WhileStatement(frame_t frame, expression_t, Statement*);
00081         int32_t accept(StatementVisitor *visitor);
00082     };
00083 
00084     class DoWhileStatement: public Statement 
00085     {
00086     public:
00087         Statement *stat;
00088         expression_t cond;
00089         DoWhileStatement(frame_t frameId, Statement*, expression_t);
00090         int32_t accept(StatementVisitor *visitor);
00091     };
00092 
00093     class BlockStatement: public Statement 
00094     {
00095     public:
00096         typedef std::vector<Statement *>::const_iterator const_iterator;
00097     protected:
00098         std::vector<Statement*> stats;
00099     public:
00100         BlockStatement(frame_t frame);
00101         virtual ~BlockStatement();
00102         virtual int32_t accept(StatementVisitor *visitor);
00103 
00104         void push_stat(Statement* stat);
00105         Statement* pop_stat();
00106         const_iterator begin() const;
00107         const_iterator end() const;
00108     };
00109 
00110     class SwitchStatement: public BlockStatement
00111     {
00112     public:
00113         expression_t cond;
00114         SwitchStatement(frame_t frame, expression_t);
00115         virtual int32_t accept(StatementVisitor *visitor);  
00116     };
00117 
00118     class CaseStatement: public BlockStatement 
00119     {
00120     public:
00121         expression_t cond;
00122         CaseStatement(frame_t frame, expression_t);
00123         virtual int32_t accept(StatementVisitor *visitor);
00124     };
00125 
00126     class DefaultStatement: public BlockStatement 
00127     {
00128     public:
00129         DefaultStatement(frame_t frame);
00130         virtual int32_t accept(StatementVisitor *visitor);
00131     };
00132 
00133     class IfStatement: public Statement 
00134     {
00135     public:
00136         expression_t cond;
00137         Statement *trueCase;
00138         Statement *falseCase;
00139         IfStatement(frame_t frame, expression_t, Statement*, 
00140                     Statement* falseStat=NULL);
00141         virtual int32_t accept(StatementVisitor *visitor);
00142     };
00143 
00144     class BreakStatement: public Statement 
00145     {
00146     public:
00147         BreakStatement(frame_t frame);
00148         virtual int32_t accept(StatementVisitor *visitor);
00149     };
00150 
00151     class ContinueStatement: public Statement 
00152     {
00153     public:
00154         ContinueStatement(frame_t frame);
00155         virtual int32_t accept(StatementVisitor *visitor);
00156     };
00157 
00158     class ReturnStatement: public Statement 
00159     {
00160     public:
00161         expression_t value;
00162         ReturnStatement(frame_t frame);
00163         ReturnStatement(frame_t frame, expression_t);
00164         virtual int32_t accept(StatementVisitor *visitor);
00165     };
00166 
00167     class StatementVisitor
00168     {
00169     public:
00170         virtual ~StatementVisitor() {};
00171         virtual int32_t emptyStat(EmptyStatement *stat)=0;
00172         virtual int32_t exprStat(ExprStatement *stat)=0;
00173         virtual int32_t forStat(ForStatement *stat)=0;
00174         virtual int32_t whileStat(WhileStatement *stat)=0;
00175         virtual int32_t doWhileStat(DoWhileStatement *stat)=0;
00176         virtual int32_t blockStat(BlockStatement *stat)=0;
00177         virtual int32_t switchStat(SwitchStatement *stat)=0;
00178         virtual int32_t caseStat(CaseStatement *stat)=0;
00179         virtual int32_t defaultStat(DefaultStatement *stat)=0;
00180         virtual int32_t ifStat(IfStatement *stat)=0;
00181         virtual int32_t breakStat(BreakStatement *stat)=0;
00182         virtual int32_t continueStat(ContinueStatement *stat)=0;
00183         virtual int32_t returnStat(ReturnStatement *stat)=0;
00184     
00185     protected:
00186         StatementVisitor(){};
00187     };
00188 
00189 }
00190 #endif

Generated on Wed Jul 2 12:08:18 2003 for libutap by doxygen 1.3.2