]> git.saurik.com Git - bison.git/blobdiff - tests/glr-regr1.at
(_AT_CHECK_PRINTER_AND_DESTRUCTOR):
[bison.git] / tests / glr-regr1.at
index 8c1964082ee3abbccf3513bcbc84f21557188de9..72aec7053d4d3cdcb6aa4526c29f5f414a4e6f0a 100644 (file)
@@ -20,15 +20,17 @@ AT_BANNER([[GLR Regression Test #1.]])
 
 AT_SETUP([Badly Collapsed GLR States])
 
-AT_DATA([glr-regr1.y],
+AT_DATA_GRAMMAR([glr-regr1.y],
 [[/* Regression Test: Improper state compression */
 /* Reported by Scott McPeak */
 
 %{
-#include <stdio.h>    // fgetc, printf
+#include <stdio.h>
 
 #define YYSTYPE int
 static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
+int yylex (void);
+int yyerror (char const *msg);
 %}
 
 
@@ -52,33 +54,37 @@ E: E 'P' E { $$=1; printf("E -> E 'P' E\n"); }  %merge <exprMerge>
 
 static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1)
 {
+  (void) x0;
+  (void) x1;
   printf ("<OR>\n");
   return 0;
 }
 
-int main()
+int
+main (void)
 {
-  yyparse();
-  return 0;
+  return yyparse ();
 }
 
-int yyerror(char const *msg)
+int
+yyerror (char const *msg)
 {
-  printf("%s\n", msg);
-  exit(4);
+  fprintf (stderr, "%s\n", msg);
+  exit (4);
 }
 
 
-int yylex()
+int
+yylex (void)
 {
-  while (1) {
-    int ch = fgetc(stdin);
-    if (ch == EOF) {
-      return 0;   // bison's EOF
-    } else if (ch == 'B' || ch == 'P') {
-      return ch;
+  for (;;)
+    {
+      int ch = getchar ();
+      if (ch == EOF)
+       return 0;
+      else if (ch == 'B' || ch == 'P')
+       return ch;
     }
-  }
 }
 ]])
 
@@ -86,7 +92,7 @@ AT_CHECK([[bison -o glr-regr1.c glr-regr1.y]], 0, [],
 [glr-regr1.y: warning: 1 shift/reduce conflict
 ])
 AT_COMPILE([glr-regr1])
-AT_CHECK([[echo BPBPB | ./glr-regr1]], 0, 
+AT_CHECK([[echo BPBPB | ./glr-regr1]], 0,
 [[E -> 'B'
 E -> 'B'
 E -> E 'P' E