diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..90594c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +as.tab.c +as.tab.h +compilateur +lex.yy.c + diff --git a/as.y b/as.y index 6da3010..f842f71 100644 --- a/as.y +++ b/as.y @@ -60,12 +60,19 @@ Body : tAO Instructions tAF ; Instructions : Instruction Instructions | ; -Instruction : Aff | Printf | If ; +Instruction : Aff | Printf | If | Declaration ; 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 ; + +DeclarationInt : tINT DeclarationBody tPV ; + +DeclarationConst : tCONST DeclarationBody tPV ; + +Declaration : DeclarationInt | DeclarationConst ; If : IfSimple | IfElse ; diff --git a/test.c b/test.c index 3550380..0d5161d 100644 --- a/test.c +++ b/test.c @@ -1,7 +1,10 @@ int main(){ - x = 3 + 6; + int x, y, z; + const PL5_op, b, c; printf(x); if (x == x && y != 5 + 6 || 1 + 2 == 2 + 1 && !(x == x)) { printf(x); + } else { + x = 3 + 2; } }