void NassiSwitchBrick::GetStrukTeX(wxString &str, wxUint32 n = 0) { for ( wxUint32 i = 0 ; i < n ; i++ ) str += _T(" "); str += _T("\\case{4}"); str += _T("{") + wxString::Format(_T("%d"), GetChildCount()) + _T("}"); str += _T("{") + *(GetTextByNumber(0)) + _T("}"); str += _T("{") + *(GetTextByNumber(2)) + _T("}\n"); NassiBrick *child = GetChild(0); if ( child ) child->GetStrukTeX(str, n+2); for ( wxUint32 i = 1 ; i < GetChildCount() ; i++ ) { for ( wxUint32 k = 0 ; k < n ; k++ ) str += _T(" "); str += _T("\\switch{") + *(GetTextByNumber(2*(i+1))) + _T("}\n"); child = GetChild(i); if ( child ) child->GetStrukTeX(str, n+2); } for ( wxUint32 i = 0 ; i < n ; i++ ) str += _T(" "); str += _T("\\caseend\n"); NassiBrick *next = GetNext(); if ( next ) next->GetStrukTeX(str, n); }
void NassiSwitchBrick::SaveSource(wxTextOutputStream &text_stream, wxUint32 n) { SaveCommentString(text_stream, Comment, n); const wxString srce = _T("switch ( ") + Source + _T(" )\n{"); SaveSourceString(text_stream, srce, n); for ( wxUint32 i = 0 ; i < GetChildCount(); i++ ) { NassiBrick *child = GetChild(i); const wxString cmt(*GetTextByNumber((i+1)*2)); wxString src = *GetTextByNumber((i+1)*2+1); if ( src.StartsWith( _T("default") ) ) src = _T("default:"); else src = _T("case ") + src + _T(":"); SaveCommentString(text_stream, cmt, n); SaveSourceString(text_stream, src, n); if ( child ) child->SaveSource(text_stream, n+4); } SaveSourceString(text_stream, _T("}"), n); NassiBrick::SaveSource(text_stream, n); }
void NassiIfBrick::GetStrukTeX(wxString &str, wxUint32 n = 0) { for ( wxUint32 i = 0 ; i < n ; i++ ) str += _T(" "); str += _T("\\ifthenelse{3}{3}"); str += (_T("{") + *(GetTextByNumber(0)) + _T("}")); str += (_T("{") + *(GetTextByNumber(2)) + _T("}")); str += (_T("{") + *(GetTextByNumber(4)) + _T("}\n")); NassiBrick *child = GetChild(0); if ( child ) child->GetStrukTeX(str, n+2); for ( wxUint32 i = 0 ; i < n ; i++ ) str += _T(" "); str += _T("\\change\n"); child = GetChild(1); if ( child ) child->GetStrukTeX(str, n+2); for ( wxUint32 i = 0 ; i < n ; i++ ) str += _T(" "); str += _T("\\ifend\n"); NassiBrick *next = GetNext(); if ( next ) next->GetStrukTeX(str, n); }
//public: virtual wxOutputStream &NassiContinueBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_CONTINUE << _T('\n'); SerializeString(stream, *(GetTextByNumber(0)) ); if ( GetNext() != nullptr ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }
//public: virtual wxOutputStream &NassiInstructionBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_INSTRUCTION << _T('\n'); for (wxUint32 n = 0 ; n < 2 ; n++ ) SerializeString(stream,*GetTextByNumber(n)); if ( GetNext() != nullptr ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }
void NassiBreakBrick::GetStrukTeX(wxString &str, wxUint32 n = 0) { for ( wxUint32 i = 0 ; i < n ; i++ ) str += _T(" "); str += _T("\\exit{"); str += *(GetTextByNumber(0)); str += _T("}\n"); NassiBrick *next = GetNext(); if ( next ) next->GetStrukTeX(str, n); }
//public: virtual wxOutputStream &NassiReturnBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_RETURN << _T('\n'); for (wxUint32 n = 0 ; n < 2 ; n++ ) SerializeString(stream, *(GetTextByNumber(n)) ); if ( GetNext() != (NassiBrick *)NULL ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }
//public: virtual wxOutputStream &NassiBreakBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_BREAK << _T('\n'); SerializeString(stream, *(GetTextByNumber(0))); if ( GetNext() != (NassiBrick *)NULL ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }
void NassiForBrick::GetStrukTeX(wxString &str, wxUint32 n = 0) { ///instruction for ( wxUint32 i = 0 ; i < n ; i++ ) str += _T(" "); str += _T("\\assign{"); str += *(GetTextByNumber(2)); //init comment str += _T("}\n"); ///loop for ( wxUint32 i = 0 ; i < n ; i++ ) str += _T(" "); str += _T("\\while{"); str += *(GetTextByNumber(0)); //main comment str += _T("}\n"); ///child NassiBrick *child = GetChild(0); if ( child ) child->GetStrukTeX(str, n+2); ///instruction at end for (wxUint32 i = 0 ; i < n+2 ; i++ ) str+= _T(" "); str+= _T("\\assign{"); str += *(GetTextByNumber(4)); //inst comment str += _T("}\n"); ///end of loop for ( wxUint32 i = 0 ; i < n ; i++ ) str += _T(" "); str += _T("\\whileend\n"); ///next brick NassiBrick *next = GetNext(); if ( next ) next->GetStrukTeX(str, n); }
wxOutputStream &NassiWhileBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_WHILE << _T('\n'); for ( wxUint32 n = 0 ; n < 2 ; n++ ) SerializeString(stream, *(GetTextByNumber(n)) ); if ( GetChild(0) != nullptr ) GetChild(0)->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); if ( GetNext() != nullptr ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }
void NassiWhileBrick::GetStrukTeX(wxString &str, wxUint32 n = 0) { for ( wxUint32 i = 0 ; i < n ; i++ ) str += _T(" "); str += _T("\\while{"); str += *(GetTextByNumber(0)); str += _T("}\n"); NassiBrick *child = GetChild(0); if ( child ) child->GetStrukTeX(str, n+2); for ( wxUint32 i = 0 ; i < n ; i++ ) str += _T(" "); str += _T("\\whileend\n"); NassiBrick *next = GetNext(); if ( next ) next->GetStrukTeX(str, n); }
//public: virtual wxOutputStream &NassiSwitchBrick::Serialize(wxOutputStream &stream) { wxTextOutputStream out(stream); out << NASSI_BRICK_SWITCH << _T('\n'); wxUint32 k = nChilds; out << k << _T('\n'); for ( wxUint32 n = 0 ; n < 2*k+2 ; n++ ) SerializeString( stream, *(GetTextByNumber(n)) ); for ( wxUint32 n = 0 ; n < k ; n++ ) { if ( GetChild(n) != nullptr ) GetChild(n)->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); } if ( GetNext() != nullptr ) GetNext()->Serialize(stream); else out << NASSI_BRICK_ESC << _T('\n'); return stream; }