libutap  0.93
Uppaal Timed Automata Parser
symbols.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-2006 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_SYMBOLS_HH
23 #define UTAP_SYMBOLS_HH
24 
25 #include "utap/common.h"
26 #include "utap/position.h"
27 #include "utap/type.h"
28 
29 #include <cinttypes>
30 #include <exception>
31 
32 namespace UTAP
33 {
34  class frame_t;
35  class expression_t;
36 
37  class NoParentException : public std::exception {};
38 
41  class range_t
42  {
43  public:
44  int lower, upper;
45 
47  range_t();
48 
50  range_t(int);
51 
53  range_t(int,int);
54 
56  range_t(const std::pair<int,int> &);
57 
59  range_t intersect(const range_t &) const;
60 
62  range_t join(const range_t &) const;
63 
65  bool contains(const range_t &) const;
66 
68  bool contains(int32_t) const;
69 
71  bool operator == (const range_t &) const;
72 
74  bool operator != (const range_t &) const;
75 
77  range_t operator| (const range_t &) const;
78 
80  range_t operator& (const range_t &) const;
81 
83  bool isEmpty() const;
84 
85  uint32_t size() const;
86  };
87 
107  class symbol_t
108  {
109  private:
110  struct symbol_data;
111  symbol_data *data;
112  protected:
113  friend class frame_t;
114  symbol_t(void *frame, type_t type, const std::string& name, void *user);
115  public:
117  symbol_t() : data(nullptr) {}
118 
120  symbol_t(const symbol_t &);
121 
123  ~symbol_t();
124 
126  const symbol_t &operator = (const symbol_t &);
127 
129  bool operator == (const symbol_t &) const;
130 
132  bool operator != (const symbol_t &) const;
133 
135  bool operator < (const symbol_t &) const;
136 
138  frame_t getFrame();
139 
141  type_t getType() const;
142 
144  void setType(type_t);
145 
147  void *getData();
148 
150  const void *getData() const;
151 
153  std::string getName() const;
154 
156  void setName(const std::string&);
157 
159  void setData(void *);
160  };
161 
183  class frame_t
184  {
185  private:
186  struct frame_data;
187  frame_data *data;
188  protected:
189  friend class symbol_t;
190  frame_t(void *);
191  public:
193  frame_t();
194 
196  frame_t(const frame_t &);
197 
199  ~frame_t();
200 
202  const frame_t &operator = (const frame_t &);
203 
205  bool operator == (const frame_t &) const;
206 
208  bool operator != (const frame_t &) const;
209 
211  uint32_t getSize() const;
212 
214  symbol_t getSymbol(int32_t);
215 
217  int32_t getIndexOf(const std::string& name) const;
218 
220  int32_t getIndexOf(symbol_t) const;
221 
223  symbol_t operator[] (int32_t);
224 
226  const symbol_t operator[] (int32_t) const;
227 
229  symbol_t addSymbol(const std::string& name, type_t, void *user = NULL);
230 
232  void add(symbol_t);
233 
235  void add(frame_t);
236 
238  void moveTo(frame_t);
239 
241  void remove(symbol_t s);
242 
244  bool resolve(const std::string& name, symbol_t &symbol);
245 
247  frame_t getParent(); // throw (NoParentException);
248 
250  bool hasParent() const;
251 
253  static frame_t createFrame();
254 
256  static frame_t createFrame(const frame_t &parent);
257 
258  std::string toString();
259 
260  bool empty();
261  };
262 }
263 
264 std::ostream &operator << (std::ostream &o, UTAP::symbol_t t);
265 std::ostream &operator << (std::ostream &o, UTAP::frame_t t);
266 
267 #endif
A reference to a symbol.
Definition: symbols.h:107
std::ostream & operator<<(std::ostream &os, const SignalFlow::strs_t &s)
Definition: signalflow.h:189
symbol_t()
Default constructor.
Definition: symbols.h:117
static string symbol(const char *str)
Extracts the alpha-numerical symbol used for variable/type identifiers.
Definition: xmlreader.cpp:107
An integer range.
Definition: symbols.h:41
A reference to a frame.
Definition: symbols.h:183
A reference to a type.
Definition: type.h:93
Definition: lexer.cc:817