libutap  0.93
Uppaal Timed Automata Parser
prettyprinter.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-2003 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_PRETTYPRINTER_H
23 #define UTAP_PRETTYPRINTER_H
24 
25 #include <string>
26 #include <vector>
27 #include <ostream>
28 #include <stack>
29 #include "utap/abstractbuilder.h"
30 
31 namespace UTAP
32 {
33 
35  {
36  private:
37  std::vector<std::string> st;
38  std::stack<std::string> type;
39  std::stack<std::string> array;
40  std::vector<std::string> fields;
41  std::stack<std::ostream *> o;
42  std::set<std::string> types;
43  std::string branchpoints;
44  std::string urgent;
45  std::string committed;
46  std::string param;
47  std::string templateset;
48  int select, guard, sync, update, probability;
49 
50  bool first;
51  uint32_t level;
52 
53  void indent();
54 
55  public:
56  PrettyPrinter(std::ostream &stream);
57 
58  void addPosition(
59  uint32_t position, uint32_t offset, uint32_t line, const std::string& path) override;
60 
61  void handleError(const std::string&) override;
62  void handleWarning(const std::string&) override;
63 
64  bool isType(const char *) override;
65  void typeBool(PREFIX) override;
66  void typeInt(PREFIX) override;
67  void typeDouble(PREFIX) override;
68  void typeBoundedInt(PREFIX) override;
69  void typeChannel(PREFIX) override;
70  void typeClock(PREFIX) override;
71  void typeVoid() override;
72  void typeScalar(PREFIX) override;
73  void typeName(PREFIX, const char *type) override;
74  void typePop() override;
75  void typeDuplicate() override;
76  void typeArrayOfSize(size_t n) override;
77  void typeArrayOfType(size_t n) override;
78  void typeStruct(PREFIX prefix, uint32_t n) override;
79  void structField(const char* name) override;
80  void declTypeDef(const char* name) override;
81  void declVar(const char *id, bool init) override;
82  void declInitialiserList(uint32_t num) override;
83  void declFieldInit(const char* name) override;
84  void declParameter(const char* name, bool) override;
85  void declFuncBegin(const char* name) override;
86  void declFuncEnd() override;
87  void blockBegin() override;
88  void blockEnd() override;
89  void emptyStatement() override;
90  void forBegin() override;
91  void forEnd() override;
92  void iterationBegin(const char *name) override; // 1 id, 1 type
93  void iterationEnd(const char *name) override; // 1 stat
94  void whileBegin() override;
95  void whileEnd() override;
96  void doWhileBegin() override;
97  void doWhileEnd() override;
98  void ifBegin() override;
99  void ifCondition() override;
100  void ifThen() override;
101  void ifEnd(bool) override;
102  void breakStatement() override;
103  void continueStatement() override;
104  void exprStatement() override;
105  void returnStatement(bool hasValue) override;
106  void procBegin(const char* name, const bool isTA = true,
107  const std::string type = "", const std::string mode = "") override;
108  void procState(const char *id, bool hasInvariant, bool hasExpRate) override;
109  void procBranchpoint(const char *id) override;
110  void procStateUrgent(const char *id) override;
111  void procStateCommit(const char *id) override;
112  void procStateInit(const char *id) override;
113  void procSelect(const char *id) override;
114  void procGuard() override;
115  void procSync(Constants::synchronisation_t type) override;
116  void procUpdate() override;
117  void procProb() override;
118  void procEdgeBegin(const char *source, const char *target, const bool control);
119  void procEdgeBegin(const char *source, const char *target, const bool control, const char* actname) override;
120  void procEdgeEnd(const char *source, const char *target) override;
121  void procEnd() override;
122  void exprId(const char *id) override;
123  void exprNat(int32_t n) override;
124  void exprDouble(double d) override;
125  void exprTrue() override;
126  void exprFalse() override;
127  void exprCallBegin() override;
128  void exprCallEnd(uint32_t n) override;
129  void exprArray() override;
130  void exprPostIncrement() override;
131  void exprPreIncrement() override;
132  void exprPostDecrement() override;
133  void exprPreDecrement() override;
134  void exprAssignment(Constants::kind_t op) override;
135  void exprUnary(Constants::kind_t op) override;
136  void exprBinary(Constants::kind_t op) override;
137  void exprNary(Constants::kind_t op, uint32_t num) override;
138  void exprScenario(const char* name) override;
139  void exprTernary(Constants::kind_t op, bool firstMissing) override;
140  void exprInlineIf() override;
141  void exprComma() override;
142  void exprDot(const char *) override;
143  void exprDeadlock() override;
144  void exprForAllBegin(const char *name) override;
145  void exprForAllEnd(const char *name) override;
146  void exprExistsBegin(const char *name) override;
147  void exprExistsEnd(const char *name) override;
148  void exprSumBegin(const char *name) override;
149  void exprSumEnd(const char *name) override;
151  void exprSimulate(int,bool,int) override;
152  void exprMitlDiamond (int,int) override;
153  void exprMitlBox (int,int) override;
154  void exprBuiltinFunction1(Constants::kind_t kind) override;
155  void exprBuiltinFunction2(Constants::kind_t kind) override;
156  void exprBuiltinFunction3(Constants::kind_t kind) override;
157  void beforeUpdate() override;
158  void afterUpdate() override;
159  void instantiationBegin(const char *, size_t, const char *) override;
160  void instantiationEnd(const char *, size_t, const char *, size_t) override;
161  void process(const char *id) override;
162  void processListEnd() override;
163  void done() override;
164 
166  void queryBegin() override;
167  void queryFormula(const char* formula, const char* location) override;
168  void queryComment(const char* comment) override;
169  void queryEnd() override;
170  };
171 }
172 
173 #endif
void ifCondition() override
void exprDeadlock() override
void exprSumBegin(const char *name) override
void typeClock(PREFIX) override
Called whenever a clock type is parsed.
void beforeUpdate() override
void blockBegin() override
void typeName(PREFIX, const char *type) override
Called when a type name has been parsed.
void declParameter(const char *name, bool) override
void procStateCommit(const char *id) override
void exprTrue() override
void whileBegin() override
bool isType(const char *) override
Must return true if and only if name is registered in the symbol table as a named type...
void exprPostIncrement() override
void exprPreIncrement() override
void typeArrayOfSize(size_t n) override
Called to create an array type.
void procEnd() override
void typeDouble(PREFIX) override
Called whenever a double type is parsed.
void procBegin(const char *name, const bool isTA=true, const std::string type="", const std::string mode="") override
void exprFalse() override
void process(const char *id) override
void exprMitlDiamond(int, int) override
void procGuard() override
void instantiationEnd(const char *, size_t, const char *, size_t) override
void declFuncEnd() override
void returnStatement(bool hasValue) override
void typeStruct(PREFIX prefix, uint32_t n) override
Called when a struct-type has been parsed.
void iterationBegin(const char *name) override
void instantiationBegin(const char *, size_t, const char *) override
void exprNary(Constants::kind_t op, uint32_t num) override
void exprDot(const char *) override
void processListEnd() override
void procProb() override
void exprExistsBegin(const char *name) override
void declVar(const char *id, bool init) override
Called to when a variable declaration has been parsed.
void exprAssignment(Constants::kind_t op) override
void exprInlineIf() override
void afterUpdate() override
void exprSimulate(int, bool, int) override
void typeBool(PREFIX) override
Called whenever a boolean type is parsed.
void exprId(const char *id) override
void addPosition(uint32_t position, uint32_t offset, uint32_t line, const std::string &path) override
Add mapping from an absolute position to a relative XML element.
void emptyStatement() override
void exprBuiltinFunction2(Constants::kind_t kind) override
void procSelect(const char *id) override
void exprForAllEnd(const char *name) override
void typeVoid() override
Called whenever a void type is parsed.
void procStateInit(const char *id) override
void exprNat(int32_t n) override
void iterationEnd(const char *name) override
void exprUnary(Constants::kind_t op) override
void typeBoundedInt(PREFIX) override
Called whenever an integer type with a range is parsed.
#define comment
Definition: lexer.cc:856
void queryEnd() override
void typeChannel(PREFIX) override
Called whenever a channel type is parsed.
void procUpdate() override
void forBegin() override
void structField(const char *name) override
Called to declare a field of a structure.
void typeInt(PREFIX) override
Called whenever an integer type is parsed.
void queryBegin() override
Verification queries.
void breakStatement() override
void exprDouble(double d) override
void procEdgeBegin(const char *source, const char *target, const bool control)
void declFuncBegin(const char *name) override
void done() override
void exprArray() override
void ifEnd(bool) override
void exprExistsEnd(const char *name) override
void ifThen() override
void typePop() override
Pop type at the topof the type stack.
void exprCallBegin() override
void exprProbaQuantitative(Constants::kind_t) override
void handleError(const std::string &) override
void exprBuiltinFunction3(Constants::kind_t kind) override
void procSync(Constants::synchronisation_t type) override
void declTypeDef(const char *name) override
Used when a typedef declaration was parsed.
void exprCallEnd(uint32_t n) override
void exprPostDecrement() override
void declFieldInit(const char *name) override
void exprBuiltinFunction1(Constants::kind_t kind) override
void procState(const char *id, bool hasInvariant, bool hasExpRate) override
void procBranchpoint(const char *id) override
void typeDuplicate() override
Duplicate type at the top of the type stack.
void forEnd() override
void queryFormula(const char *formula, const char *location) override
void exprStatement() override
void exprTernary(Constants::kind_t op, bool firstMissing) override
void exprMitlBox(int, int) override
void blockEnd() override
void exprScenario(const char *name) override
void procStateUrgent(const char *id) override
void typeScalar(PREFIX) override
Called whenever a scalar type is parsed.
void handleWarning(const std::string &) override
void exprBinary(Constants::kind_t op) override
void declInitialiserList(uint32_t num) override
void ifBegin() override
void doWhileEnd() override
Definition: lexer.cc:817
PrettyPrinter(std::ostream &stream)
void exprSumEnd(const char *name) override
void whileEnd() override
void exprComma() override
void typeArrayOfType(size_t n) override
Called to create an array type.
void exprPreDecrement() override
void continueStatement() override
void queryComment(const char *comment) override
void exprForAllBegin(const char *name) override
void doWhileBegin() override
void procEdgeEnd(const char *source, const char *target) override