]> git.saurik.com Git - bison.git/blobdiff - tests/conflicts.at
Initial check-in introducing experimental GLR parsing. See entry in
[bison.git] / tests / conflicts.at
index 46add71b2b8636b9b5e6353f95ca2d3ad31b80e9..3aceda1cc72b5e2b62cad5516a6e30d6a17330da 100644 (file)
@@ -50,16 +50,22 @@ AT_SETUP([%nonassoc and eof])
 AT_DATA([input.y],
 [[
 %{
+#include <config.h>
+/* We don't need a perfect malloc for these tests. */
+#undef malloc
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <error.h>
+
+#if STDC_HEADERS
+# include <stdlib.h>
+#endif
+
 #define YYERROR_VERBOSE 1
-#define yyerror(Msg) \
-do { \
-  fprintf (stderr, "%s\n", Msg); \
-  exit (1); \
-} while (0)
+static void
+yyerror (const char *msg)
+{
+  fprintf (stderr, "%s\n", msg);
+  exit (1);
+}
 
 /* The current argument. */
 static const char *input = NULL;
@@ -124,13 +130,15 @@ AT_CLEANUP
 
 AT_SETUP([Unresolved SR Conflicts])
 
+AT_KEYWORDS([report])
+
 AT_DATA([input.y],
 [[%token NUM OP
 %%
 exp: exp OP exp | NUM;
 ]])
 
-AT_CHECK([bison input.y -o input.c -v], 0, [],
+AT_CHECK([bison input.y -o input.c --report=all], 0, [],
 [input.y contains 1 shift/reduce conflict.
 ])
 
@@ -141,18 +149,18 @@ AT_CHECK([cat input.output], [],
 
 Grammar
 
-  Number, Line, Rule
-    0   3 $axiom -> exp $
-    1   3 exp -> exp OP exp
-    2   3 exp -> NUM
+    0 $axiom: exp $
+
+    1 exp: exp OP exp
+    2    | NUM
 
 
 Terminals, with rules where they appear
 
 $ (0) 0
 error (256)
-NUM (257) 2
-OP (258) 1
+NUM (258) 2
+OP (259) 1
 
 
 Nonterminals, with rules where they appear
@@ -166,6 +174,8 @@ exp (6)
 state 0
 
     $axiom  ->  . exp $   (rule 0)
+    exp  ->  . exp OP exp   (rule 1)
+    exp  ->  . NUM   (rule 2)
 
     NUM        shift, and go to state 1
 
@@ -200,7 +210,9 @@ state 3
 
 state 4
 
+    exp  ->  . exp OP exp   (rule 1)
     exp  ->  exp OP . exp   (rule 1)
+    exp  ->  . NUM   (rule 2)
 
     NUM        shift, and go to state 1
 
@@ -210,8 +222,8 @@ state 4
 
 state 5
 
-    exp  ->  exp . OP exp   (rule 1)
-    exp  ->  exp OP exp .   (rule 1)
+    exp  ->  exp . OP exp  [$, OP]   (rule 1)
+    exp  ->  exp OP exp .  [$, OP]   (rule 1)
 
     OP         shift, and go to state 4
 
@@ -231,6 +243,8 @@ AT_CLEANUP
 
 AT_SETUP([Solved SR Conflicts])
 
+AT_KEYWORDS([report])
+
 AT_DATA([input.y],
 [[%token NUM OP
 %right OP
@@ -238,27 +252,24 @@ AT_DATA([input.y],
 exp: exp OP exp | NUM;
 ]])
 
-AT_CHECK([bison input.y -o input.c -v], 0, [], [])
+AT_CHECK([bison input.y -o input.c --report=all], 0, [], [])
 
 # Check the contents of the report.
 AT_CHECK([cat input.output], [],
-[[Conflict in state 5 between rule 2 and token OP resolved as shift.
+[[Grammar
 
+    0 $axiom: exp $
 
-Grammar
-
-  Number, Line, Rule
-    0   4 $axiom -> exp $
-    1   4 exp -> exp OP exp
-    2   4 exp -> NUM
+    1 exp: exp OP exp
+    2    | NUM
 
 
 Terminals, with rules where they appear
 
 $ (0) 0
 error (256)
-NUM (257) 2
-OP (258) 1
+NUM (258) 2
+OP (259) 1
 
 
 Nonterminals, with rules where they appear
@@ -272,6 +283,8 @@ exp (6)
 state 0
 
     $axiom  ->  . exp $   (rule 0)
+    exp  ->  . exp OP exp   (rule 1)
+    exp  ->  . NUM   (rule 2)
 
     NUM        shift, and go to state 1
 
@@ -306,7 +319,9 @@ state 3
 
 state 4
 
+    exp  ->  . exp OP exp   (rule 1)
     exp  ->  exp OP . exp   (rule 1)
+    exp  ->  . NUM   (rule 2)
 
     NUM        shift, and go to state 1
 
@@ -316,13 +331,14 @@ state 4
 
 state 5
 
-    exp  ->  exp . OP exp   (rule 1)
-    exp  ->  exp OP exp .   (rule 1)
+    exp  ->  exp . OP exp  [$]   (rule 1)
+    exp  ->  exp OP exp .  [$]   (rule 1)
 
     OP         shift, and go to state 4
 
     $default   reduce using rule 1 (exp)
 
+    Conflict between rule 2 and token OP resolved as reduce (%right OP).
 
 
 ]])