pd_basics.cpp
Go to the documentation of this file.
1 /** @file pd_basics.cpp Attributes for pushdown automata */
2 
3 
4 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
5 
6  Copyright (C) 2013 Stefan Jacobi, Sven Schneider, Anne-Kathrin Hess
7 
8 */
9 
10 #include "pd_basics.h"
11 
12 namespace faudes {
13 
14 /********************************************************************
15 
16  Implementation of StackSymbolSet
17 
18 ********************************************************************/
19 
20 
21 // std faudes type (cannot do New() with macro)
22 FAUDES_TYPE_IMPLEMENTATION_COPY(Void,StackSymbolSet,NameSet)
23 FAUDES_TYPE_IMPLEMENTATION_CAST(Void,StackSymbolSet,NameSet)
24 FAUDES_TYPE_IMPLEMENTATION_ASSIGN(Void,StackSymbolSet,NameSet)
25 FAUDES_TYPE_IMPLEMENTATION_EQUAL(Void,StackSymbolSet,NameSet)
26 
27 // StackSymbolSet::msStackSymbolTable (static)
28 SymbolTable StackSymbolSet::msSymbolTable;
29 
30 // StackSymbolSet(void);
31 StackSymbolSet::StackSymbolSet(void) : NameSet() {
32  // overwrite default static symboltable
33  mpSymbolTable= &msSymbolTable;
34  NameSet::Name("StackSymbols");
35  FD_DC("StackSymbolSet("<<this<<")::StackSymbolSet() with csymtab "<< SymbolTablep());
36 }
37 
38 // StackSymbolSet(StackSymbolSet)
39 StackSymbolSet::StackSymbolSet(const StackSymbolSet& rOtherSet) : NameSet(rOtherSet) {
40  FD_DC("StackSymbolSet(" << this << ")::StackSymbolSet(rOtherSet " << &rOtherSet << ")");
41 }
42 
43 // StackSymbolSet(file);
44 StackSymbolSet::StackSymbolSet(const std::string& rFilename, const std::string& rLabel) : NameSet() {
45  // overwrite default static symboltable
46  mpSymbolTable= &msSymbolTable; NameSet::Name("StackSymbols");
47  // read file
48  NameSet::Read(rFilename,rLabel);
49 }
50 
51 // StackSymbolSet::New()
53  StackSymbolSet* res = new StackSymbolSet();
55  return res;
56 }
57 
58 // DoAssign()
59 void StackSymbolSet::DoAssign(const StackSymbolSet& rSourceSet) {
60  // call base
61  NameSet::DoAssign(rSourceSet);
62 }
63 
64 // DoEqual()
65 bool StackSymbolSet::DoEqual(const StackSymbolSet& rOtherSet) const {
66  // call base
67  return NameSet::DoEqual(rOtherSet);
68 }
69 
70 // StackSymbolSet::StaticSymbolTablep
72  return &msSymbolTable;
73 }
74 
75 /********************************************************************
76 
77  Implementation of StackSymbol
78 
79 ********************************************************************/
80 
82  Write(tw,mSymbol);
83 }
84 
85 void StackSymbol::Write(TokenWriter& tw, const std::string& rLabel) const{
86  Token token;
87  int oldcolumns = tw.Columns();
88  tw.Columns(1);
89  tw.WriteBegin(rLabel);
90 
91  token.SetString(mSymbol);
92  tw << token;
93 
94  tw.WriteEnd(rLabel);
95  tw.Columns(oldcolumns);
96 }
97 
98 bool StackSymbol::operator!=(const StackSymbol &other) const{
99  if (mSymbol.compare(other.mSymbol) == 0)
100  return false;
101  return true;
102 }
103 
104 bool StackSymbol::operator==(const StackSymbol &other) const{
105  if (mSymbol.compare(other.mSymbol) == 0)
106  return true;
107  return false;
108 }
109 
110 bool StackSymbol::operator<(const StackSymbol &other) const{
111  if (mSymbol.compare(other.mSymbol) < 0)
112  return true;
113  return false;
114 }
115 
117  if (mSymbol.compare(FAUDES_PD_LAMBDA) == 0)
118  return true;
119  return false;
120 }
121 
122 std::string StackSymbol::ToString() const{
123  return mSymbol;
124 }
125 
126 bool StackSymbol::Empty() const{
127  if (mSymbol.compare("") == 0)
128  return true;
129  return false;
130 }
131 
132 } // namespace faudes
133 

libFAUDES 2.28c --- 2016.09.30 --- c++ api documentaion by doxygen