From 806dd4ff649a1fb9a28dc469cc17d7dd5dbc1da5 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 23 Feb 2018 01:11:34 +0100 Subject: Adapt for new grammar --- res/exp.tpc | 5 ----- res/instr.tpc | 28 ---------------------------- res/ko_sample.tpc | 24 ++++++++++++++++++++++++ res/ok_sample.tpc | 24 ++++++++++++++++++++++++ res/trinome.tpc | 43 ------------------------------------------- 5 files changed, 48 insertions(+), 76 deletions(-) delete mode 100644 res/exp.tpc delete mode 100644 res/instr.tpc create mode 100644 res/ko_sample.tpc create mode 100644 res/ok_sample.tpc delete mode 100644 res/trinome.tpc (limited to 'res') diff --git a/res/exp.tpc b/res/exp.tpc deleted file mode 100644 index 471c068..0000000 --- a/res/exp.tpc +++ /dev/null @@ -1,5 +0,0 @@ -/* exp.tpc */ - -/* double valeur(double a, double b, double c, double x) ; */ -/* Résolution d'une équation du deuxième degré */ - r1=(-b+s)/(2*a)+print(valeur(1,b,c,r1),valeur(1,b,c,r2)) diff --git a/res/instr.tpc b/res/instr.tpc deleted file mode 100644 index 7153ac2..0000000 --- a/res/instr.tpc +++ /dev/null @@ -1,28 +0,0 @@ -/* instr.tpc */ -/* int trinome(float a, float b, float c) ; - double valeur(double a, double b, double c, double x) ; */ -/* Résolution d'une équation du deuxième degré */ - b=-1; - while (b<=1) { - c=-1; - while (c<=1) { - print(b, c); - if (trinome(1,b,c)) { - print(r1, r2); - print(valeur(1,b,c,r1),valeur(1,b,c,r2)); - } - c=c+1; - } - b=b+1; - } - return 0; - d=b*b-4*a*c; - if (d>=0) { - s=sqrt(d); - r1=(-b+s)/(2*a); - r2=(-b-s)/(2*a); - return 1; - } - return 0; - if (0<=r1 && r1<=max && 0>=r2 && r2>=-max) - return; \ No newline at end of file diff --git a/res/ko_sample.tpc b/res/ko_sample.tpc new file mode 100644 index 0000000..f3a4c7a --- /dev/null +++ b/res/ko_sample.tpc @@ -0,0 +1,24 @@ +/** + * UPEM / Compilation / Projet TPC + * Exemple de fichier source TPC invalide + * Pacien TRAN-GIRARD, Adam NAILI + */ + +const special = 'b'; + +char funky_func(int arg) { + return !arg; +} + +void main(void) { + void ret; + ret = 1 + funky_func(0) * 2; + + while (ret) { + readc(ret); + print(ret); + + if (ret == special) print('!'); + } +} + diff --git a/res/ok_sample.tpc b/res/ok_sample.tpc new file mode 100644 index 0000000..7591dfd --- /dev/null +++ b/res/ok_sample.tpc @@ -0,0 +1,24 @@ +/** + * UPEM / Compilation / Projet TPC + * Exemple de fichier source TPC valide + * Pacien TRAN-GIRARD, Adam NAILI + */ + +const special = 'b'; + +char funky_func(int arg) { + return !arg; +} + +void main(void) { + char ret; + ret = 1 + funky_func(0) * 2; + + while (ret) { + readc(ret); + print(ret); + + if (ret == special) print('!'); + } +} + diff --git a/res/trinome.tpc b/res/trinome.tpc deleted file mode 100644 index c3e2f94..0000000 --- a/res/trinome.tpc +++ /dev/null @@ -1,43 +0,0 @@ -/* #include - #include */ -/* int trinome(float a, float b, float c) ; - double valeur(double a, double b, double c, double x) ; */ -/* Résolution d'une équation du deuxième degré */ -float r1, r2; - -int main(void) { - int b, c; - b=-1; - while (b<=1) { - c=-1; - while (c<=1) { - print(b, c); - if (trinome(1,b,c)) { - print(r1, r2); - print(valeur(1,b,c,r1),valeur(1,b,c,r2)); - if (0<=r1 && r1<=max && 0>=r2 && r2>=-max) - return 0; - } - c=c+1; - } - b=b+1; - } - return 0; -} - -int trinome(float a,float b, float c) { - float d; - float s; - d=b*b-4*a*c; - if (d>=0) { - s=sqrt(d); - r1=(-b+s)/(2*a); - r2=(-b-s)/(2*a); - return 1; - } - return 0; -} - -double valeur(double a, double b, double c, double x) { - return a*x*x+b*x+c; -} \ No newline at end of file -- cgit v1.2.3