Force declarations at the beginning

This commit is contained in:
Arnaud Vergnet 2021-03-18 10:09:14 +01:00
parent ee4ec4f3f9
commit 7d65980c4f

12
as.y
View file

@ -49,30 +49,34 @@
S : Main ;
Main : tINT tMAIN tPO Params tPF Body ;
Main : tINT tMAIN tPO Params tPF MainBody ;
Params : | Param SuiteParams ;
Param : tINT tID ;
SuiteParams : tVIRG Param SuiteParams ;
MainBody : tAO Declarations Instructions tAF ;
Body : tAO Instructions tAF ;
Instructions : Instruction Instructions | ;
Instruction : Aff | Printf | If | Declaration ;
Instruction : Aff | Printf | If ;
Aff : tID tEQ E tPV ;
E : tNB | tID | E tADD E | E tMUL E | E tSUB E | E tDIV E | tPO E tPF | tSUB E ;
DeclarationBody : tID tVIRG DeclarationBody | tID ;
Declarations : | Declaration Declarations ;
Declaration : DeclarationInt | DeclarationConst ;
DeclarationInt : tINT DeclarationBody tPV ;
DeclarationConst : tCONST DeclarationBody tPV ;
Declaration : DeclarationInt | DeclarationConst ;
DeclarationBody : tID tVIRG DeclarationBody | tID ;
If : IfSimple | IfElse ;