]> git.saurik.com Git - bison.git/commitdiff
Always check the value returned by yyparse.
authorAkim Demaille <akim@epita.fr>
Fri, 15 Nov 2002 08:56:40 +0000 (08:56 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 15 Nov 2002 08:56:40 +0000 (08:56 +0000)
* tests/calc.at (_AT_DATA_CALC_Y): Have `main' exit with the value
returned by yyparse.
(_AT_CHECK_CALC_ERROR): Take the expected exit value as argument.
Adjust calls.
* tests/glr-regr1.at (glr-regr1.y): Have `main' exit with the value
returned by yyparse.

ChangeLog
tests/calc.at
tests/glr-regr1.at

index 10e8a894d2a23bdf2f7a3aa3ce88524dac52c752..6b5bb825d6cb8451af8eb8111f40f9145307857d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2002-11-15  Akim Demaille  <akim@epita.fr>
+
+       Always check the value returned by yyparse.
+
+       * tests/calc.at (_AT_DATA_CALC_Y): Have `main' exit with the value
+       returned by yyparse.
+       (_AT_CHECK_CALC_ERROR): Take the expected exit value as argument.
+       Adjust calls.
+       * tests/glr-regr1.at (glr-regr1.y): Have `main' exit with the value
+       returned by yyparse.
+
 2002-11-14  Paul Hilfinger  <Hilfinger@CS.Berkeley.EDU>
 
        * data/glr.c (yyFail): Always set yyerrflag.  Corrects regression
 2002-11-14  Paul Hilfinger  <Hilfinger@CS.Berkeley.EDU>
 
        * data/glr.c (yyFail): Always set yyerrflag.  Corrects regression
index b226cbc92f2512ec009de6160436a1da14ef61fd..f558e27e7283b8edf7c9ac66895c1441ee2ad964 100644 (file)
@@ -291,6 +291,7 @@ main (int argc, const char **argv)
 {
   value_t result = 0;
   int count = 0;
 {
   value_t result = 0;
   int count = 0;
+  int status = 0;
   yyin = NULL;
 
   if (argc == 2)
   yyin = NULL;
 
   if (argc == 2)
@@ -307,11 +308,10 @@ main (int argc, const char **argv)
 #if YYDEBUG
   yydebug = 1;
 #endif
 #if YYDEBUG
   yydebug = 1;
 #endif
-  yyparse (]AT_PARAM_IF([&result, &count])[);
+  status = yyparse (]AT_PARAM_IF([&result, &count])[);
   assert (global_result == result);
   assert (global_count  == count);
   assert (global_result == result);
   assert (global_count  == count);
-
-  return 0;
+  return status;
 }
 ]])
 ])# _AT_DATA_CALC_Y
 }
 ]])
 ])# _AT_DATA_CALC_Y
@@ -349,9 +349,10 @@ m4_bmatch([$1],
 ])
 
 
 ])
 
 
-# _AT_CHECK_CALC_ERROR(BISON-OPTIONS, INPUT, [NUM-DEBUG-LINES],
+# _AT_CHECK_CALC_ERROR(BISON-OPTIONS, EXIT-STATUS, INPUT,
+#                      [NUM-DEBUG-LINES],
 #                      [VERBOSE-AND-LOCATED-ERROR-MESSAGE])
 #                      [VERBOSE-AND-LOCATED-ERROR-MESSAGE])
-# -------------------------------------------------------------
+# ---------------------------------------------------------
 # Run `calc' on INPUT, and expect a `parse error' message.
 #
 # If INPUT starts with a slash, it is used as absolute input file name,
 # Run `calc' on INPUT, and expect a `parse error' message.
 #
 # If INPUT starts with a slash, it is used as absolute input file name,
@@ -367,17 +368,17 @@ m4_bmatch([$1],
 # If BISON-OPTIONS contains `%debug' but not `%glr', then NUM-STDERR-LINES
 # is the number of expected lines on stderr.
 m4_define([_AT_CHECK_CALC_ERROR],
 # If BISON-OPTIONS contains `%debug' but not `%glr', then NUM-STDERR-LINES
 # is the number of expected lines on stderr.
 m4_define([_AT_CHECK_CALC_ERROR],
-[m4_bmatch([$2], [^/],
-           [AT_PARSER_CHECK([./calc $2], 0, [], [stderr])],
+[m4_bmatch([$3], [^/],
+           [AT_PARSER_CHECK([./calc $3], $2, [], [stderr])],
            [AT_DATA([[input]],
            [AT_DATA([[input]],
-[[$2
+[[$3
 ]])
 ]])
-AT_PARSER_CHECK([./calc input], 0, [], [stderr])])
+AT_PARSER_CHECK([./calc input], $2, [], [stderr])])
 m4_bmatch([$1],
   [%debug.*%glr\|%glr.*%debug],
      [],
   [%debug],
 m4_bmatch([$1],
   [%debug.*%glr\|%glr.*%debug],
      [],
   [%debug],
-     [AT_CHECK([wc -l <stderr | sed 's/[[^0-9]]//g'], 0, [$3
+     [AT_CHECK([wc -l <stderr | sed 's/[[^0-9]]//g'], 0, [$4
 ])])
 
 # Normalize the observed and expected error messages, depending upon the
 ])])
 
 # Normalize the observed and expected error messages, depending upon the
@@ -397,7 +398,7 @@ sed '/^Starting/d
 mv at-stderr stderr
 # 2. Create the reference error message.
 AT_DATA([[expout]],
 mv at-stderr stderr
 # 2. Create the reference error message.
 AT_DATA([[expout]],
-[$4
+[$5
 ])
 # 3. If locations are not used, remove them.
 AT_YYERROR_SEES_LOC_IF([],
 ])
 # 3. If locations are not used, remove them.
 AT_YYERROR_SEES_LOC_IF([],
@@ -497,27 +498,27 @@ _AT_CHECK_CALC([$1],
                [486])
 
 # Some parse errors.
                [486])
 
 # Some parse errors.
-_AT_CHECK_CALC_ERROR([$1], [0 0], [11],
+_AT_CHECK_CALC_ERROR([$1], [1], [0 0], [11],
                      [1.3-1.4: parse error, unexpected "number"])
                      [1.3-1.4: parse error, unexpected "number"])
-_AT_CHECK_CALC_ERROR([$1], [1//2], [15],
+_AT_CHECK_CALC_ERROR([$1], [1], [1//2], [15],
                      [1.3-1.4: parse error, unexpected '/', expecting "number" or '-' or '('])
                      [1.3-1.4: parse error, unexpected '/', expecting "number" or '-' or '('])
-_AT_CHECK_CALC_ERROR([$1], [error], [4],
+_AT_CHECK_CALC_ERROR([$1], [1], [error], [4],
                      [1.1-1.2: parse error, unexpected $undefined, expecting "number" or '-' or '\n' or '('])
                      [1.1-1.2: parse error, unexpected $undefined, expecting "number" or '-' or '\n' or '('])
-_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [22],
+_AT_CHECK_CALC_ERROR([$1], [1], [1 = 2 = 3], [22],
                      [1.7-1.8: parse error, unexpected '='])
                      [1.7-1.8: parse error, unexpected '='])
-_AT_CHECK_CALC_ERROR([$1],
+_AT_CHECK_CALC_ERROR([$1], [1],
                      [
 +1],
                      [14],
                      [2.1-2.2: parse error, unexpected '+'])
 # Exercise error messages with EOF: work on an empty file.
                      [
 +1],
                      [14],
                      [2.1-2.2: parse error, unexpected '+'])
 # Exercise error messages with EOF: work on an empty file.
-_AT_CHECK_CALC_ERROR([$1], [/dev/null], [4],
+_AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4],
                      [1.1-1.2: parse error, unexpected "end of input", expecting "number" or '-' or '\n' or '('])
 
 # Exercise the error token: without it, we die at the first error,
 # hence be sure i. to have several errors, ii. to test the action
 # associated to `error'.
                      [1.1-1.2: parse error, unexpected "end of input", expecting "number" or '-' or '\n' or '('])
 
 # Exercise the error token: without it, we die at the first error,
 # hence be sure i. to have several errors, ii. to test the action
 # associated to `error'.
-_AT_CHECK_CALC_ERROR([$1], [(1 ++ 2) + (0 0) = 1], [82],
+_AT_CHECK_CALC_ERROR([$1], [0], [(1 ++ 2) + (0 0) = 1], [82],
 [1.5-1.6: parse error, unexpected '+', expecting "number" or '-' or '('
 1.15-1.16: parse error, unexpected "number"
 calc: error: 0 != 1])
 [1.5-1.6: parse error, unexpected '+', expecting "number" or '-' or '('
 1.15-1.16: parse error, unexpected "number"
 calc: error: 0 != 1])
index 2483fc52170283a0447107aefc894982bf656b99..72aec7053d4d3cdcb6aa4526c29f5f414a4e6f0a 100644 (file)
@@ -63,8 +63,7 @@ static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1)
 int
 main (void)
 {
 int
 main (void)
 {
-  yyparse ();
-  return 0;
+  return yyparse ();
 }
 
 int
 }
 
 int