libutap  0.93
Uppaal Timed Automata Parser
statementbuilder.h
Go to the documentation of this file.
1 // -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 
3 /* libutap - Uppaal Timed Automata Parser.
4  Copyright (C) 2002-2004 Uppsala University and Aalborg University.
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public License
8  as published by the Free Software Foundation; either version 2.1 of
9  the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  USA
20 */
21 
22 #ifndef UTAP_STATEMENTBUILDER_H
23 #define UTAP_STATEMENTBUILDER_H
24 
25 #include "utap/expressionbuilder.h"
26 #include "utap/utap.h"
27 
28 #include <cinttypes>
29 #include <cassert>
30 #include <vector>
31 
32 
33 namespace UTAP
34 {
40  {
41  protected:
47 
50 
52  std::vector<BlockStatement*> blocks;
53 
55  std::vector<type_t> fields;
56 
58  std::vector<std::string> labels;
59 
60  virtual variable_t *addVariable(type_t type, const char* name,
61  expression_t init) = 0;
62  virtual bool addFunction(type_t type, const char* name) = 0;
63 
64  static void collectDependencies(std::set<symbol_t> &, expression_t );
65  static void collectDependencies(std::set<symbol_t> &, type_t );
66 
67  public:
70 
71  void typeArrayOfSize(size_t) override;
72  void typeArrayOfType(size_t) override;
73  void typeStruct(PREFIX, uint32_t fields) override;
74  void structField(const char* name) override;
75  void declTypeDef(const char* name) override;
76  void declVar(const char* name, bool init) override;
77  void declInitialiserList(uint32_t num) override;
78  void declFieldInit(const char* name) override;
79  void declParameter(const char* name, bool) override;
80  void declFuncBegin(const char* name) override;
81  void declFuncEnd() override;
82  void blockBegin() override;
83  void blockEnd() override;
84  void emptyStatement() override;
85  void forBegin() override;
86  void forEnd() override;
87  void iterationBegin(const char *name) override;
88  void iterationEnd(const char *name) override;
89  void whileBegin() override;
90  void whileEnd() override;
91  void doWhileBegin() override;
92  void doWhileEnd() override;
93  void ifBegin() override {};
94  void ifCondition() override {}; // 1 expr
95  void ifThen() override {}; // 1 expr, 1 statement
96  void ifEnd(bool) override; // 1 expr, 1 or 2 statements
97  void exprStatement() override;
98  void returnStatement(bool) override;
99  void assertStatement() override;
100  void exprCallBegin() override;
101  };
102 }
103 #endif
void typeArrayOfSize(size_t) override
Called to create an array type.
void declInitialiserList(uint32_t num) override
void ifBegin() override
std::vector< std::string > labels
The labels of a struct.
std::vector< type_t > fields
The types of a struct.
void declTypeDef(const char *name) override
A type definition.
void iterationBegin(const char *name) override
void ifCondition() override
void declParameter(const char *name, bool) override
void iterationEnd(const char *name) override
void typeArrayOfType(size_t) override
Called to create an array type.
Partial implementation of the builder interface, useful for building something with statements that i...
void ifThen() override
Partial implementation of the builder interface: The ExpressionBuilder implements all expression rela...
StatementBuilder(TimedAutomataSystem *)
void returnStatement(bool) override
Base type for variables, clocks, etc.
Definition: system.h:43
function_t * currentFun
The function currently being parsed.
void emptyStatement() override
static void collectDependencies(std::set< symbol_t > &, expression_t)
void exprStatement() override
A reference to a frame.
Definition: symbols.h:183
A reference to a type.
Definition: type.h:93
void structField(const char *name) override
Used to declare the fields of a structure.
frame_t params
The params frame is used temporarily during parameter parsing.
void declFieldInit(const char *name) override
virtual bool addFunction(type_t type, const char *name)=0
void ifEnd(bool) override
A reference to an expression.
Definition: expression.h:70
Information about a function.
Definition: system.h:110
void typeStruct(PREFIX, uint32_t fields) override
Used to construct a new struct type, which is then pushed onto the type stack.
void declFuncBegin(const char *name) override
void assertStatement() override
std::vector< BlockStatement * > blocks
Stack of nested statement blocks.
Definition: lexer.cc:817
void doWhileBegin() override
void exprCallBegin() override
virtual variable_t * addVariable(type_t type, const char *name, expression_t init)=0
void declVar(const char *name, bool init) override
Declare a new variable of the given name.