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

systembuilder.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-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_SYSTEMBUILDER_H
00023 #define UTAP_SYSTEMBUILDER_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 {
00068     class SystemBuilder : public ExpressionBuilder
00069     {
00070     protected:
00071         // Error message for unsupported features
00072         static const char *const unsupported;
00073         static const char *const invalid_type;
00074 
00075         /* Flag used to determine how strict we check for inclusion 
00076            between ranges of integers. TODO: Replace this with a
00077            system, which reports a warning if there is a potential
00078            overflow. */
00079         bool strict_range;
00080 
00081         /* The current priority level, used when declaring process or
00082          * channel priorities.
00083          */
00084         int32_t currentPriority;
00085     private:
00086 
00087 
00088         // 
00089         // Support for handling template and function parameters
00090         //
00091 
00092         /* The templateset frame is used during template set declaration */
00093         frame_t templateset;
00094 
00095         /* The params frame is used temporarily during parameter parsing */
00096         frame_t params;
00097 
00098         /* current parsing function structure */
00099         function_t *currentFun;
00100 
00101         template_t *currentTemplate;
00102 
00103         edge_t *currentEdge;
00104 
00105         /* stack of function body statement blocks */
00106         std::vector<BlockStatement*> blocks; 
00107 
00108         //
00109         // Method for handling types
00110         //
00111 
00112         type_t buildArrayType(type_t type, uint32_t dim);
00113         type_t getElementTypeOfArray(type_t type);
00114         declarations_t *getCurrentDeclarationBlock();
00115 
00116     public:
00117 
00118         SystemBuilder(TimedAutomataSystem *);
00119 
00120         /************************************************************
00121          * Types
00122          */
00123         // 2 expr if range==true
00124         virtual void typeStruct(int32_t prefix, uint32_t fields);
00125 
00126         virtual void structField(const char* name, uint32_t dim); 
00127         // 1 type and dim array sizes
00128         virtual void structFieldEnd();
00129 
00130         virtual void declTypeDef(const char* name, uint32_t dim); 
00131         // 1 type and dim array sizes
00132         virtual void declTypeDefEnd();
00133 
00134         /************************************************************
00135          * Variable declarations
00136          */
00137         virtual void declVar(const char* name, uint32_t dim, bool init); 
00138         // 1 type, dims, initializer if init==true
00139         virtual void declVarEnd();
00140         virtual void declInitialiserList(uint32_t num); // n initialisers
00141         virtual void declFieldInit(const char* name); // 1 initialiser
00142 
00143         /************************************************************
00144          * Guarded progress measure
00145          */
00146         virtual void declProgress(bool);
00147     
00148         /************************************************************
00149          * Function declarations
00150          */
00151         virtual void declParameter(const char* name, bool reference, uint32_t dim);
00152         // 1 type, dim array sizes
00153         virtual void declParameterEnd(); // pop parameter type
00154     
00155         virtual void declFuncBegin(const char* name, uint32_t n); // n paramaters
00156         virtual void declFuncEnd(); // 1 block
00157 
00158         /************************************************************
00159          * Process declarations
00160          */
00161         virtual void procTemplateSet(const char *name);
00162         virtual void procBegin(const char* name, uint32_t n, uint32_t m);
00163         virtual void procEnd(); // 1 ProcBody
00164         virtual void procState(const char* name, bool hasInvariant); // 1 expr
00165         virtual void procStateCommit(const char* name); // mark previously decl. state
00166         virtual void procStateUrgent(const char* name); // mark previously decl. state
00167         virtual void procStateWinning(const char* name); // mark previously decl. state
00168         virtual void procStateLosing(const char* name); // mark previously decl. state
00169         virtual void procStateInit(const char* name); // mark previously decl. state
00170         virtual void procEdgeBegin(const char* from, const char* to, const bool control);
00171         virtual void procEdgeEnd(const char* from, const char* to); 
00172 
00173         // 1 type
00174         virtual void procSelect(const char *id);
00175 
00176         // 1 epxr
00177         virtual void procGuard();
00178 
00179         // 1 expr
00180         virtual void procSync(Constants::synchronisation_t type); // 1 expr
00181 
00182         // 1 expr
00183         virtual void procUpdate();
00184     
00185         /************************************************************
00186          * Statements
00187          */
00188         virtual void blockBegin();
00189         virtual void blockEnd();
00190         virtual void emptyStatement();
00191         virtual void forBegin();
00192         virtual void forEnd(); // 3 expr, 1 stat
00193         virtual void iterationBegin(const char *name);
00194         virtual void iterationEnd(const char *name);
00195         virtual void whileBegin();
00196         virtual void whileEnd(); // 1 expr, 1 stat
00197         virtual void doWhileBegin();
00198         virtual void doWhileEnd(); // 1 stat, 1 expr
00199         virtual void ifBegin();
00200         virtual void ifElse();
00201         virtual void ifEnd(bool); // 1 expr, 1 or 2 statements
00202         virtual void breakStatement();
00203         virtual void continueStatement();
00204         virtual void switchBegin();
00205         virtual void switchEnd(); // 1 expr, 1+ case/default
00206         virtual void caseBegin();
00207         virtual void caseEnd();  // 1 expr, 0+ stat
00208         virtual void defaultBegin();
00209         virtual void defaultEnd(); // 0+ statements
00210         virtual void exprStatement(); // 1 expr
00211         virtual void returnStatement(bool); // 1 expr if argument is true
00212 
00213         /************************************************************
00214          * Expressions
00215          */     
00216         virtual void exprCallBegin();
00217     
00218         /************************************************************
00219          * System declaration
00220          */
00221         virtual void instantiationBegin(const char*, const char*);
00222         virtual void instantiationEnd(const char *, const char *, uint32_t n); // n arguments
00223         virtual void process(const char*);
00224 
00225         virtual void done();    
00226 
00227         /********************************************************************
00228          * Guiding
00229          */
00230 
00231         virtual void beforeUpdate();
00232         virtual void afterUpdate();
00233 
00234         /********************************************************************
00235          * Priority
00236          */
00237 
00238         virtual void lowPriority(const char*);
00239         virtual void samePriority(const char*);
00240         virtual void higherPriority(const char*);
00241     };
00242 }
00243 #endif

Generated on Thu Nov 10 13:16:12 2005 for libutap by  doxygen 1.4.2