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

expressionbuilder.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-2003 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_EXPRESSIONBUILDER_HH
00023 #define UTAP_EXPRESSIONBUILDER_HH
00024 
00025 #include "utap/abstractbuilder.h"
00026 #include "utap/utap.h"
00027 
00028 namespace UTAP
00029 {
00030     class ExpressionBuilder : public AbstractBuilder 
00031     {
00032     public:
00033         class ExpressionFragments 
00034         {
00035         private:
00036             std::vector<expression_t> data;
00037         public:
00038             expression_t &operator[] (int idx)
00039                 { return data[data.size() - idx - 1]; }
00040             void push(expression_t e)
00041                 { data.push_back(e); }
00042             void pop()
00043                 { data.pop_back(); }
00044             void pop(int n);
00045             uint32_t size() { return data.size(); }
00046         };
00047 
00048     protected:
00049         /* Expression stack */
00050         ExpressionFragments fragments;
00051 
00052         /* Pointer to the intermediate system under construction */
00053         TimedAutomataSystem *system;
00054 
00055         /* Current frame */
00056         frame_t frame;
00057 
00058         /* Set the current frame */
00059         void setFrame(frame_t);
00060 
00061         expression_t makeConstant(int value);
00062 
00064         // allowProcessReferences()
00066         // If this method returns true, it is allowed to access the 
00067         // private identifiers of a process by prefixing the identifier
00068         // with the process name. 
00069         //
00070         // This is only interesting when parsing properties. In this case
00071         // the method should be overridden by a sub class.
00072         virtual bool allowProcessReferences() { return false; }
00073 
00074     public:
00075         ExpressionBuilder(TimedAutomataSystem *);
00076         ExpressionFragments &getExpressions();
00077 
00078         /************************************************************
00079          * Query functions
00080          */
00081         virtual bool isType(const char*);
00082         virtual bool isLocation(const char*);
00083 
00084         /************************************************************
00085          * Expressions
00086          */
00087         virtual void exprTrue();
00088         virtual void exprFalse();
00089         virtual void exprId(const char * varName);
00090         virtual void exprNat(int32_t); // natural number
00091         virtual void exprCallBegin(const char * functionName);
00092         virtual void exprCallEnd(uint32_t n); // n exprs as arguments
00093         virtual void exprArg(uint32_t n); // 1 exprs as n-th argument for fn-call
00094         virtual void exprArray(); // 2 expr 
00095         virtual void exprPostIncrement(); // 1 expr
00096         virtual void exprPreIncrement(); // 1 expr
00097         virtual void exprPostDecrement(); // 1 expr
00098         virtual void exprPreDecrement(); // 1 expr
00099         virtual void exprAssignment(Constants::kind_t op); // 2 expr
00100         virtual void exprUnary(Constants::kind_t unaryop); // 1 expr
00101         virtual void exprBinary(Constants::kind_t binaryop); // 2 expr
00102         virtual void exprInlineIf(); // 3 expr
00103         virtual void exprComma(); // 2 expr
00104         virtual void exprDot(const char *); // 1 expr
00105         virtual void exprDeadlock();
00106 
00107     };
00108 }
00109 
00110 #endif

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