pd_gotoattributes.cppGo to the documentation of this file.00001 /** @file pd_gotoattributes.cpp Attributes for LR machines*/ 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_gotoattributes.h" 00011 00012 namespace faudes { 00013 00014 00015 /******************************* 00016 * 00017 * Implementation of AttributeGotoTransition 00018 * 00019 */ 00020 00021 // faudes type std 00022 FAUDES_TYPE_IMPLEMENTATION(Void,AttributeGotoTransition,AttributeVoid) 00023 00024 // Assign my members 00025 void AttributeGotoTransition::DoAssign(const AttributeGotoTransition& rSrcAttr) { 00026 // call base (incl. virtual clear) 00027 AttributeVoid::DoAssign(rSrcAttr); 00028 // my additional members 00029 mpGrammarSymbol = rSrcAttr.mpGrammarSymbol; 00030 } 00031 00032 // Equality 00033 bool AttributeGotoTransition::DoEqual(const AttributeGotoTransition& rOther) const { 00034 // my members 00035 if(*mpGrammarSymbol!=*rOther.mpGrammarSymbol) return false; 00036 // pass 00037 return true; 00038 } 00039 00040 //DoWrite(rTw,rLabel,pContext); 00041 void AttributeGotoTransition::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const { 00042 (void) pContext; 00043 if(IsDefault()) return; 00044 std::string label=rLabel; 00045 if(label=="") label=""; 00046 FD_DC("AttributeGotoTransition(" << this << ")::DoWrite(tr): to section " << label); 00047 00048 rTw.WriteText(mpGrammarSymbol->Str()); 00049 00050 } 00051 00052 //DoRead(rTr,rLabel,pContext) 00053 void AttributeGotoTransition::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) { 00054 std::string label=rLabel; 00055 if(label=="") label=""; 00056 FD_DC("AttributeGotoTransition(" << this << ")::DoRead(tr): from section " << label); 00057 (void) pContext; 00058 mpGrammarSymbol = GrammarSymbolPtr(); 00059 Token token; 00060 rTr.Peek(token); 00061 if(!token.IsBegin()) return; 00062 if(token.StringValue()!=label) return; 00063 //mStackSymbols.Read(rTr,label); 00064 //TODO implement? 00065 } 00066 00067 00068 /******************************* 00069 * 00070 * Implementation of AttributeGotoState 00071 * 00072 */ 00073 00074 // faudes type std 00075 FAUDES_TYPE_IMPLEMENTATION(Void,AttributeGotoState,AttributeFlags) 00076 00077 // Assign my members 00078 void AttributeGotoState::DoAssign(const AttributeGotoState& rSrcAttr) { 00079 // call base (incl. virtual clear) 00080 AttributeFlags::DoAssign(rSrcAttr); 00081 // my additional members 00082 mConfigSet=rSrcAttr.mConfigSet; 00083 } 00084 00085 // Equality 00086 bool AttributeGotoState::DoEqual(const AttributeGotoState& rOther) const { 00087 // base 00088 if(!AttributeFlags::DoEqual(rOther)) return false; 00089 // my members 00090 if(CompareConfigSet(mConfigSet,rOther.mConfigSet) || CompareConfigSet(rOther.mConfigSet,mConfigSet)) return false; 00091 // pass 00092 return true; 00093 } 00094 00095 00096 //DoWrite(rTw,rLabel,pContext); 00097 void AttributeGotoState::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const { 00098 (void) pContext; 00099 if(IsDefault()) return; 00100 AttributeFlags::DoWrite(rTw,"",pContext); 00101 std::string label=rLabel; 00102 if(label=="") label="State"; 00103 FD_DC("AttributeGotoState(" << this << ")::DoWrite(tr): to section " << label); 00104 00105 rTw.WriteText(ConfigSetToStr(mConfigSet) + "\n"); 00106 } 00107 00108 00109 //DoRead(rTr,rLabel,pContext) 00110 void AttributeGotoState::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) { 00111 // call base first 00112 AttributeFlags::DoRead(rTr,"",pContext); 00113 // figure my section 00114 std::string label=rLabel; 00115 if(label=="") label="State"; 00116 FD_DC("AttributeGotoState(" << this << ")::DoRead(tr): from section " << label); 00117 // clear my data 00118 mConfigSet.clear(); 00119 // test my section 00120 Token token; 00121 rTr.Peek(token); 00122 if(!token.IsBegin()) return; 00123 if(token.StringValue()!=label) return; 00124 // read my section (can throw exceptions now) 00125 //TODO implement? 00126 } 00127 00128 00129 00130 } // namespace faudes 00131 libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen |