Finish syntaxic analysis

This commit is contained in:
Arnaud Vergnet 2021-03-18 10:03:38 +01:00
parent 6e00634d28
commit ee4ec4f3f9
3 changed files with 17 additions and 2 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
as.tab.c
as.tab.h
compilateur
lex.yy.c

9
as.y
View file

@ -60,12 +60,19 @@ Body : tAO Instructions tAF ;
Instructions : Instruction Instructions | ; Instructions : Instruction Instructions | ;
Instruction : Aff | Printf | If ; Instruction : Aff | Printf | If | Declaration ;
Aff : tID tEQ E tPV ; 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 ; 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 ; If : IfSimple | IfElse ;

5
test.c
View file

@ -1,7 +1,10 @@
int main(){ int main(){
x = 3 + 6; int x, y, z;
const PL5_op, b, c;
printf(x); printf(x);
if (x == x && y != 5 + 6 || 1 + 2 == 2 + 1 && !(x == x)) { if (x == x && y != 5 + 6 || 1 + 2 == 2 + 1 && !(x == x)) {
printf(x); printf(x);
} else {
x = 3 + 2;
} }
} }