From 4e3d2e0421e6ea72542e80e994cc37bea01dd8d1 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Thu, 26 Jan 2023 17:43:16 +0100 Subject: [PATCH] change whl to while --- calc.c | 8 ++++---- parser.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/calc.c b/calc.c index 336e8fa..d4d2243 100644 --- a/calc.c +++ b/calc.c @@ -291,15 +291,15 @@ int main (int argc, char *argv[]) // test: echo -e 'sto (1, 4)\ninc (1)\ninc (1)\ndec (1)\ninc (1)\nrcl (1) == 6' | calc.exe -v 3 | grep -q '=> 1' // test: echo -e 'inc\ninc (\ndec\ndec (' | calc.exe | grep -c error | xargs test 4 = // test: echo -e 'inc (11)\ndec (0)' | calc.exe | grep -c invalid | xargs test 2 = -// test: echo -e 'whl (inc (1) < 100, sto (2, rcl (1) + rcl (2)))' | calc.exe | grep -q '=> 5050' -// test: echo -e 'whl\nwhl (inc (1) < 3,\nwhl (inc (1) < 100, sto (2, rcl (1) + rcl (2))' | calc.exe | grep -c error | xargs test 3 = -// test: echo -e 'whl (0, 1)' | calc.exe -v 3 | grep -q While +// test: echo -e 'while (inc (1) < 100, sto (2, rcl (1) + rcl (2)))' | calc.exe | grep -q '=> 5050' +// test: echo -e 'while\nwhile (inc (1) < 3,\nwhile (inc (1) < 100, sto (2, rcl (1) + rcl (2))' | calc.exe | grep -c error | xargs test 3 = +// test: echo -e 'while (0, 1)' | calc.exe -v 3 | grep -q While // test: echo -e '{sto (1, 1 + 1), rcl (1) * 3}' | calc.exe -v 3 | grep -q 'Program' // test: echo -e '{sto (1, 1 + 1), rcl (1) * 3}' | calc.exe | grep -q '=> 6' // test: echo -e '{\n{}\n{1, 2\n{sto (1, 1 + 1),\npow(2, {sto (1, 1 + 2), 2}, {rcl(2)})\n2 {sto (1, 1 + 1)}' | calc.exe | grep -c error | xargs test 6 = // test: echo -e '1 }\n1 )\n1 , 2\n ' | calc.exe | grep -c error | xargs test 3 = // Fibonacci sequence -// test: echo -e '{sto (1, 1), sto (2, 1), sto (10, 1), whl (inc (10) < 12 - 1, {sto (3, rcl (1) + rcl (2)), sto (1, rcl (2)), sto (2, rcl (3))})}' | calc.exe | grep '=> 144' +// test: echo -e '{sto (1, 1), sto (2, 1), sto (10, 1), while (inc (10) < 12 - 1, {sto (3, rcl (1) + rcl (2)), sto (1, rcl (2)), sto (2, rcl (3))})}' | calc.exe | grep '=> 144' /* vim: set ts=4 sw=4 et: */ diff --git a/parser.c b/parser.c index 11d5860..c023a6e 100644 --- a/parser.c +++ b/parser.c @@ -139,7 +139,7 @@ keyword_t functions[NB_FUNCTIONS] = { { "help", Help, 0, 4, 9}, { "!", Not, 1, 1, 6}, { "cond", Cond, 3, 4, 5}, - { "whl", While, 2, 3, 5} + { "while", While, 2, 5, 5} }; #define NB_CONSTANTS 3 @@ -633,7 +633,7 @@ void help (void) fprintf (stdout, "storage functions:"); fprintf (stdout, " sto rcl inc dec\n"); fprintf (stdout, "conditional functions:"); - fprintf (stdout, " cond\n"); + fprintf (stdout, " cond while\n"); fprintf (stdout, "miscellaneous functions:"); fprintf (stdout, " quit help\n"); fprintf (stdout, "supported constants:"); -- 2.30.2