bool GeneratedState0::Transition (Automate & automate, Symbole *s)
{
    // Generated code :
    switch ((int)*s) {
    case CONST:
        automate.Reduction(0);
        break;
    case ECRIRE:
         automate.Reduction(0);
        break;
    case IDENTIFIANT:
         automate.Reduction(0);
        break;
    case LIRE:
         automate.Reduction(0);
        break;
    case PDECL:
        automate.Decalage(s, new GeneratedState0p);
        break;
    case VAR:
        automate.Reduction(0);
        break;
    case PROGRAMME:
        automate.Consommer();
        Programme* progSymbole;
        progSymbole = static_cast<Programme*>(s);
        automate.Accepter(progSymbole);
        break;
    default:
        automate.SetErreur();
        break;
    }
    return false;

}
示例#2
0
bool E1::Transition ( Automate & automate, Symbole * s )
{
    switch(*s)
    {
        case VAR:
        {
            automate.Decalage(s, new E4);
            return true;
        }
        case CONST:
        {
            automate.Decalage(s, new E5);
            return true;
        }
        case LIRE:
        case ECRIRE:
        case ID:
        case FIN:
        {
            automate.Reduction(new PartieInstructions, 0);
            return true;
        }
        case D:
        {
            automate.Decalage(s, new E3);
            return true;
        }
        case PI:
        {
            automate.Decalage(s, new E2);
            return true;
        }
    }
    return false;
}
bool GeneratedState1::Transition (Automate & automate, Symbole *s)
{
    // Generated code :
    switch ((int)*s) {
    case FIN:
        automate.Reduction(2);
        break;
    case ECRIRE:
        automate.Consommer();
        automate.Decalage(s, new GeneratedState11);
        break;

    case IDENTIFIANT:
        automate.Consommer();
        automate.Decalage(s, new GeneratedState13);
        break;
    case LIRE:
        automate.Consommer();
        automate.Decalage(s, new GeneratedState12);
        break;
    default:
        automate.SetErreur();
        break;
    }
    return false;

}
bool GeneratedState22::Transition (Automate & automate, Symbole *s)
{

    // Generated code :
    switch ((int)*s) {
    case POINT_VIRGULE:
        automate.Reduction(1);
        break;
    case VIRGULE:
        automate.Reduction(1);
        break;
    case IDENTIFIANT : //récupération sur erreur
        automate.Reduction(1);
        break;
    default:
        automate.SetErreur();
        break;
    }
    return false;

}
示例#5
0
bool E10::Transition ( Automate & automate, Symbole * s )
{
    switch(*s)
    {
        case VAR:
        case CONST:
        case LIRE:
        case ECRIRE:
        case ID:
        case FIN:
        {
            //Symbole * point_virgule = 
            delete automate.PopSymbole();
            ListeDeclaration * d = (ListeDeclaration *) automate.PopSymbole();
            PartieDeclarative * pd = (PartieDeclarative *) automate.PopSymbole();

            if( ! pd->AjouterDeclarations(d) )
            {
                // nettoyer les Declaration
                for(Declaration * decl : d->GetListeDeclarations())
                {
                    delete decl;
                }
                delete d;
                for(auto & decl : pd->GetDeclarations())
                {
                    delete decl.second;
                }
                delete pd;

                throw DOUBLE_DECLARATION;
            }
            else
            {
                delete d;
                automate.Reduction(pd, 3);
                return true;
            }
        }
    }
    return false;
}
示例#6
0
bool E2::Transition ( Automate & automate, Symbole * s )
{
    switch(*s)
    {
        case LIRE:
        {
            automate.Decalage(s, new E7);
            return true;
        }
        case ECRIRE:
        {
            automate.Decalage(s, new E8);
            return true;
        }
        case ID:
        {
            automate.Decalage(s, new E9);
            return true;
        }
        case FIN:
        {
            PartieInstructions * pi = (PartieInstructions *) automate.PopSymbole();
            PartieDeclarative * pd = (PartieDeclarative *) automate.PopSymbole();
            
            Programme * prog = new Programme(pd->GetDeclarations(), pi->GetInstructions());
            
            delete pi;
            delete pd;
            
            //réduire R0
            automate.Reduction(prog, 2);
            
            return true;
        }
        case I:
        {
            automate.Decalage(s, new E6);
            return true;
        }
    }
    return false;
}
示例#7
0
bool E13::Transition ( Automate & automate, Symbole * s )
{
    switch(*s)
    {
        case VIRGULE:
        {
            automate.Decalage(s, new E25);
            return true;
        }
        case POINT_VIRGULE:
        {
            ListeIdentifiantsValeurs * lidv = (ListeIdentifiantsValeurs *) automate.PopSymbole();
            lidv->SetIdent(D);
            //Symbole * constante = 
            delete automate.PopSymbole();

            //réduire R4
            automate.Reduction(lidv, 2);
            return true;
        }
    }
    return false;
}