00001 // -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; indent-tabs-mode: nil; -*- 00002 00003 /* libutap - Uppaal Timed Automata Parser. 00004 Copyright (C) 2002-2004 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_STATEMENTBUILDER_H 00023 #define UTAP_STATEMENTBUILDER_H 00024 00025 #include <cassert> 00026 #include <vector> 00027 #include <inttypes.h> 00028 00029 #include "utap/expressionbuilder.h" 00030 #include "utap/utap.h" 00031 00032 namespace UTAP 00033 { 00038 class StatementBuilder : public ExpressionBuilder 00039 { 00040 protected: 00045 frame_t params; 00046 00048 function_t *currentFun; 00049 00051 std::vector<BlockStatement*> blocks; 00052 00054 std::vector<type_t> fields; 00055 00057 std::vector<std::string> labels; 00058 00059 virtual variable_t *addVariable(type_t type, const char* name, 00060 expression_t init) = 0; 00061 virtual bool addFunction(type_t type, const char* name) = 0; 00062 00063 static void collectDependencies(std::set<symbol_t> &, expression_t ); 00064 static void collectDependencies(std::set<symbol_t> &, type_t ); 00065 00066 public: 00067 StatementBuilder(TimedAutomataSystem *); 00068 00069 virtual void typeArrayOfSize(size_t); 00070 virtual void typeArrayOfType(size_t); 00071 virtual void typeStruct(PREFIX, uint32_t fields); 00072 virtual void structField(const char* name); 00073 virtual void declTypeDef(const char* name); 00074 virtual void declVar(const char* name, bool init); 00075 virtual void declInitialiserList(uint32_t num); 00076 virtual void declFieldInit(const char* name); 00077 virtual void declParameter(const char* name, bool); 00078 virtual void declFuncBegin(const char* name); 00079 virtual void declFuncEnd(); 00080 virtual void blockBegin(); 00081 virtual void blockEnd(); 00082 virtual void emptyStatement(); 00083 virtual void forBegin(); 00084 virtual void forEnd(); 00085 virtual void iterationBegin(const char *name); 00086 virtual void iterationEnd(const char *name); 00087 virtual void whileBegin(); 00088 virtual void whileEnd(); 00089 virtual void doWhileBegin(); 00090 virtual void doWhileEnd(); 00091 virtual void ifBegin(); 00092 virtual void ifElse(); 00093 virtual void ifEnd(bool); 00094 virtual void exprStatement(); 00095 virtual void returnStatement(bool); 00096 virtual void assertStatement(); 00097 virtual void exprCallBegin(); 00098 }; 00099 } 00100 #endif