Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
void NassiIfBrick::SaveSource(wxTextOutputStream &text_stream, wxUint32 n)
{
    SaveCommentString(text_stream, Comment, n);

    wxString src = _T("if ") + Source;
    SaveSourceString(text_stream, src, n);

    SaveCommentString(text_stream, TrueCommentText, n+4);

    NassiBrick *child = GetChild(0);
    if ( child )
    {
        SaveSourceString(text_stream, _T("{"), n);
        child->SaveSource(text_stream, n+4);
        SaveSourceString(text_stream, _T("}"), n);
    }
    else
        SaveSourceString(text_stream, _T(";"), n+4);

    child = GetChild(1);
    if ( child )
    {
        SaveSourceString(text_stream, _T("else\n{"), n);

        SaveCommentString(text_stream, FalseCommentText, n+4);
        child->SaveSource(text_stream, n+4);

        SaveSourceString(text_stream, _T("}"), n);
    }


    NassiBrick::SaveSource(text_stream, n);
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
void NassiContinueBrick::GetStrukTeX(wxString &str, wxUint32 n = 0)
{
    /// is not siported by struktex
    NassiBrick *next = GetNext();
    if ( next )
        next->GetStrukTeX(str, n);
}
Ejemplo n.º 5
0
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);
}
Ejemplo n.º 6
0
void NassiBlockBrick::GetStrukTeX(wxString &str, wxUint32 n = 0)
{
    NassiBrick *child = GetChild(0);
    if ( child )
        child->GetStrukTeX(str, n);

    NassiBrick *next = GetNext();
    if ( next )
        next->GetStrukTeX(str, n);
}
Ejemplo n.º 7
0
void CreateNassiIfThenText::operator() ( wxChar const * /*first*/, wxChar const * /*last*/ ) const
{
    NassiBrick *parent;
    parent = m_brick->GetParent();

    parent->SetTextByNumber(m_c_str, 2);
    parent->SetTextByNumber(m_s_str, 3);
    m_c_str.clear();
    m_s_str.clear();
}
Ejemplo n.º 8
0
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);
}
Ejemplo n.º 9
0
void CreateNassiSwitchBrick::operator() ( wxChar const * /*first*/, wxChar const * /*last*/ ) const
{
    NassiBrick *brick = new NassiSwitchBrick();
    m_brick->SetNext(brick);
    brick->SetTextByNumber(m_c_str, 0);
    brick->SetTextByNumber(m_s_str, 1);
    m_c_str.clear();
    m_s_str.clear();
    m_brick = brick;
    brick = new NassiInstructionBrick();
    m_brick->AddChild(0);
    m_brick->SetChild(brick, 0);
    m_brick = brick;
}
//void CreateNassiWhileBrick::operator()(iterator_t first, iterator_t const& last)const
void CreateNassiWhileBrick::operator() ( wxChar const *first, wxChar const *last ) const
{
    NassiBrick *brick = new NassiWhileBrick();
    m_brick->SetNext( brick );
    brick->SetTextByNumber(m_c_str, 0);
    brick->SetTextByNumber(m_s_str, 1);
    m_c_str.clear();
    m_s_str.clear();
    m_brick = brick;

    brick = new NassiInstructionBrick();
    m_brick->SetChild(brick);
    m_brick = brick;
}
//void CreateNassiSwitchBrick::operator()(iterator_t first, iterator_t const& last)const
void CreateNassiSwitchBrick::operator() ( wxChar const *first, wxChar const *last ) const
{
    NassiBrick *brick = new NassiSwitchBrick();
    m_brick->SetNext(brick);
    brick->SetTextByNumber(m_c_str, 0);
    brick->SetTextByNumber(m_s_str, 1);
    m_c_str.clear();
    m_s_str.clear();
    m_brick = brick;
    brick = new NassiInstructionBrick();
    m_brick->AddChild(0);
    m_brick->SetChild(brick, 0);
    m_brick = brick;
    //wxMessageBox(_T("Switch brick"), _T("Created:"));
}
Ejemplo n.º 12
0
void CreateNassiBlockBrick::DoCreate() const
{
    NassiBrick *brick = new NassiBlockBrick();
    m_brick->SetNext( brick );
    brick->SetTextByNumber(m_c_str, 0);
    brick->SetTextByNumber(m_s_str, 1);
    m_c_str.clear();
    m_s_str.clear();
    m_brick = brick;

    brick = new NassiInstructionBrick();
    brick->SetTextByNumber( _("created by CreateNassiBlockBrick"), 0);
    m_brick->SetChild(brick);
    m_brick = brick;
}
Ejemplo n.º 13
0
void NassiBlockBrick::SaveSource(wxTextOutputStream &text_stream, wxUint32 n)
{
    SaveCommentString(text_stream, Comment, n);
    //SaveSourceString(text_stream, Source, n);

    SaveSourceString(text_stream, _T("{"), n);

    NassiBrick *child = GetChild(0);
    if ( child )
        child->SaveSource(text_stream, n+4);

    SaveSourceString(text_stream, _T("}"), n);


    NassiBrick::SaveSource(text_stream, n);
}
Ejemplo n.º 14
0
//static
NassiBrick *NassiBrick::SetData(wxInputStream &stream)
{
    wxUint32 n;
    NassiBrick *brick;
    wxTextInputStream inp(stream);
    inp >> n;
    switch ( n )
    {
        case NASSI_BRICK_INSTRUCTION:
            brick = new NassiInstructionBrick();
            break;
        case NASSI_BRICK_CONTINUE:
            brick = new NassiContinueBrick();
            break;
        case NASSI_BRICK_BREAK:
            brick = new NassiBreakBrick();
            break;
        case NASSI_BRICK_RETURN:
            brick = new NassiReturnBrick();
            break;
        case NASSI_BRICK_WHILE:
            brick = new NassiWhileBrick();
            break;
        case NASSI_BRICK_DOWHILE:
            brick = new NassiDoWhileBrick();
            break;
        case NASSI_BRICK_FOR:
            brick = new NassiForBrick();
            break;
        case NASSI_BRICK_BLOCK:
            brick = new NassiBlockBrick();
            break;
        case NASSI_BRICK_IF:
            brick = new NassiIfBrick();
            break;
        case NASSI_BRICK_SWITCH:
            brick = new NassiSwitchBrick();
            break;
        case NASSI_BRICK_ESC:
        default:
            brick = nullptr;
    }
    if ( brick )
        brick->Deserialize(stream);
    return ( brick );
}
//void CreateNassiIfBrick::operator()(iterator_t first, iterator_t const& last)const
void CreateNassiIfBrick::operator() ( wxChar const *first, wxChar const *last ) const
{
    //wxMessageDialog dlg(NULL, _T("open begin"), _T("test"));
    //dlg.ShowModal();
    NassiBrick *brick = new NassiIfBrick();
    m_brick->SetNext( brick );
    brick->SetTextByNumber(m_c_str, 0);
    brick->SetTextByNumber(m_s_str, 1);
    m_c_str.clear();
    m_s_str.clear();
    m_brick = brick;

    brick = new NassiInstructionBrick();
    m_brick->SetChild(brick, 0);
    m_brick = brick;
    //wxMessageDialog dlg2(NULL, _T("open end"), _T("test"));
    //dlg2.ShowModal();
}
Ejemplo n.º 16
0
void NassiWhileBrick::SaveSource(wxTextOutputStream &text_stream, wxUint32 n)
{
    SaveCommentString(text_stream, Comment, n);

    wxString src = _T("while ") + Source;
    SaveSourceString(text_stream,src, n);

    NassiBrick *child = GetChild(0);
    if ( child )
    {
        SaveSourceString(text_stream, _T("{"), n);
        child->SaveSource(text_stream, n+4);
        SaveSourceString(text_stream, _T("}"), n);
    }
    else
        SaveSourceString(text_stream, _T(";"), n+4);


    NassiBrick::SaveSource(text_stream, n);
}
Ejemplo n.º 17
0
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);
}
Ejemplo n.º 18
0
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);
}
Ejemplo n.º 19
0
void NassiBrick::GetStrukTeX(wxString &str, wxUint32 n = 0)
{
    NassiBrick *next = GetNext();
    if ( next )
        next->GetStrukTeX(str, n);
}
Ejemplo n.º 20
0
void NassiBrick::SaveSource(wxTextOutputStream &text_stream, wxUint32 n)
{
    NassiBrick *next = GetNext();
    if ( next )
        next->SaveSource(text_stream, n);
}