change whl to while
authorLaurent Mazet <laurent.mazet@thalesgroup.com>
Thu, 26 Jan 2023 16:43:16 +0000 (17:43 +0100)
committerLaurent Mazet <laurent.mazet@thalesgroup.com>
Thu, 26 Jan 2023 16:43:16 +0000 (17:43 +0100)
calc.c
parser.c

diff --git a/calc.c b/calc.c
index 336e8fa7821f93d39a574ce1b5df9a94ceedefdf..d4d224387294d1c41ab7ac3b3492ff494a937249 100644 (file)
--- 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: */
index 11d586036205526817487a9446c039c2917cea8f..c023a6e959a5fe6fb3f86f76fba752bb97a0745b 100644 (file)
--- 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:");