From 35cccd3ad5df1f2cb432136dc3ad4195fe61068b Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 23 Dec 2022 06:42:36 +0100 Subject: [PATCH] calculation priority --- README.md | 1 - parser.mly | 4 ++-- tests/10_math.test | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9435e0f..d2ac103 100644 --- a/README.md +++ b/README.md @@ -41,4 +41,3 @@ $ make test ## Problèmes connus - Pas de parenthèses pour les calculs -- Pas de prioriétés de calculs diff --git a/parser.mly b/parser.mly index efe3872..8fcc2f4 100644 --- a/parser.mly +++ b/parser.mly @@ -15,8 +15,8 @@ %token Land Lor %token Lif Lelse Lwhile -%left Ladd Lsub Lmul Ldiv Lrem Lseq Lsge Lsgt Lsle Lslt Lsne -%left Land Lor +%left Ladd Lsub Lseq Lsge Lsgt Lsle Lslt Lsne Land Lor +%left Lmul Ldiv Lrem %type prog diff --git a/tests/10_math.test b/tests/10_math.test index 6f82f73..c8609dc 100644 --- a/tests/10_math.test +++ b/tests/10_math.test @@ -1,5 +1,5 @@ int main () { - int res = 13 * -100 - 20 + 8; + int res = 8 - 20 - 13 * 100; res = abs(res * 2) / 2; return res % 2; }