pd_basics.cpp

Go to the documentation of this file.
00001 /** @file pd_basics.cpp  Attributes for pushdown automata */
00002 
00003 
00004 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
00005 
00006    Copyright (C) 2013  Stefan Jacobi, Sven Schneider, Anne-Kathrin Hess
00007 
00008 */
00009 
00010 #include "pd_basics.h"
00011 
00012 namespace faudes {
00013   
00014 /********************************************************************
00015 
00016  Implementation of StackSymbolSet
00017 
00018 ********************************************************************/
00019 
00020 
00021 // std faudes type (cannot do New() with macro)
00022 FAUDES_TYPE_IMPLEMENTATION_COPY(Void,StackSymbolSet,NameSet)
00023 FAUDES_TYPE_IMPLEMENTATION_CAST(Void,StackSymbolSet,NameSet)
00024 FAUDES_TYPE_IMPLEMENTATION_ASSIGN(Void,StackSymbolSet,NameSet)
00025 FAUDES_TYPE_IMPLEMENTATION_EQUAL(Void,StackSymbolSet,NameSet)
00026 
00027 // StackSymbolSet::msStackSymbolTable (static)
00028 SymbolTable StackSymbolSet::msSymbolTable;
00029 
00030 // StackSymbolSet(void);
00031 StackSymbolSet::StackSymbolSet(void) : NameSet() { 
00032   // overwrite default static symboltable 
00033   mpSymbolTable= &msSymbolTable; 
00034   NameSet::Name("StackSymbols"); 
00035   FD_DC("StackSymbolSet("<<this<<")::StackSymbolSet() with csymtab "<< SymbolTablep());
00036 }
00037 
00038 // StackSymbolSet(StackSymbolSet)
00039 StackSymbolSet::StackSymbolSet(const StackSymbolSet& rOtherSet) : NameSet(rOtherSet) {
00040   FD_DC("StackSymbolSet(" << this << ")::StackSymbolSet(rOtherSet " << &rOtherSet << ")");
00041 }
00042 
00043 // StackSymbolSet(file);
00044 StackSymbolSet::StackSymbolSet(const std::string& rFilename, const std::string& rLabel) : NameSet() {
00045   // overwrite default static symboltable 
00046   mpSymbolTable= &msSymbolTable; NameSet::Name("StackSymbols"); 
00047   // read file
00048   NameSet::Read(rFilename,rLabel);
00049 }
00050 
00051 // StackSymbolSet::New()
00052 StackSymbolSet* StackSymbolSet::New(void) const {
00053   StackSymbolSet* res = new StackSymbolSet();
00054   res->mpSymbolTable=mpSymbolTable;
00055   return res;
00056 }
00057 
00058 // DoAssign()
00059 void StackSymbolSet::DoAssign(const StackSymbolSet& rSourceSet) {
00060   // call base
00061   NameSet::DoAssign(rSourceSet);
00062 }
00063 
00064 // DoEqual()
00065 bool StackSymbolSet::DoEqual(const StackSymbolSet& rOtherSet) const {
00066   // call base
00067   return NameSet::DoEqual(rOtherSet);
00068 }
00069 
00070 // StackSymbolSet::StaticSymbolTablep
00071 SymbolTable* StackSymbolSet::StaticSymbolTablep(void) {
00072   return &msSymbolTable;
00073 }
00074 
00075 /********************************************************************
00076 
00077  Implementation of StackSymbol
00078 
00079 ********************************************************************/
00080 
00081 void StackSymbol::Write(TokenWriter& tw) const{
00082   Write(tw,mSymbol);
00083 }
00084 
00085 void StackSymbol::Write(TokenWriter& tw, const std::string& rLabel) const{
00086   Token token;
00087   int oldcolumns = tw.Columns();
00088   tw.Columns(1);
00089   tw.WriteBegin(rLabel);
00090   
00091   token.SetString(mSymbol);
00092   tw << token;
00093 
00094   tw.WriteEnd(rLabel);
00095   tw.Columns(oldcolumns);
00096 }
00097 
00098 bool StackSymbol::operator!=(const StackSymbol &other) const{
00099   if (mSymbol.compare(other.mSymbol) == 0)
00100     return false;
00101   return true;
00102 }
00103 
00104 bool StackSymbol::operator==(const StackSymbol &other) const{
00105   if (mSymbol.compare(other.mSymbol) == 0)
00106     return true;
00107   return false;
00108 }
00109 
00110 bool StackSymbol::operator<(const StackSymbol &other) const{
00111   if (mSymbol.compare(other.mSymbol) < 0)
00112     return true;
00113   return false;
00114 }
00115 
00116 bool StackSymbol::IsLambda() const{
00117   if (mSymbol.compare(FAUDES_PD_LAMBDA) == 0)
00118     return true;
00119   return false;
00120 }
00121 
00122 std::string StackSymbol::ToString() const{
00123   return mSymbol;
00124 }
00125 
00126 bool StackSymbol::Empty() const{
00127   if (mSymbol.compare("") == 0)
00128     return true;
00129   return false;
00130 }
00131 
00132 } // namespace faudes
00133 

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen