From ee4ec4f3f92ec9d20b6e72acdd04fc7136f97645 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Thu, 18 Mar 2021 10:03:38 +0100 Subject: [PATCH] Finish syntaxic analysis --- .gitignore | 5 +++++ as.y | 9 ++++++++- test.c | 5 ++++- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .gitignore 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; } }