summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/calc.tab.c50
-rw-r--r--test/calc.y8
-rw-r--r--test/calc1.tab.c72
-rw-r--r--test/calc1.y8
-rw-r--r--test/calc2.tab.c53
-rw-r--r--test/calc2.y11
-rw-r--r--test/calc3.tab.c58
-rw-r--r--test/calc3.y10
-rw-r--r--test/code_calc.code.c51
-rw-r--r--test/code_calc.y9
-rw-r--r--test/code_error.code.c17
-rw-r--r--test/code_error.y9
-rw-r--r--test/error.tab.c17
-rw-r--r--test/error.y9
-rw-r--r--test/ftp.tab.c175
-rw-r--r--test/ftp.y163
-rw-r--r--test/grammar.tab.c190
-rw-r--r--test/grammar.y16
-rw-r--r--test/pure_calc.tab.c68
-rw-r--r--test/pure_calc.y20
-rw-r--r--test/pure_error.tab.c27
-rw-r--r--test/pure_error.y14
-rw-r--r--test/quote_calc-s.output557
-rw-r--r--test/quote_calc-s.tab.c687
-rw-r--r--test/quote_calc-s.tab.h9
-rw-r--r--test/quote_calc.output557
-rw-r--r--test/quote_calc.tab.c693
-rw-r--r--test/quote_calc.tab.h15
-rw-r--r--test/quote_calc.y112
-rw-r--r--test/quote_calc2-s.output557
-rw-r--r--test/quote_calc2-s.tab.c687
-rw-r--r--test/quote_calc2-s.tab.h9
-rw-r--r--test/quote_calc2.output557
-rw-r--r--test/quote_calc2.tab.c693
-rw-r--r--test/quote_calc2.tab.h15
-rw-r--r--test/quote_calc2.y112
-rw-r--r--test/quote_calc3-s.output557
-rw-r--r--test/quote_calc3-s.tab.c688
-rw-r--r--test/quote_calc3-s.tab.h9
-rw-r--r--test/quote_calc3.output557
-rw-r--r--test/quote_calc3.tab.c688
-rw-r--r--test/quote_calc3.tab.h9
-rw-r--r--test/quote_calc3.y112
-rw-r--r--test/quote_calc4-s.output557
-rw-r--r--test/quote_calc4-s.tab.c688
-rw-r--r--test/quote_calc4-s.tab.h9
-rw-r--r--test/quote_calc4.output557
-rw-r--r--test/quote_calc4.tab.c688
-rw-r--r--test/quote_calc4.tab.h9
-rw-r--r--test/quote_calc4.y112
-rwxr-xr-xtest/run_make.sh125
-rwxr-xr-xtest/run_test.sh71
52 files changed, 11276 insertions, 475 deletions
diff --git a/test/calc.tab.c b/test/calc.tab.c
index d13ebb9..de039ec 100644
--- a/test/calc.tab.c
+++ b/test/calc.tab.c
@@ -102,7 +102,10 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
int regs[26];
int base;
-#line 106 "calc.tab.c"
+extern int yylex(void);
+static void yyerror(const char *s);
+
+#line 109 "calc.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -130,8 +133,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
+#endif
extern int YYPARSE_DECL();
@@ -294,14 +301,9 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
-#line 63 "calc.y"
+#line 66 "calc.y"
/* start of programs */
-#ifdef YYBYACC
-extern int YYLEX_DECL();
-static void YYERROR_DECL();
-#endif
-
int
main (void)
{
@@ -341,7 +343,7 @@ yylex(void)
}
return( c );
}
-#line 345 "calc.tab.c"
+#line 347 "calc.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -548,66 +550,66 @@ yyreduce:
switch (yyn)
{
case 3:
-#line 25 "calc.y"
+#line 28 "calc.y"
{ yyerrok ; }
break;
case 4:
-#line 29 "calc.y"
+#line 32 "calc.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
-#line 31 "calc.y"
+#line 34 "calc.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
-#line 35 "calc.y"
+#line 38 "calc.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
-#line 37 "calc.y"
+#line 40 "calc.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
-#line 39 "calc.y"
+#line 42 "calc.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
-#line 41 "calc.y"
+#line 44 "calc.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
-#line 43 "calc.y"
+#line 46 "calc.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
-#line 45 "calc.y"
+#line 48 "calc.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
-#line 47 "calc.y"
+#line 50 "calc.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
-#line 49 "calc.y"
+#line 52 "calc.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
-#line 51 "calc.y"
+#line 54 "calc.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
-#line 53 "calc.y"
+#line 56 "calc.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
-#line 58 "calc.y"
+#line 61 "calc.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
-#line 60 "calc.y"
+#line 63 "calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 611 "calc.tab.c"
+#line 613 "calc.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/calc.y b/test/calc.y
index 654062b..c2e5a89 100644
--- a/test/calc.y
+++ b/test/calc.y
@@ -5,6 +5,9 @@
int regs[26];
int base;
+extern int yylex(void);
+static void yyerror(const char *s);
+
%}
%start list
@@ -62,11 +65,6 @@ number: DIGIT
%% /* start of programs */
-#ifdef YYBYACC
-extern int YYLEX_DECL();
-static void YYERROR_DECL();
-#endif
-
int
main (void)
{
diff --git a/test/calc1.tab.c b/test/calc1.tab.c
index 415b7f6..65551e8 100644
--- a/test/calc1.tab.c
+++ b/test/calc1.tab.c
@@ -113,12 +113,15 @@ INTERVAL;
INTERVAL vmul(double, double, INTERVAL);
INTERVAL vdiv(double, double, INTERVAL);
+extern int yylex(void);
+static void yyerror(const char *s);
+
int dcheck(INTERVAL);
double dreg[26];
INTERVAL vreg[26];
-#line 28 "calc1.y"
+#line 31 "calc1.y"
#ifdef YYSTYPE
#undef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
@@ -132,7 +135,7 @@ typedef union
INTERVAL vval;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
-#line 136 "calc1.tab.c"
+#line 139 "calc1.tab.c"
/* compatibility with bison */
#ifdef YYPARSE_PARAM
@@ -156,8 +159,12 @@ typedef union
#endif
/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
+#endif
extern int YYPARSE_DECL();
@@ -344,14 +351,9 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
-#line 173 "calc1.y"
+#line 176 "calc1.y"
/* beginning of subroutines section */
-#ifdef YYBYACC
-extern int YYLEX_DECL();
-static void YYERROR_DECL();
-#endif
-
#define BSZ 50 /* buffer size for floating point numbers */
/* lexical analysis */
@@ -480,7 +482,7 @@ vdiv(double a, double b, INTERVAL v)
{
return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
}
-#line 484 "calc1.tab.c"
+#line 486 "calc1.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -687,85 +689,85 @@ yyreduce:
switch (yyn)
{
case 3:
-#line 54 "calc1.y"
+#line 57 "calc1.y"
{
(void) printf("%15.8f\n", yystack.l_mark[-1].dval);
}
break;
case 4:
-#line 58 "calc1.y"
+#line 61 "calc1.y"
{
(void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi);
}
break;
case 5:
-#line 62 "calc1.y"
+#line 65 "calc1.y"
{
dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval;
}
break;
case 6:
-#line 66 "calc1.y"
+#line 69 "calc1.y"
{
vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval;
}
break;
case 7:
-#line 70 "calc1.y"
+#line 73 "calc1.y"
{
yyerrok;
}
break;
case 9:
-#line 77 "calc1.y"
+#line 80 "calc1.y"
{
yyval.dval = dreg[yystack.l_mark[0].ival];
}
break;
case 10:
-#line 81 "calc1.y"
+#line 84 "calc1.y"
{
yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval;
}
break;
case 11:
-#line 85 "calc1.y"
+#line 88 "calc1.y"
{
yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval;
}
break;
case 12:
-#line 89 "calc1.y"
+#line 92 "calc1.y"
{
yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval;
}
break;
case 13:
-#line 93 "calc1.y"
+#line 96 "calc1.y"
{
yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval;
}
break;
case 14:
-#line 97 "calc1.y"
+#line 100 "calc1.y"
{
yyval.dval = -yystack.l_mark[0].dval;
}
break;
case 15:
-#line 101 "calc1.y"
+#line 104 "calc1.y"
{
yyval.dval = yystack.l_mark[-1].dval;
}
break;
case 16:
-#line 107 "calc1.y"
+#line 110 "calc1.y"
{
yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval;
}
break;
case 17:
-#line 111 "calc1.y"
+#line 114 "calc1.y"
{
yyval.vval.lo = yystack.l_mark[-3].dval;
yyval.vval.hi = yystack.l_mark[-1].dval;
@@ -777,79 +779,79 @@ case 17:
}
break;
case 18:
-#line 121 "calc1.y"
+#line 124 "calc1.y"
{
yyval.vval = vreg[yystack.l_mark[0].ival];
}
break;
case 19:
-#line 125 "calc1.y"
+#line 128 "calc1.y"
{
yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi;
yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo;
}
break;
case 20:
-#line 130 "calc1.y"
+#line 133 "calc1.y"
{
yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi;
yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo;
}
break;
case 21:
-#line 135 "calc1.y"
+#line 138 "calc1.y"
{
yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo;
yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi;
}
break;
case 22:
-#line 140 "calc1.y"
+#line 143 "calc1.y"
{
yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo;
yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi;
}
break;
case 23:
-#line 145 "calc1.y"
+#line 148 "calc1.y"
{
yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
}
break;
case 24:
-#line 149 "calc1.y"
+#line 152 "calc1.y"
{
yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
}
break;
case 25:
-#line 153 "calc1.y"
+#line 156 "calc1.y"
{
if (dcheck(yystack.l_mark[0].vval)) YYERROR;
yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
}
break;
case 26:
-#line 158 "calc1.y"
+#line 161 "calc1.y"
{
if (dcheck ( yystack.l_mark[0].vval )) YYERROR;
yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
}
break;
case 27:
-#line 163 "calc1.y"
+#line 166 "calc1.y"
{
yyval.vval.hi = -yystack.l_mark[0].vval.lo;
yyval.vval.lo = -yystack.l_mark[0].vval.hi;
}
break;
case 28:
-#line 168 "calc1.y"
+#line 171 "calc1.y"
{
yyval.vval = yystack.l_mark[-1].vval;
}
break;
-#line 853 "calc1.tab.c"
+#line 855 "calc1.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/calc1.y b/test/calc1.y
index 00a560f..ec89736 100644
--- a/test/calc1.y
+++ b/test/calc1.y
@@ -16,6 +16,9 @@ INTERVAL;
INTERVAL vmul(double, double, INTERVAL);
INTERVAL vdiv(double, double, INTERVAL);
+extern int yylex(void);
+static void yyerror(const char *s);
+
int dcheck(INTERVAL);
double dreg[26];
@@ -172,11 +175,6 @@ vexp : dexp
%% /* beginning of subroutines section */
-#ifdef YYBYACC
-extern int YYLEX_DECL();
-static void YYERROR_DECL();
-#endif
-
#define BSZ 50 /* buffer size for floating point numbers */
/* lexical analysis */
diff --git a/test/calc2.tab.c b/test/calc2.tab.c
index 69ec2ba..1eb9548 100644
--- a/test/calc2.tab.c
+++ b/test/calc2.tab.c
@@ -99,7 +99,15 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
# include <stdio.h>
# include <ctype.h>
-#line 103 "calc2.tab.c"
+#ifdef YYBISON
+#define YYLEX_PARAM base
+#define YYLEX_DECL() yylex(int *YYLEX_PARAM)
+#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
+int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+#line 111 "calc2.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -127,8 +135,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s)
+#endif
+#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(regs, base, msg)
+#endif
extern int YYPARSE_DECL();
@@ -291,12 +303,11 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
-#line 65 "calc2.y"
+#line 73 "calc2.y"
/* start of programs */
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
int
@@ -318,7 +329,7 @@ YYERROR_DECL()
}
int
-yylex(int *base)
+YYLEX_DECL()
{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
@@ -341,7 +352,7 @@ yylex(int *base)
}
return( c );
}
-#line 345 "calc2.tab.c"
+#line 356 "calc2.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -548,66 +559,66 @@ yyreduce:
switch (yyn)
{
case 3:
-#line 27 "calc2.y"
+#line 35 "calc2.y"
{ yyerrok ; }
break;
case 4:
-#line 31 "calc2.y"
+#line 39 "calc2.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
-#line 33 "calc2.y"
+#line 41 "calc2.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
-#line 37 "calc2.y"
+#line 45 "calc2.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
-#line 39 "calc2.y"
+#line 47 "calc2.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
-#line 41 "calc2.y"
+#line 49 "calc2.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
-#line 43 "calc2.y"
+#line 51 "calc2.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
-#line 45 "calc2.y"
+#line 53 "calc2.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
-#line 47 "calc2.y"
+#line 55 "calc2.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
-#line 49 "calc2.y"
+#line 57 "calc2.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
-#line 51 "calc2.y"
+#line 59 "calc2.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
-#line 53 "calc2.y"
+#line 61 "calc2.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
-#line 55 "calc2.y"
+#line 63 "calc2.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
-#line 60 "calc2.y"
+#line 68 "calc2.y"
{ yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
-#line 62 "calc2.y"
+#line 70 "calc2.y"
{ yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 611 "calc2.tab.c"
+#line 622 "calc2.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/calc2.y b/test/calc2.y
index 4b2d42f..e742ff3 100644
--- a/test/calc2.y
+++ b/test/calc2.y
@@ -7,6 +7,14 @@
# include <stdio.h>
# include <ctype.h>
+#ifdef YYBISON
+#define YYLEX_PARAM base
+#define YYLEX_DECL() yylex(int *YYLEX_PARAM)
+#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
+int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
%}
%start list
@@ -66,7 +74,6 @@ number: DIGIT
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
int
@@ -88,7 +95,7 @@ YYERROR_DECL()
}
int
-yylex(int *base)
+YYLEX_DECL()
{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
diff --git a/test/calc3.tab.c b/test/calc3.tab.c
index 7d69117..9c38899 100644
--- a/test/calc3.tab.c
+++ b/test/calc3.tab.c
@@ -99,7 +99,16 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
# include <stdio.h>
# include <ctype.h>
-#line 103 "calc3.tab.c"
+#ifdef YYBISON
+#define YYSTYPE int
+#define YYLEX_PARAM base
+#define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM)
+#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
+int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+#line 112 "calc3.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -119,7 +128,11 @@ typedef int YYSTYPE;
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
-# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
+# ifdef YYLEX_PARAM_TYPE
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM)
+# else
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM)
+# endif
# define YYLEX yylex(&yylval, YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(YYSTYPE *yylval, int * base)
@@ -127,8 +140,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s)
+#endif
+#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(regs, base, msg)
+#endif
extern int YYPARSE_DECL();
@@ -284,12 +301,11 @@ typedef struct {
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
-#line 67 "calc3.y"
+#line 76 "calc3.y"
/* start of programs */
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
int
@@ -334,7 +350,7 @@ YYLEX_DECL()
}
return( c );
}
-#line 338 "calc3.tab.c"
+#line 354 "calc3.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -548,66 +564,66 @@ yyreduce:
switch (yyn)
{
case 3:
-#line 29 "calc3.y"
+#line 38 "calc3.y"
{ yyerrok ; }
break;
case 4:
-#line 33 "calc3.y"
+#line 42 "calc3.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
-#line 35 "calc3.y"
+#line 44 "calc3.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
-#line 39 "calc3.y"
+#line 48 "calc3.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
-#line 41 "calc3.y"
+#line 50 "calc3.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
-#line 43 "calc3.y"
+#line 52 "calc3.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
-#line 45 "calc3.y"
+#line 54 "calc3.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
-#line 47 "calc3.y"
+#line 56 "calc3.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
-#line 49 "calc3.y"
+#line 58 "calc3.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
-#line 51 "calc3.y"
+#line 60 "calc3.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
-#line 53 "calc3.y"
+#line 62 "calc3.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
-#line 55 "calc3.y"
+#line 64 "calc3.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
-#line 57 "calc3.y"
+#line 66 "calc3.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
-#line 62 "calc3.y"
+#line 71 "calc3.y"
{ yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
-#line 64 "calc3.y"
+#line 73 "calc3.y"
{ yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 611 "calc3.tab.c"
+#line 627 "calc3.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/calc3.y b/test/calc3.y
index 9b31546..252faa9 100644
--- a/test/calc3.y
+++ b/test/calc3.y
@@ -9,6 +9,15 @@
# include <stdio.h>
# include <ctype.h>
+#ifdef YYBISON
+#define YYSTYPE int
+#define YYLEX_PARAM base
+#define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM)
+#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
+int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
%}
%start list
@@ -68,7 +77,6 @@ number: DIGIT
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
int
diff --git a/test/code_calc.code.c b/test/code_calc.code.c
index 7521939..a3cf368 100644
--- a/test/code_calc.code.c
+++ b/test/code_calc.code.c
@@ -21,7 +21,12 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
int regs[26];
int base;
-#line 25 "code_calc.code.c"
+#ifdef YYBISON
+int yylex(void);
+static void yyerror(const char *s);
+#endif
+
+#line 30 "code_calc.code.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -49,8 +54,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
+#endif
extern int YYPARSE_DECL();
@@ -195,12 +204,11 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
-#line 63 "code_calc.y"
+#line 68 "code_calc.y"
/* start of programs */
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
int
@@ -219,7 +227,8 @@ yyerror(const char *s)
}
int
-yylex(void) {
+yylex(void)
+{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
@@ -241,7 +250,7 @@ yylex(void) {
}
return( c );
}
-#line 245 "code_calc.code.c"
+#line 254 "code_calc.code.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -448,66 +457,66 @@ yyreduce:
switch (yyn)
{
case 3:
-#line 25 "code_calc.y"
+#line 30 "code_calc.y"
{ yyerrok ; }
break;
case 4:
-#line 29 "code_calc.y"
+#line 34 "code_calc.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
-#line 31 "code_calc.y"
+#line 36 "code_calc.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
-#line 35 "code_calc.y"
+#line 40 "code_calc.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
-#line 37 "code_calc.y"
+#line 42 "code_calc.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
-#line 39 "code_calc.y"
+#line 44 "code_calc.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
-#line 41 "code_calc.y"
+#line 46 "code_calc.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
-#line 43 "code_calc.y"
+#line 48 "code_calc.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
-#line 45 "code_calc.y"
+#line 50 "code_calc.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
-#line 47 "code_calc.y"
+#line 52 "code_calc.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
-#line 49 "code_calc.y"
+#line 54 "code_calc.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
-#line 51 "code_calc.y"
+#line 56 "code_calc.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
-#line 53 "code_calc.y"
+#line 58 "code_calc.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
-#line 58 "code_calc.y"
+#line 63 "code_calc.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
-#line 60 "code_calc.y"
+#line 65 "code_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 511 "code_calc.code.c"
+#line 520 "code_calc.code.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/code_calc.y b/test/code_calc.y
index a9b0b3e..0a99456 100644
--- a/test/code_calc.y
+++ b/test/code_calc.y
@@ -5,6 +5,11 @@
int regs[26];
int base;
+#ifdef YYBISON
+int yylex(void);
+static void yyerror(const char *s);
+#endif
+
%}
%start list
@@ -64,7 +69,6 @@ number: DIGIT
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
int
@@ -83,7 +87,8 @@ yyerror(const char *s)
}
int
-yylex(void) {
+yylex(void)
+{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
diff --git a/test/code_error.code.c b/test/code_error.code.c
index f845db3..db50bbc 100644
--- a/test/code_error.code.c
+++ b/test/code_error.code.c
@@ -14,6 +14,14 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#define YYPURE 0
+#line 2 "code_error.y"
+
+#ifdef YYBISON
+int yylex(void);
+static void yyerror(const char *);
+#endif
+
+#line 25 "code_error.code.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -41,8 +49,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
+#endif
extern int YYPARSE_DECL();
@@ -184,13 +196,12 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
-#line 4 "code_error.y"
+#line 12 "code_error.y"
#include <stdio.h>
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
int
@@ -211,7 +222,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 215 "code_error.code.c"
+#line 226 "code_error.code.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
diff --git a/test/code_error.y b/test/code_error.y
index 3614433..bb77156 100644
--- a/test/code_error.y
+++ b/test/code_error.y
@@ -1,3 +1,11 @@
+%{
+
+#ifdef YYBISON
+int yylex(void);
+static void yyerror(const char *);
+#endif
+
+%}
%%
S: error
%%
@@ -6,7 +14,6 @@ S: error
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
int
diff --git a/test/error.tab.c b/test/error.tab.c
index 088f9d5..9113629 100644
--- a/test/error.tab.c
+++ b/test/error.tab.c
@@ -95,6 +95,10 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#define YYPURE 0
+#line 2 "error.y"
+int yylex(void);
+static void yyerror(const char *);
+#line 102 "error.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -122,8 +126,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
+#endif
extern int YYPARSE_DECL();
@@ -202,15 +210,10 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
-#line 4 "error.y"
+#line 8 "error.y"
#include <stdio.h>
-#ifdef YYBYACC
-extern int YYLEX_DECL();
-static void YYERROR_DECL();
-#endif
-
int
main(void)
{
@@ -229,7 +232,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 233 "error.tab.c"
+#line 236 "error.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
diff --git a/test/error.y b/test/error.y
index 3614433..673c68d 100644
--- a/test/error.y
+++ b/test/error.y
@@ -1,14 +1,13 @@
+%{
+int yylex(void);
+static void yyerror(const char *);
+%}
%%
S: error
%%
#include <stdio.h>
-#ifdef YYBYACC
-extern int YYLEX_DECL();
-static void YYERROR_DECL();
-#endif
-
int
main(void)
{
diff --git a/test/ftp.tab.c b/test/ftp.tab.c
index 2df84f7..c450766 100644
--- a/test/ftp.tab.c
+++ b/test/ftp.tab.c
@@ -119,6 +119,11 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#include <time.h>
#include <assert.h>
+#ifdef YYBISON
+int yylex(void);
+static void yyerror(const char *);
+#endif
+
extern struct sockaddr_in data_dest;
extern int logged_in;
extern struct passwd *pw;
@@ -167,16 +172,29 @@ static int cmd_bytesz;
char cbuf[512];
char *fromname;
-
+struct tab {
+ const char *name;
+ short token;
+ short state;
+ short implemented; /* 1 if command is implemented */
+ const char *help;
+};
static char * copy(const char *);
+#ifdef YYBISON
+static void sizecmd(char *filename);
+static void help(struct tab *ctab, char *s);
+struct tab cmdtab[];
+struct tab sitetab[];
+#endif
+
static void
yyerror(const char *msg)
{
perror(msg);
}
-#line 180 "ftp.tab.c"
+#line 198 "ftp.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -204,8 +222,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
+#endif
extern int YYPARSE_DECL();
@@ -543,11 +565,10 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
-#line 689 "ftp.y"
+#line 707 "ftp.y"
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
extern jmp_buf errcatch;
@@ -564,14 +585,6 @@ static void upper(char *);
#define SITECMD 7 /* SITE command */
#define NSTR 8 /* Number followed by a string */
-struct tab {
- const char *name;
- short token;
- short state;
- short implemented; /* 1 if command is implemented */
- const char *help;
-};
-
struct tab cmdtab[] = { /* In order defined in RFC 765 */
{ "USER", USER, STR1, 1, "<sp> username" },
{ "PASS", PASS, ZSTR1, 1, "<sp> password" },
@@ -1075,7 +1088,7 @@ sizecmd(char *filename)
reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
}
}
-#line 1079 "ftp.tab.c"
+#line 1092 "ftp.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -1282,27 +1295,27 @@ yyreduce:
switch (yyn)
{
case 2:
-#line 132 "ftp.y"
+#line 150 "ftp.y"
{
fromname = (char *) 0;
}
break;
case 4:
-#line 139 "ftp.y"
+#line 157 "ftp.y"
{
user((char *) yystack.l_mark[-1]);
free((char *) yystack.l_mark[-1]);
}
break;
case 5:
-#line 144 "ftp.y"
+#line 162 "ftp.y"
{
pass((char *) yystack.l_mark[-1]);
free((char *) yystack.l_mark[-1]);
}
break;
case 6:
-#line 149 "ftp.y"
+#line 167 "ftp.y"
{
usedefault = 0;
if (pdata >= 0) {
@@ -1313,13 +1326,13 @@ case 6:
}
break;
case 7:
-#line 158 "ftp.y"
+#line 176 "ftp.y"
{
passive();
}
break;
case 8:
-#line 162 "ftp.y"
+#line 180 "ftp.y"
{
switch (cmd_type) {
@@ -1356,7 +1369,7 @@ case 8:
}
break;
case 9:
-#line 197 "ftp.y"
+#line 215 "ftp.y"
{
switch (yystack.l_mark[-1]) {
@@ -1370,7 +1383,7 @@ case 9:
}
break;
case 10:
-#line 209 "ftp.y"
+#line 227 "ftp.y"
{
switch (yystack.l_mark[-1]) {
@@ -1384,19 +1397,19 @@ case 10:
}
break;
case 11:
-#line 221 "ftp.y"
+#line 239 "ftp.y"
{
reply(202, "ALLO command ignored.");
}
break;
case 12:
-#line 225 "ftp.y"
+#line 243 "ftp.y"
{
reply(202, "ALLO command ignored.");
}
break;
case 13:
-#line 229 "ftp.y"
+#line 247 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
retrieve((char *) 0, (char *) yystack.l_mark[-1]);
@@ -1405,7 +1418,7 @@ case 13:
}
break;
case 14:
-#line 236 "ftp.y"
+#line 254 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
store((char *) yystack.l_mark[-1], "w", 0);
@@ -1414,7 +1427,7 @@ case 14:
}
break;
case 15:
-#line 243 "ftp.y"
+#line 261 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
store((char *) yystack.l_mark[-1], "a", 0);
@@ -1423,14 +1436,14 @@ case 15:
}
break;
case 16:
-#line 250 "ftp.y"
+#line 268 "ftp.y"
{
if (yystack.l_mark[-1])
send_file_list(".");
}
break;
case 17:
-#line 255 "ftp.y"
+#line 273 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
send_file_list((char *) yystack.l_mark[-1]);
@@ -1439,14 +1452,14 @@ case 17:
}
break;
case 18:
-#line 262 "ftp.y"
+#line 280 "ftp.y"
{
if (yystack.l_mark[-1])
retrieve("/bin/ls -lgA", "");
}
break;
case 19:
-#line 267 "ftp.y"
+#line 285 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
retrieve("/bin/ls -lgA %s", (char *) yystack.l_mark[-1]);
@@ -1455,7 +1468,7 @@ case 19:
}
break;
case 20:
-#line 274 "ftp.y"
+#line 292 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
statfilecmd((char *) yystack.l_mark[-1]);
@@ -1464,13 +1477,13 @@ case 20:
}
break;
case 21:
-#line 281 "ftp.y"
+#line 299 "ftp.y"
{
statcmd();
}
break;
case 22:
-#line 285 "ftp.y"
+#line 303 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
remove((char *) yystack.l_mark[-1]);
@@ -1479,7 +1492,7 @@ case 22:
}
break;
case 23:
-#line 292 "ftp.y"
+#line 310 "ftp.y"
{
if (fromname) {
renamecmd(fromname, (char *) yystack.l_mark[-1]);
@@ -1492,20 +1505,20 @@ case 23:
}
break;
case 24:
-#line 303 "ftp.y"
+#line 321 "ftp.y"
{
reply(225, "ABOR command successful.");
}
break;
case 25:
-#line 307 "ftp.y"
+#line 325 "ftp.y"
{
if (yystack.l_mark[-1])
cwd(pw->pw_dir);
}
break;
case 26:
-#line 312 "ftp.y"
+#line 330 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
cwd((char *) yystack.l_mark[-1]);
@@ -1514,13 +1527,13 @@ case 26:
}
break;
case 27:
-#line 319 "ftp.y"
+#line 337 "ftp.y"
{
help(cmdtab, (char *) 0);
}
break;
case 28:
-#line 323 "ftp.y"
+#line 341 "ftp.y"
{
register char *cp = (char *)yystack.l_mark[-1];
@@ -1537,13 +1550,13 @@ case 28:
}
break;
case 29:
-#line 338 "ftp.y"
+#line 356 "ftp.y"
{
reply(200, "NOOP command successful.");
}
break;
case 30:
-#line 342 "ftp.y"
+#line 360 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
makedir((char *) yystack.l_mark[-1]);
@@ -1552,7 +1565,7 @@ case 30:
}
break;
case 31:
-#line 349 "ftp.y"
+#line 367 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
removedir((char *) yystack.l_mark[-1]);
@@ -1561,33 +1574,33 @@ case 31:
}
break;
case 32:
-#line 356 "ftp.y"
+#line 374 "ftp.y"
{
if (yystack.l_mark[-1])
pwd();
}
break;
case 33:
-#line 361 "ftp.y"
+#line 379 "ftp.y"
{
if (yystack.l_mark[-1])
cwd("..");
}
break;
case 34:
-#line 366 "ftp.y"
+#line 384 "ftp.y"
{
help(sitetab, (char *) 0);
}
break;
case 35:
-#line 370 "ftp.y"
+#line 388 "ftp.y"
{
help(sitetab, (char *) yystack.l_mark[-1]);
}
break;
case 36:
-#line 374 "ftp.y"
+#line 392 "ftp.y"
{
int oldmask;
@@ -1599,7 +1612,7 @@ case 36:
}
break;
case 37:
-#line 384 "ftp.y"
+#line 402 "ftp.y"
{
int oldmask;
@@ -1616,7 +1629,7 @@ case 37:
}
break;
case 38:
-#line 399 "ftp.y"
+#line 417 "ftp.y"
{
if (yystack.l_mark[-5] && (yystack.l_mark[-1] != 0)) {
if (yystack.l_mark[-3] > 0777)
@@ -1632,7 +1645,7 @@ case 38:
}
break;
case 39:
-#line 413 "ftp.y"
+#line 431 "ftp.y"
{
reply(200,
"Current IDLE time limit is %d seconds; max %d",
@@ -1640,7 +1653,7 @@ case 39:
}
break;
case 40:
-#line 419 "ftp.y"
+#line 437 "ftp.y"
{
if (yystack.l_mark[-1] < 30 || yystack.l_mark[-1] > maxtimeout) {
reply(501,
@@ -1656,7 +1669,7 @@ case 40:
}
break;
case 41:
-#line 433 "ftp.y"
+#line 451 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
store((char *) yystack.l_mark[-1], "w", 1);
@@ -1665,7 +1678,7 @@ case 41:
}
break;
case 42:
-#line 440 "ftp.y"
+#line 458 "ftp.y"
{
#ifdef unix
#ifdef BSD
@@ -1680,7 +1693,7 @@ case 42:
}
break;
case 43:
-#line 461 "ftp.y"
+#line 479 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
sizecmd((char *) yystack.l_mark[-1]);
@@ -1689,7 +1702,7 @@ case 43:
}
break;
case 44:
-#line 478 "ftp.y"
+#line 496 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0) {
struct stat stbuf;
@@ -1713,20 +1726,20 @@ case 44:
}
break;
case 45:
-#line 500 "ftp.y"
+#line 518 "ftp.y"
{
reply(221, "Goodbye.");
dologout(0);
}
break;
case 46:
-#line 505 "ftp.y"
+#line 523 "ftp.y"
{
yyerrok;
}
break;
case 47:
-#line 510 "ftp.y"
+#line 528 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1]) {
fromname = renamefrom((char *) yystack.l_mark[-1]);
@@ -1737,13 +1750,13 @@ case 47:
}
break;
case 49:
-#line 524 "ftp.y"
+#line 542 "ftp.y"
{
*(const char **)(&(yyval)) = "";
}
break;
case 52:
-#line 535 "ftp.y"
+#line 553 "ftp.y"
{
register char *a, *p;
@@ -1755,116 +1768,116 @@ case 52:
}
break;
case 53:
-#line 547 "ftp.y"
+#line 565 "ftp.y"
{
yyval = FORM_N;
}
break;
case 54:
-#line 551 "ftp.y"
+#line 569 "ftp.y"
{
yyval = FORM_T;
}
break;
case 55:
-#line 555 "ftp.y"
+#line 573 "ftp.y"
{
yyval = FORM_C;
}
break;
case 56:
-#line 561 "ftp.y"
+#line 579 "ftp.y"
{
cmd_type = TYPE_A;
cmd_form = FORM_N;
}
break;
case 57:
-#line 566 "ftp.y"
+#line 584 "ftp.y"
{
cmd_type = TYPE_A;
cmd_form = yystack.l_mark[0];
}
break;
case 58:
-#line 571 "ftp.y"
+#line 589 "ftp.y"
{
cmd_type = TYPE_E;
cmd_form = FORM_N;
}
break;
case 59:
-#line 576 "ftp.y"
+#line 594 "ftp.y"
{
cmd_type = TYPE_E;
cmd_form = yystack.l_mark[0];
}
break;
case 60:
-#line 581 "ftp.y"
+#line 599 "ftp.y"
{
cmd_type = TYPE_I;
}
break;
case 61:
-#line 585 "ftp.y"
+#line 603 "ftp.y"
{
cmd_type = TYPE_L;
cmd_bytesz = NBBY;
}
break;
case 62:
-#line 590 "ftp.y"
+#line 608 "ftp.y"
{
cmd_type = TYPE_L;
cmd_bytesz = yystack.l_mark[0];
}
break;
case 63:
-#line 596 "ftp.y"
+#line 614 "ftp.y"
{
cmd_type = TYPE_L;
cmd_bytesz = yystack.l_mark[0];
}
break;
case 64:
-#line 603 "ftp.y"
+#line 621 "ftp.y"
{
yyval = STRU_F;
}
break;
case 65:
-#line 607 "ftp.y"
+#line 625 "ftp.y"
{
yyval = STRU_R;
}
break;
case 66:
-#line 611 "ftp.y"
+#line 629 "ftp.y"
{
yyval = STRU_P;
}
break;
case 67:
-#line 617 "ftp.y"
+#line 635 "ftp.y"
{
yyval = MODE_S;
}
break;
case 68:
-#line 621 "ftp.y"
+#line 639 "ftp.y"
{
yyval = MODE_B;
}
break;
case 69:
-#line 625 "ftp.y"
+#line 643 "ftp.y"
{
yyval = MODE_C;
}
break;
case 70:
-#line 631 "ftp.y"
+#line 649 "ftp.y"
{
/*
* Problem: this production is used for all pathname
@@ -1883,7 +1896,7 @@ case 70:
}
break;
case 72:
-#line 653 "ftp.y"
+#line 671 "ftp.y"
{
register int ret, dec, multby, digit;
@@ -1908,7 +1921,7 @@ case 72:
}
break;
case 73:
-#line 678 "ftp.y"
+#line 696 "ftp.y"
{
if (logged_in)
yyval = 1;
@@ -1918,7 +1931,7 @@ case 73:
}
}
break;
-#line 1922 "ftp.tab.c"
+#line 1935 "ftp.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/ftp.y b/test/ftp.y
index 4ad33e3..42c210b 100644
--- a/test/ftp.y
+++ b/test/ftp.y
@@ -46,6 +46,11 @@
#include <time.h>
#include <assert.h>
+#ifdef YYBISON
+int yylex(void);
+static void yyerror(const char *);
+#endif
+
extern struct sockaddr_in data_dest;
extern int logged_in;
extern struct passwd *pw;
@@ -94,10 +99,23 @@ static int cmd_bytesz;
char cbuf[512];
char *fromname;
-
+struct tab {
+ const char *name;
+ short token;
+ short state;
+ short implemented; /* 1 if command is implemented */
+ const char *help;
+};
static char * copy(const char *);
+#ifdef YYBISON
+static void sizecmd(char *filename);
+static void help(struct tab *ctab, char *s);
+struct tab cmdtab[];
+struct tab sitetab[];
+#endif
+
static void
yyerror(const char *msg)
{
@@ -129,24 +147,24 @@ yyerror(const char *msg)
cmd_list: /* empty */
| cmd_list cmd
- = {
+ {
fromname = (char *) 0;
}
| cmd_list rcmd
;
cmd: USER SP username CRLF
- = {
+ {
user((char *) $3);
free((char *) $3);
}
| PASS SP password CRLF
- = {
+ {
pass((char *) $3);
free((char *) $3);
}
| PORT SP host_port CRLF
- = {
+ {
usedefault = 0;
if (pdata >= 0) {
(void) close(pdata);
@@ -155,11 +173,11 @@ cmd: USER SP username CRLF
reply(200, "PORT command successful.");
}
| PASV CRLF
- = {
+ {
passive();
}
| TYPE SP type_code CRLF
- = {
+ {
switch (cmd_type) {
case TYPE_A:
@@ -194,7 +212,7 @@ cmd: USER SP username CRLF
}
}
| STRU SP struct_code CRLF
- = {
+ {
switch ($3) {
case STRU_F:
@@ -206,7 +224,7 @@ cmd: USER SP username CRLF
}
}
| MODE SP mode_code CRLF
- = {
+ {
switch ($3) {
case MODE_S:
@@ -218,78 +236,78 @@ cmd: USER SP username CRLF
}
}
| ALLO SP NUMBER CRLF
- = {
+ {
reply(202, "ALLO command ignored.");
}
| ALLO SP NUMBER SP R SP NUMBER CRLF
- = {
+ {
reply(202, "ALLO command ignored.");
}
| RETR check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0)
retrieve((char *) 0, (char *) $4);
if ($4 != 0)
free((char *) $4);
}
| STOR check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0)
store((char *) $4, "w", 0);
if ($4 != 0)
free((char *) $4);
}
| APPE check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0)
store((char *) $4, "a", 0);
if ($4 != 0)
free((char *) $4);
}
| NLST check_login CRLF
- = {
+ {
if ($2)
send_file_list(".");
}
| NLST check_login SP STRING CRLF
- = {
+ {
if ($2 && $4 != 0)
send_file_list((char *) $4);
if ($4 != 0)
free((char *) $4);
}
| LIST check_login CRLF
- = {
+ {
if ($2)
retrieve("/bin/ls -lgA", "");
}
| LIST check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0)
retrieve("/bin/ls -lgA %s", (char *) $4);
if ($4 != 0)
free((char *) $4);
}
| STAT check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0)
statfilecmd((char *) $4);
if ($4 != 0)
free((char *) $4);
}
| STAT CRLF
- = {
+ {
statcmd();
}
| DELE check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0)
remove((char *) $4);
if ($4 != 0)
free((char *) $4);
}
| RNTO SP pathname CRLF
- = {
+ {
if (fromname) {
renamecmd(fromname, (char *) $3);
free(fromname);
@@ -300,27 +318,27 @@ cmd: USER SP username CRLF
free((char *) $3);
}
| ABOR CRLF
- = {
+ {
reply(225, "ABOR command successful.");
}
| CWD check_login CRLF
- = {
+ {
if ($2)
cwd(pw->pw_dir);
}
| CWD check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0)
cwd((char *) $4);
if ($4 != 0)
free((char *) $4);
}
| HELP CRLF
- = {
+ {
help(cmdtab, (char *) 0);
}
| HELP SP STRING CRLF
- = {
+ {
register char *cp = (char *)$3;
if (strncasecmp(cp, "SITE", 4) == 0) {
@@ -335,43 +353,43 @@ cmd: USER SP username CRLF
help(cmdtab, (char *) $3);
}
| NOOP CRLF
- = {
+ {
reply(200, "NOOP command successful.");
}
| MKD check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0)
makedir((char *) $4);
if ($4 != 0)
free((char *) $4);
}
| RMD check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0)
removedir((char *) $4);
if ($4 != 0)
free((char *) $4);
}
| PWD check_login CRLF
- = {
+ {
if ($2)
pwd();
}
| CDUP check_login CRLF
- = {
+ {
if ($2)
cwd("..");
}
| SITE SP HELP CRLF
- = {
+ {
help(sitetab, (char *) 0);
}
| SITE SP HELP SP STRING CRLF
- = {
+ {
help(sitetab, (char *) $5);
}
| SITE SP UMASK check_login CRLF
- = {
+ {
int oldmask;
if ($4) {
@@ -381,7 +399,7 @@ cmd: USER SP username CRLF
}
}
| SITE SP UMASK check_login SP octal_number CRLF
- = {
+ {
int oldmask;
if ($4) {
@@ -396,7 +414,7 @@ cmd: USER SP username CRLF
}
}
| SITE SP CHMOD check_login SP octal_number SP pathname CRLF
- = {
+ {
if ($4 && ($8 != 0)) {
if ($6 > 0777)
reply(501,
@@ -410,13 +428,13 @@ cmd: USER SP username CRLF
free((char *) $8);
}
| SITE SP IDLE CRLF
- = {
+ {
reply(200,
"Current IDLE time limit is %d seconds; max %d",
timeout, maxtimeout);
}
| SITE SP IDLE SP NUMBER CRLF
- = {
+ {
if ($5 < 30 || $5 > maxtimeout) {
reply(501,
"Maximum IDLE time must be between 30 and %d seconds",
@@ -430,14 +448,14 @@ cmd: USER SP username CRLF
}
}
| STOU check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0)
store((char *) $4, "w", 1);
if ($4 != 0)
free((char *) $4);
}
| SYST CRLF
- = {
+ {
#ifdef unix
#ifdef BSD
reply(215, "UNIX Type: L%d Version: BSD-%d",
@@ -458,7 +476,7 @@ cmd: USER SP username CRLF
* using with RESTART (we just count bytes).
*/
| SIZE check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0)
sizecmd((char *) $4);
if ($4 != 0)
@@ -475,7 +493,7 @@ cmd: USER SP username CRLF
* not necessarily 3 digits)
*/
| MDTM check_login SP pathname CRLF
- = {
+ {
if ($2 && $4 != 0) {
struct stat stbuf;
if (stat((char *) $4, &stbuf) < 0)
@@ -497,17 +515,17 @@ cmd: USER SP username CRLF
free((char *) $4);
}
| QUIT CRLF
- = {
+ {
reply(221, "Goodbye.");
dologout(0);
}
| error CRLF
- = {
+ {
yyerrok;
}
;
rcmd: RNFR check_login SP pathname CRLF
- = {
+ {
if ($2 && $4) {
fromname = renamefrom((char *) $4);
if (fromname == (char *) 0 && $4) {
@@ -521,7 +539,7 @@ username: STRING
;
password: /* empty */
- = {
+ {
*(const char **)(&($$)) = "";
}
| STRING
@@ -532,7 +550,7 @@ byte_size: NUMBER
host_port: NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA
NUMBER COMMA NUMBER
- = {
+ {
register char *a, *p;
a = (char *)&data_dest.sin_addr;
@@ -544,91 +562,91 @@ host_port: NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA
;
form_code: N
- = {
+ {
$$ = FORM_N;
}
| T
- = {
+ {
$$ = FORM_T;
}
| C
- = {
+ {
$$ = FORM_C;
}
;
type_code: A
- = {
+ {
cmd_type = TYPE_A;
cmd_form = FORM_N;
}
| A SP form_code
- = {
+ {
cmd_type = TYPE_A;
cmd_form = $3;
}
| E
- = {
+ {
cmd_type = TYPE_E;
cmd_form = FORM_N;
}
| E SP form_code
- = {
+ {
cmd_type = TYPE_E;
cmd_form = $3;
}
| I
- = {
+ {
cmd_type = TYPE_I;
}
| L
- = {
+ {
cmd_type = TYPE_L;
cmd_bytesz = NBBY;
}
| L SP byte_size
- = {
+ {
cmd_type = TYPE_L;
cmd_bytesz = $3;
}
/* this is for a bug in the BBN ftp */
| L byte_size
- = {
+ {
cmd_type = TYPE_L;
cmd_bytesz = $2;
}
;
struct_code: F
- = {
+ {
$$ = STRU_F;
}
| R
- = {
+ {
$$ = STRU_R;
}
| P
- = {
+ {
$$ = STRU_P;
}
;
mode_code: S
- = {
+ {
$$ = MODE_S;
}
| B
- = {
+ {
$$ = MODE_B;
}
| C
- = {
+ {
$$ = MODE_C;
}
;
pathname: pathstring
- = {
+ {
/*
* Problem: this production is used for all pathname
* processing, but only gives a 550 error reply.
@@ -650,7 +668,7 @@ pathstring: STRING
;
octal_number: NUMBER
- = {
+ {
register int ret, dec, multby, digit;
/*
@@ -675,7 +693,7 @@ octal_number: NUMBER
;
check_login: /* empty */
- = {
+ {
if (logged_in)
$$ = 1;
else {
@@ -689,7 +707,6 @@ check_login: /* empty */
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
extern jmp_buf errcatch;
@@ -706,14 +723,6 @@ static void upper(char *);
#define SITECMD 7 /* SITE command */
#define NSTR 8 /* Number followed by a string */
-struct tab {
- const char *name;
- short token;
- short state;
- short implemented; /* 1 if command is implemented */
- const char *help;
-};
-
struct tab cmdtab[] = { /* In order defined in RFC 765 */
{ "USER", USER, STR1, 1, "<sp> username" },
{ "PASS", PASS, ZSTR1, 1, "<sp> password" },
diff --git a/test/grammar.tab.c b/test/grammar.tab.c
index f2ff21f..64ffe1e 100644
--- a/test/grammar.tab.c
+++ b/test/grammar.tab.c
@@ -95,7 +95,17 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#define YYPURE 0
-#line 69 "grammar.y"
+#line 9 "grammar.y"
+#ifdef YYBISON
+#include <stdlib.h>
+#define YYSTYPE_IS_DECLARED
+#define yyerror yaccError
+#endif
+
+#if defined(YYBISON) || !defined(YYBYACC)
+static void yyerror(const char *s);
+#endif
+#line 81 "grammar.y"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
@@ -298,8 +308,6 @@ extern boolean file_comments;
extern FuncDefStyle func_style;
extern char base_file[];
-#define YYMAXDEPTH 150
-
extern int yylex (void);
/* declaration specifier attributes for the typedef statement currently being
@@ -374,7 +382,7 @@ haveAnsiParam (void)
}
return FALSE;
}
-#line 378 "grammar.tab.c"
+#line 386 "grammar.tab.c"
/* compatibility with bison */
#ifdef YYPARSE_PARAM
@@ -398,8 +406,12 @@ haveAnsiParam (void)
#endif
/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
+#endif
extern int YYPARSE_DECL();
@@ -898,7 +910,7 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
-#line 1004 "grammar.y"
+#line 1014 "grammar.y"
/* lex.yy.c */
#define BEGIN yy_start = 1 + 2 *
@@ -1069,7 +1081,7 @@ free_parser(void)
#endif
}
#endif
-#line 1073 "grammar.tab.c"
+#line 1085 "grammar.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -1276,19 +1288,19 @@ yyreduce:
switch (yyn)
{
case 10:
-#line 367 "grammar.y"
+#line 377 "grammar.y"
{
yyerrok;
}
break;
case 11:
-#line 371 "grammar.y"
+#line 381 "grammar.y"
{
yyerrok;
}
break;
case 13:
-#line 382 "grammar.y"
+#line 392 "grammar.y"
{
/* Provide an empty action here so bison will not complain about
* incompatible types in the default action it normally would
@@ -1297,13 +1309,13 @@ case 13:
}
break;
case 14:
-#line 389 "grammar.y"
+#line 399 "grammar.y"
{
/* empty */
}
break;
case 15:
-#line 396 "grammar.y"
+#line 406 "grammar.y"
{
#if OPT_LINTLIBRARY
if (types_out && want_typedef()) {
@@ -1316,7 +1328,7 @@ case 15:
}
break;
case 16:
-#line 407 "grammar.y"
+#line 417 "grammar.y"
{
if (func_params != NULL) {
set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
@@ -1332,32 +1344,32 @@ case 16:
}
break;
case 17:
-#line 421 "grammar.y"
+#line 431 "grammar.y"
{
cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags;
free_decl_spec(&yystack.l_mark[0].decl_spec);
}
break;
case 18:
-#line 426 "grammar.y"
+#line 436 "grammar.y"
{
end_typedef();
}
break;
case 19:
-#line 433 "grammar.y"
+#line 443 "grammar.y"
{
begin_typedef();
}
break;
case 20:
-#line 437 "grammar.y"
+#line 447 "grammar.y"
{
begin_typedef();
}
break;
case 23:
-#line 449 "grammar.y"
+#line 459 "grammar.y"
{
int flags = cur_decl_spec_flags;
@@ -1371,7 +1383,7 @@ case 23:
}
break;
case 24:
-#line 461 "grammar.y"
+#line 471 "grammar.y"
{
int flags = cur_decl_spec_flags;
@@ -1382,7 +1394,7 @@ case 24:
}
break;
case 25:
-#line 473 "grammar.y"
+#line 483 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
@@ -1395,7 +1407,7 @@ case 25:
}
break;
case 26:
-#line 484 "grammar.y"
+#line 494 "grammar.y"
{
/* If we're converting to K&R and we've got a nominally K&R
* function which has a parameter which is ANSI (i.e., a prototyped
@@ -1421,7 +1433,7 @@ case 26:
}
break;
case 28:
-#line 509 "grammar.y"
+#line 519 "grammar.y"
{
if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
yyerror("syntax error");
@@ -1433,7 +1445,7 @@ case 28:
}
break;
case 29:
-#line 519 "grammar.y"
+#line 529 "grammar.y"
{
DeclSpec decl_spec;
@@ -1451,7 +1463,7 @@ case 29:
}
break;
case 36:
-#line 550 "grammar.y"
+#line 560 "grammar.y"
{
join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec);
free(yystack.l_mark[-1].decl_spec.text);
@@ -1459,115 +1471,115 @@ case 36:
}
break;
case 40:
-#line 565 "grammar.y"
+#line 575 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 41:
-#line 569 "grammar.y"
+#line 579 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN);
}
break;
case 42:
-#line 573 "grammar.y"
+#line 583 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 43:
-#line 577 "grammar.y"
+#line 587 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC);
}
break;
case 44:
-#line 581 "grammar.y"
+#line 591 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE);
}
break;
case 45:
-#line 585 "grammar.y"
+#line 595 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK);
}
break;
case 46:
-#line 592 "grammar.y"
+#line 602 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
}
break;
case 47:
-#line 596 "grammar.y"
+#line 606 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 48:
-#line 600 "grammar.y"
+#line 610 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT);
}
break;
case 49:
-#line 604 "grammar.y"
+#line 614 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 50:
-#line 608 "grammar.y"
+#line 618 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 51:
-#line 612 "grammar.y"
+#line 622 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT);
}
break;
case 52:
-#line 616 "grammar.y"
+#line 626 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 53:
-#line 620 "grammar.y"
+#line 630 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 54:
-#line 624 "grammar.y"
+#line 634 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 55:
-#line 628 "grammar.y"
+#line 638 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
}
break;
case 56:
-#line 632 "grammar.y"
+#line 642 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 57:
-#line 636 "grammar.y"
+#line 646 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 58:
-#line 640 "grammar.y"
+#line 650 "grammar.y"
{
Symbol *s;
s = find_symbol(typedef_names, yystack.l_mark[0].text.text);
@@ -1576,13 +1588,13 @@ case 58:
}
break;
case 61:
-#line 652 "grammar.y"
+#line 662 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 62:
-#line 656 "grammar.y"
+#line 666 "grammar.y"
{
/* This rule allows the <pointer> nonterminal to scan #define
* names as if they were type modifiers.
@@ -1594,7 +1606,7 @@ case 62:
}
break;
case 63:
-#line 669 "grammar.y"
+#line 679 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
@@ -1603,7 +1615,7 @@ case 63:
}
break;
case 64:
-#line 676 "grammar.y"
+#line 686 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
@@ -1612,38 +1624,38 @@ case 64:
}
break;
case 65:
-#line 683 "grammar.y"
+#line 693 "grammar.y"
{
(void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 66:
-#line 691 "grammar.y"
+#line 701 "grammar.y"
{
imply_typedef(yyval.text.text);
}
break;
case 67:
-#line 695 "grammar.y"
+#line 705 "grammar.y"
{
imply_typedef(yyval.text.text);
}
break;
case 68:
-#line 702 "grammar.y"
+#line 712 "grammar.y"
{
new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator);
}
break;
case 69:
-#line 706 "grammar.y"
+#line 716 "grammar.y"
{
add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator);
}
break;
case 70:
-#line 713 "grammar.y"
+#line 723 "grammar.y"
{
if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
func_style == FUNC_TRADITIONAL && cur_file->convert) {
@@ -1654,7 +1666,7 @@ case 70:
}
break;
case 71:
-#line 722 "grammar.y"
+#line 732 "grammar.y"
{
if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
func_style == FUNC_TRADITIONAL && cur_file->convert) {
@@ -1664,7 +1676,7 @@ case 71:
}
break;
case 73:
-#line 734 "grammar.y"
+#line 744 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
@@ -1673,7 +1685,7 @@ case 73:
}
break;
case 74:
-#line 741 "grammar.y"
+#line 751 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
@@ -1682,21 +1694,21 @@ case 74:
}
break;
case 75:
-#line 748 "grammar.y"
+#line 758 "grammar.y"
{
(void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text);
new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 76:
-#line 756 "grammar.y"
+#line 766 "grammar.y"
{
imply_typedef("enum");
yyval.text = yystack.l_mark[0].text;
}
break;
case 79:
-#line 769 "grammar.y"
+#line 779 "grammar.y"
{
yyval.declarator = yystack.l_mark[0].declarator;
(void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
@@ -1707,13 +1719,13 @@ case 79:
}
break;
case 81:
-#line 782 "grammar.y"
+#line 792 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin);
}
break;
case 82:
-#line 786 "grammar.y"
+#line 796 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
(void)sprintf(buf, "(%s)", yyval.declarator->text);
@@ -1723,7 +1735,7 @@ case 82:
}
break;
case 83:
-#line 794 "grammar.y"
+#line 804 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
(void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
@@ -1732,7 +1744,7 @@ case 83:
}
break;
case 84:
-#line 801 "grammar.y"
+#line 811 "grammar.y"
{
yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -1742,7 +1754,7 @@ case 84:
}
break;
case 85:
-#line 809 "grammar.y"
+#line 819 "grammar.y"
{
yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -1752,28 +1764,28 @@ case 85:
}
break;
case 86:
-#line 820 "grammar.y"
+#line 830 "grammar.y"
{
(void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text);
yyval.text.begin = yystack.l_mark[-1].text.begin;
}
break;
case 87:
-#line 825 "grammar.y"
+#line 835 "grammar.y"
{
(void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
yyval.text.begin = yystack.l_mark[-2].text.begin;
}
break;
case 88:
-#line 833 "grammar.y"
+#line 843 "grammar.y"
{
strcpy(yyval.text.text, "");
yyval.text.begin = 0L;
}
break;
case 90:
-#line 842 "grammar.y"
+#line 852 "grammar.y"
{
(void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text);
yyval.text.begin = yystack.l_mark[0].decl_spec.begin;
@@ -1781,7 +1793,7 @@ case 90:
}
break;
case 91:
-#line 848 "grammar.y"
+#line 858 "grammar.y"
{
(void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text);
yyval.text.begin = yystack.l_mark[-1].text.begin;
@@ -1789,71 +1801,71 @@ case 91:
}
break;
case 93:
-#line 858 "grammar.y"
+#line 868 "grammar.y"
{
add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "...");
}
break;
case 94:
-#line 865 "grammar.y"
+#line 875 "grammar.y"
{
new_param_list(&yyval.param_list, yystack.l_mark[0].parameter);
}
break;
case 95:
-#line 869 "grammar.y"
+#line 879 "grammar.y"
{
add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter);
}
break;
case 96:
-#line 876 "grammar.y"
+#line 886 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
}
break;
case 97:
-#line 881 "grammar.y"
+#line 891 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
}
break;
case 98:
-#line 886 "grammar.y"
+#line 896 "grammar.y"
{
check_untagged(&yystack.l_mark[0].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0);
}
break;
case 99:
-#line 894 "grammar.y"
+#line 904 "grammar.y"
{
new_ident_list(&yyval.param_list);
}
break;
case 101:
-#line 902 "grammar.y"
+#line 912 "grammar.y"
{
new_ident_list(&yyval.param_list);
add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text);
}
break;
case 102:
-#line 907 "grammar.y"
+#line 917 "grammar.y"
{
add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text);
}
break;
case 103:
-#line 914 "grammar.y"
+#line 924 "grammar.y"
{
yyval.text = yystack.l_mark[0].text;
}
break;
case 104:
-#line 918 "grammar.y"
+#line 928 "grammar.y"
{
#if OPT_LINTLIBRARY
if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
@@ -1865,13 +1877,13 @@ case 104:
}
break;
case 105:
-#line 931 "grammar.y"
+#line 941 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
}
break;
case 106:
-#line 935 "grammar.y"
+#line 945 "grammar.y"
{
yyval.declarator = yystack.l_mark[0].declarator;
(void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
@@ -1881,7 +1893,7 @@ case 106:
}
break;
case 108:
-#line 947 "grammar.y"
+#line 957 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
(void)sprintf(buf, "(%s)", yyval.declarator->text);
@@ -1891,7 +1903,7 @@ case 108:
}
break;
case 109:
-#line 955 "grammar.y"
+#line 965 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
(void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
@@ -1900,13 +1912,13 @@ case 109:
}
break;
case 110:
-#line 962 "grammar.y"
+#line 972 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
}
break;
case 111:
-#line 966 "grammar.y"
+#line 976 "grammar.y"
{
yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -1916,7 +1928,7 @@ case 111:
}
break;
case 112:
-#line 974 "grammar.y"
+#line 984 "grammar.y"
{
yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin);
yyval.declarator->func_stack = yystack.l_mark[-2].declarator;
@@ -1925,7 +1937,7 @@ case 112:
}
break;
case 113:
-#line 981 "grammar.y"
+#line 991 "grammar.y"
{
Declarator *d;
@@ -1938,7 +1950,7 @@ case 113:
}
break;
case 114:
-#line 992 "grammar.y"
+#line 1002 "grammar.y"
{
Declarator *d;
@@ -1949,7 +1961,7 @@ case 114:
yyval.declarator->func_def = FUNC_ANSI;
}
break;
-#line 1953 "grammar.tab.c"
+#line 1965 "grammar.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/grammar.y b/test/grammar.y
index 3b0176a..6755522 100644
--- a/test/grammar.y
+++ b/test/grammar.y
@@ -1,10 +1,22 @@
-/* $Id: grammar.y,v 1.3 2010/11/23 01:28:47 tom Exp $
+/* $Id: grammar.y,v 1.5 2012/01/15 20:00:59 tom Exp $
*
* yacc grammar for C function prototype generator
* This was derived from the grammar in Appendix A of
* "The C Programming Language" by Kernighan and Ritchie.
*/
%expect 1
+%{
+#ifdef YYBISON
+#include <stdlib.h>
+#define YYSTYPE_IS_DECLARED
+#define yyerror yaccError
+#endif
+
+#if defined(YYBISON) || !defined(YYBYACC)
+static void yyerror(const char *s);
+#endif
+%}
+
%token <text> '(' '*' '&'
/* identifiers that are not reserved words */
T_IDENTIFIER T_TYPEDEF_NAME T_DEFINE_NAME
@@ -268,8 +280,6 @@ extern boolean file_comments;
extern FuncDefStyle func_style;
extern char base_file[];
-#define YYMAXDEPTH 150
-
extern int yylex (void);
/* declaration specifier attributes for the typedef statement currently being
diff --git a/test/pure_calc.tab.c b/test/pure_calc.tab.c
index db353b5..eb8c189 100644
--- a/test/pure_calc.tab.c
+++ b/test/pure_calc.tab.c
@@ -102,7 +102,16 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
int regs[26];
int base;
-#line 106 "pure_calc.tab.c"
+#ifdef YYBISON
+#define YYSTYPE int
+#define YYLEX_PARAM &yylval
+#define YYLEX_DECL() yylex(YYSTYPE *yylval)
+#define YYERROR_DECL() yyerror(const char *s)
+int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+#line 115 "pure_calc.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -122,7 +131,11 @@ typedef int YYSTYPE;
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
-# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
+# ifdef YYLEX_PARAM_TYPE
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM)
+# else
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM)
+# endif
# define YYLEX yylex(&yylval, YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(YYSTYPE *yylval)
@@ -130,8 +143,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
+#endif
extern int YYPARSE_DECL();
@@ -287,12 +304,11 @@ typedef struct {
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
-#line 63 "pure_calc.y"
+#line 72 "pure_calc.y"
/* start of programs */
#ifdef YYBYACC
-extern int YYLEX_DECL();
-static void YYERROR_DECL();
+static int YYLEX_DECL();
#endif
int
@@ -305,13 +321,13 @@ main (void)
}
static void
-yyerror(const char *s)
+YYERROR_DECL()
{
fprintf(stderr, "%s\n", s);
}
int
-yylex(YYSTYPE *value)
+YYLEX_DECL()
{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
@@ -325,16 +341,16 @@ yylex(YYSTYPE *value)
/* c is now nonblank */
if( islower( c )) {
- *value = c - 'a';
+ *yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
- *value = c - '0';
+ *yylval = c - '0';
return ( DIGIT );
}
return( c );
}
-#line 338 "pure_calc.tab.c"
+#line 354 "pure_calc.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -548,66 +564,66 @@ yyreduce:
switch (yyn)
{
case 3:
-#line 25 "pure_calc.y"
+#line 34 "pure_calc.y"
{ yyerrok ; }
break;
case 4:
-#line 29 "pure_calc.y"
+#line 38 "pure_calc.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
-#line 31 "pure_calc.y"
+#line 40 "pure_calc.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
-#line 35 "pure_calc.y"
+#line 44 "pure_calc.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
-#line 37 "pure_calc.y"
+#line 46 "pure_calc.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
-#line 39 "pure_calc.y"
+#line 48 "pure_calc.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
-#line 41 "pure_calc.y"
+#line 50 "pure_calc.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
-#line 43 "pure_calc.y"
+#line 52 "pure_calc.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
-#line 45 "pure_calc.y"
+#line 54 "pure_calc.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
-#line 47 "pure_calc.y"
+#line 56 "pure_calc.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
-#line 49 "pure_calc.y"
+#line 58 "pure_calc.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
-#line 51 "pure_calc.y"
+#line 60 "pure_calc.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
-#line 53 "pure_calc.y"
+#line 62 "pure_calc.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
-#line 58 "pure_calc.y"
+#line 67 "pure_calc.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
-#line 60 "pure_calc.y"
+#line 69 "pure_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 611 "pure_calc.tab.c"
+#line 627 "pure_calc.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
diff --git a/test/pure_calc.y b/test/pure_calc.y
index 16af107..3cd0433 100644
--- a/test/pure_calc.y
+++ b/test/pure_calc.y
@@ -5,6 +5,15 @@
int regs[26];
int base;
+#ifdef YYBISON
+#define YYSTYPE int
+#define YYLEX_PARAM &yylval
+#define YYLEX_DECL() yylex(YYSTYPE *yylval)
+#define YYERROR_DECL() yyerror(const char *s)
+int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
%}
%start list
@@ -63,8 +72,7 @@ number: DIGIT
%% /* start of programs */
#ifdef YYBYACC
-extern int YYLEX_DECL();
-static void YYERROR_DECL();
+static int YYLEX_DECL();
#endif
int
@@ -77,13 +85,13 @@ main (void)
}
static void
-yyerror(const char *s)
+YYERROR_DECL()
{
fprintf(stderr, "%s\n", s);
}
int
-yylex(YYSTYPE *value)
+YYLEX_DECL()
{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
@@ -97,11 +105,11 @@ yylex(YYSTYPE *value)
/* c is now nonblank */
if( islower( c )) {
- *value = c - 'a';
+ *yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
- *value = c - '0';
+ *yylval = c - '0';
return ( DIGIT );
}
return( c );
diff --git a/test/pure_error.tab.c b/test/pure_error.tab.c
index 1ba1dc4..98de3d8 100644
--- a/test/pure_error.tab.c
+++ b/test/pure_error.tab.c
@@ -95,6 +95,18 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#define YYPURE 1
+#line 2 "pure_error.y"
+
+#ifdef YYBISON
+#define YYSTYPE int
+#define YYLEX_PARAM &yylval
+#define YYLEX_DECL() yylex(YYSTYPE *yylval)
+#define YYERROR_DECL() yyerror(const char *s)
+int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+#line 110 "pure_error.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -114,7 +126,11 @@ typedef int YYSTYPE;
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
-# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
+# ifdef YYLEX_PARAM_TYPE
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM)
+# else
+# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM)
+# endif
# define YYLEX yylex(&yylval, YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(YYSTYPE *yylval)
@@ -122,8 +138,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
+#endif
extern int YYPARSE_DECL();
@@ -195,13 +215,12 @@ typedef struct {
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
-#line 4 "pure_error.y"
+#line 17 "pure_error.y"
#include <stdio.h>
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
int
@@ -222,7 +241,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
-#line 226 "pure_error.tab.c"
+#line 245 "pure_error.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
diff --git a/test/pure_error.y b/test/pure_error.y
index dd9c79e..fe7a3c3 100644
--- a/test/pure_error.y
+++ b/test/pure_error.y
@@ -1,3 +1,16 @@
+%{
+
+#ifdef YYBISON
+#define YYSTYPE int
+#define YYLEX_PARAM &yylval
+#define YYLEX_DECL() yylex(YYSTYPE *yylval)
+#define YYERROR_DECL() yyerror(const char *s)
+int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
+%}
+
%%
S: error
%%
@@ -6,7 +19,6 @@ S: error
#ifdef YYBYACC
extern int YYLEX_DECL();
-static void YYERROR_DECL();
#endif
int
diff --git a/test/quote_calc-s.output b/test/quote_calc-s.output
new file mode 100644
index 0000000..0306652
--- /dev/null
+++ b/test/quote_calc-s.output
@@ -0,0 +1,557 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr OP_ADD expr
+ 8 | expr OP_SUB expr
+ 9 | expr OP_MUL expr
+ 10 | expr OP_DIV expr
+ 11 | expr OP_MOD expr
+ 12 | expr OP_AND expr
+ 13 | expr '|' expr
+ 14 | OP_SUB expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ expr : OP_SUB . expr (14)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 12
+ number goto 9
+
+
+state 4
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 5
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 13
+ OP_ADD reduce 15
+ OP_SUB reduce 15
+ OP_MUL reduce 15
+ OP_DIV reduce 15
+ OP_MOD reduce 15
+ OP_AND reduce 15
+ '|' reduce 15
+ '\n' reduce 15
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ OP_ADD reduce 16
+ OP_SUB reduce 16
+ OP_MUL reduce 16
+ OP_DIV reduce 16
+ OP_MOD reduce 16
+ OP_AND reduce 16
+ '|' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD
+12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB
+12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL
+12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV
+12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD
+12: shift/reduce conflict (shift 21, reduce 14) on OP_AND
+state 12
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+ expr : OP_SUB expr . (14)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' reduce 14
+ '\n' reduce 14
+ ')' reduce 14
+
+
+state 13
+ stat : LETTER '=' . expr (5)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr OP_ADD . expr (7)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr OP_SUB . expr (8)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr OP_MUL . expr (9)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr OP_DIV . expr (10)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr OP_MOD . expr (11)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr OP_AND . expr (12)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '|' . expr (13)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD
+26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB
+26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL
+26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV
+26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD
+26: shift/reduce conflict (shift 21, reduce 7) on OP_AND
+26: shift/reduce conflict (shift 22, reduce 7) on '|'
+state 26
+ expr : expr . OP_ADD expr (7)
+ expr : expr OP_ADD expr . (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 7
+ ')' reduce 7
+
+
+27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD
+27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB
+27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL
+27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV
+27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD
+27: shift/reduce conflict (shift 21, reduce 8) on OP_AND
+27: shift/reduce conflict (shift 22, reduce 8) on '|'
+state 27
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr OP_SUB expr . (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 8
+ ')' reduce 8
+
+
+28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD
+28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB
+28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL
+28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV
+28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD
+28: shift/reduce conflict (shift 21, reduce 9) on OP_AND
+28: shift/reduce conflict (shift 22, reduce 9) on '|'
+state 28
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr OP_MUL expr . (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 9
+ ')' reduce 9
+
+
+29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD
+29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB
+29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL
+29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV
+29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD
+29: shift/reduce conflict (shift 21, reduce 10) on OP_AND
+29: shift/reduce conflict (shift 22, reduce 10) on '|'
+state 29
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr OP_DIV expr . (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 10
+ ')' reduce 10
+
+
+30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD
+30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB
+30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL
+30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV
+30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD
+30: shift/reduce conflict (shift 21, reduce 11) on OP_AND
+30: shift/reduce conflict (shift 22, reduce 11) on '|'
+state 30
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr OP_MOD expr . (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 11
+ ')' reduce 11
+
+
+31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD
+31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB
+31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL
+31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV
+31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD
+31: shift/reduce conflict (shift 21, reduce 12) on OP_AND
+31: shift/reduce conflict (shift 22, reduce 12) on '|'
+state 31
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr OP_AND expr . (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 12
+ ')' reduce 12
+
+
+32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD
+32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB
+32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL
+32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV
+32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD
+32: shift/reduce conflict (shift 21, reduce 13) on OP_AND
+state 32
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+State 12 contains 6 shift/reduce conflicts.
+State 26 contains 7 shift/reduce conflicts.
+State 27 contains 7 shift/reduce conflicts.
+State 28 contains 7 shift/reduce conflicts.
+State 29 contains 7 shift/reduce conflicts.
+State 30 contains 7 shift/reduce conflicts.
+State 31 contains 7 shift/reduce conflicts.
+State 32 contains 6 shift/reduce conflicts.
+
+
+28 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/quote_calc-s.tab.c b/test/quote_calc-s.tab.c
new file mode 100644
index 0000000..15346fd
--- /dev/null
+++ b/test/quote_calc-s.tab.c
@@ -0,0 +1,687 @@
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse quote_calc_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex quote_calc_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror quote_calc_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar quote_calc_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval quote_calc_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval quote_calc_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug quote_calc_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs quote_calc_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag quote_calc_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs quote_calc_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen quote_calc_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred quote_calc_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto quote_calc_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex quote_calc_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex quote_calc_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex quote_calc_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable quote_calc_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck quote_calc_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname quote_calc_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule quote_calc_rule
+#endif /* yyrule */
+#define YYPREFIX "quote_calc_"
+
+#define YYPURE 0
+
+#line 2 "quote_calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+#line 109 "quote_calc-s.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
+#define YYERRCODE 256
+static const short quote_calc_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short quote_calc_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short quote_calc_defred[] = { 1,
+ 0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
+ 15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
+ 0, 0,
+};
+static const short quote_calc_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short quote_calc_sindex[] = { 0,
+ -38, 5, -36, 0, -51, -36, 7, -121, -248, 0,
+ 0, -243, -36, -22, 0, -36, -36, -36, -36, -36,
+ -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
+ -121, -243,
+};
+static const short quote_calc_rindex[] = { 0,
+ 0, 0, 0, 0, -9, 0, 0, 13, -10, 0,
+ 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 15, 0, -3, -2, -1, 1, 2,
+ 3, -4,
+};
+static const short quote_calc_gindex[] = { 0,
+ 0, 42, 0,
+};
+#define YYTABLESIZE 258
+static const short quote_calc_table[] = { 16,
+ 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
+ 10, 11, 12, 16, 10, 17, 15, 18, 25, 19,
+ 23, 20, 4, 21, 5, 0, 0, 0, 0, 0,
+ 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
+ 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
+ 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
+ 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 16, 0, 17, 0, 18,
+ 0, 19, 0, 20, 0, 21, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
+ 3, 0, 3, 0, 0, 0, 0, 0, 0, 0,
+ 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
+ 19, 0, 20, 0, 21, 0, 16, 15, 16, 15,
+ 16, 15, 16, 15, 16, 15, 16, 15,
+};
+static const short quote_calc_check[] = { 10,
+ 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
+ 10, 10, 10, 257, 10, 259, 10, 261, 41, 263,
+ 269, 265, 10, 267, 10, -1, -1, -1, -1, -1,
+ 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
+ -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
+ -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
+ 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 124, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 257, -1, 259, -1, 261,
+ -1, 263, -1, 265, -1, 267, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
+ 259, -1, 259, -1, -1, -1, -1, -1, -1, -1,
+ 269, 270, 269, 270, 257, -1, 259, -1, 261, -1,
+ 263, -1, 265, -1, 267, -1, 257, 257, 259, 259,
+ 261, 261, 263, 263, 265, 265, 267, 267,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 271
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
+"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr OP_ADD expr",
+"expr : expr OP_SUB expr",
+"expr : expr OP_MUL expr",
+"expr : expr OP_DIV expr",
+"expr : expr OP_MOD expr",
+"expr : expr OP_AND expr",
+"expr : expr '|' expr",
+"expr : OP_SUB expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 73 "quote_calc.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 361 "quote_calc-s.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 35 "quote_calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 39 "quote_calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 41 "quote_calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 45 "quote_calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 47 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 49 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 51 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 53 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 55 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 57 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 59 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 61 "quote_calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 63 "quote_calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 68 "quote_calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 70 "quote_calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 627 "quote_calc-s.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/quote_calc-s.tab.h b/test/quote_calc-s.tab.h
new file mode 100644
index 0000000..1a46579
--- /dev/null
+++ b/test/quote_calc-s.tab.h
@@ -0,0 +1,9 @@
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
diff --git a/test/quote_calc.output b/test/quote_calc.output
new file mode 100644
index 0000000..0306652
--- /dev/null
+++ b/test/quote_calc.output
@@ -0,0 +1,557 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr OP_ADD expr
+ 8 | expr OP_SUB expr
+ 9 | expr OP_MUL expr
+ 10 | expr OP_DIV expr
+ 11 | expr OP_MOD expr
+ 12 | expr OP_AND expr
+ 13 | expr '|' expr
+ 14 | OP_SUB expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ expr : OP_SUB . expr (14)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 12
+ number goto 9
+
+
+state 4
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 5
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 13
+ OP_ADD reduce 15
+ OP_SUB reduce 15
+ OP_MUL reduce 15
+ OP_DIV reduce 15
+ OP_MOD reduce 15
+ OP_AND reduce 15
+ '|' reduce 15
+ '\n' reduce 15
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ OP_ADD reduce 16
+ OP_SUB reduce 16
+ OP_MUL reduce 16
+ OP_DIV reduce 16
+ OP_MOD reduce 16
+ OP_AND reduce 16
+ '|' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD
+12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB
+12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL
+12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV
+12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD
+12: shift/reduce conflict (shift 21, reduce 14) on OP_AND
+state 12
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+ expr : OP_SUB expr . (14)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' reduce 14
+ '\n' reduce 14
+ ')' reduce 14
+
+
+state 13
+ stat : LETTER '=' . expr (5)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr OP_ADD . expr (7)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr OP_SUB . expr (8)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr OP_MUL . expr (9)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr OP_DIV . expr (10)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr OP_MOD . expr (11)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr OP_AND . expr (12)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '|' . expr (13)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD
+26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB
+26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL
+26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV
+26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD
+26: shift/reduce conflict (shift 21, reduce 7) on OP_AND
+26: shift/reduce conflict (shift 22, reduce 7) on '|'
+state 26
+ expr : expr . OP_ADD expr (7)
+ expr : expr OP_ADD expr . (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 7
+ ')' reduce 7
+
+
+27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD
+27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB
+27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL
+27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV
+27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD
+27: shift/reduce conflict (shift 21, reduce 8) on OP_AND
+27: shift/reduce conflict (shift 22, reduce 8) on '|'
+state 27
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr OP_SUB expr . (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 8
+ ')' reduce 8
+
+
+28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD
+28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB
+28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL
+28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV
+28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD
+28: shift/reduce conflict (shift 21, reduce 9) on OP_AND
+28: shift/reduce conflict (shift 22, reduce 9) on '|'
+state 28
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr OP_MUL expr . (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 9
+ ')' reduce 9
+
+
+29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD
+29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB
+29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL
+29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV
+29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD
+29: shift/reduce conflict (shift 21, reduce 10) on OP_AND
+29: shift/reduce conflict (shift 22, reduce 10) on '|'
+state 29
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr OP_DIV expr . (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 10
+ ')' reduce 10
+
+
+30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD
+30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB
+30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL
+30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV
+30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD
+30: shift/reduce conflict (shift 21, reduce 11) on OP_AND
+30: shift/reduce conflict (shift 22, reduce 11) on '|'
+state 30
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr OP_MOD expr . (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 11
+ ')' reduce 11
+
+
+31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD
+31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB
+31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL
+31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV
+31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD
+31: shift/reduce conflict (shift 21, reduce 12) on OP_AND
+31: shift/reduce conflict (shift 22, reduce 12) on '|'
+state 31
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr OP_AND expr . (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 12
+ ')' reduce 12
+
+
+32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD
+32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB
+32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL
+32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV
+32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD
+32: shift/reduce conflict (shift 21, reduce 13) on OP_AND
+state 32
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+State 12 contains 6 shift/reduce conflicts.
+State 26 contains 7 shift/reduce conflicts.
+State 27 contains 7 shift/reduce conflicts.
+State 28 contains 7 shift/reduce conflicts.
+State 29 contains 7 shift/reduce conflicts.
+State 30 contains 7 shift/reduce conflicts.
+State 31 contains 7 shift/reduce conflicts.
+State 32 contains 6 shift/reduce conflicts.
+
+
+28 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/quote_calc.tab.c b/test/quote_calc.tab.c
new file mode 100644
index 0000000..9a45472
--- /dev/null
+++ b/test/quote_calc.tab.c
@@ -0,0 +1,693 @@
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse quote_calc_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex quote_calc_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror quote_calc_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar quote_calc_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval quote_calc_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval quote_calc_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug quote_calc_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs quote_calc_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag quote_calc_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs quote_calc_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen quote_calc_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred quote_calc_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto quote_calc_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex quote_calc_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex quote_calc_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex quote_calc_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable quote_calc_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck quote_calc_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname quote_calc_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule quote_calc_rule
+#endif /* yyrule */
+#define YYPREFIX "quote_calc_"
+
+#define YYPURE 0
+
+#line 2 "quote_calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+#line 109 "quote_calc.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define OP_ADD 257
+#define ADD 258
+#define OP_SUB 259
+#define SUB 260
+#define OP_MUL 261
+#define MUL 262
+#define OP_DIV 263
+#define DIV 264
+#define OP_MOD 265
+#define MOD 266
+#define OP_AND 267
+#define AND 268
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
+#define YYERRCODE 256
+static const short quote_calc_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short quote_calc_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short quote_calc_defred[] = { 1,
+ 0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
+ 15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
+ 0, 0,
+};
+static const short quote_calc_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short quote_calc_sindex[] = { 0,
+ -38, 5, -36, 0, -51, -36, 7, -121, -248, 0,
+ 0, -243, -36, -22, 0, -36, -36, -36, -36, -36,
+ -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
+ -121, -243,
+};
+static const short quote_calc_rindex[] = { 0,
+ 0, 0, 0, 0, -9, 0, 0, 13, -10, 0,
+ 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 15, 0, -3, -2, -1, 1, 2,
+ 3, -4,
+};
+static const short quote_calc_gindex[] = { 0,
+ 0, 42, 0,
+};
+#define YYTABLESIZE 258
+static const short quote_calc_table[] = { 16,
+ 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
+ 10, 11, 12, 16, 10, 17, 15, 18, 25, 19,
+ 23, 20, 4, 21, 5, 0, 0, 0, 0, 0,
+ 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
+ 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
+ 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
+ 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 16, 0, 17, 0, 18,
+ 0, 19, 0, 20, 0, 21, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
+ 3, 0, 3, 0, 0, 0, 0, 0, 0, 0,
+ 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
+ 19, 0, 20, 0, 21, 0, 16, 15, 16, 15,
+ 16, 15, 16, 15, 16, 15, 16, 15,
+};
+static const short quote_calc_check[] = { 10,
+ 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
+ 10, 10, 10, 257, 10, 259, 10, 261, 41, 263,
+ 269, 265, 10, 267, 10, -1, -1, -1, -1, -1,
+ 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
+ -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
+ -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
+ 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 124, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 257, -1, 259, -1, 261,
+ -1, 263, -1, 265, -1, 267, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
+ 259, -1, 259, -1, -1, -1, -1, -1, -1, -1,
+ 269, 270, 269, 270, 257, -1, 259, -1, 261, -1,
+ 263, -1, 265, -1, 267, -1, 257, 257, 259, 259,
+ 261, 261, 263, 263, 265, 265, 267, 267,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 271
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
+"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr OP_ADD expr",
+"expr : expr OP_SUB expr",
+"expr : expr OP_MUL expr",
+"expr : expr OP_DIV expr",
+"expr : expr OP_MOD expr",
+"expr : expr OP_AND expr",
+"expr : expr '|' expr",
+"expr : OP_SUB expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 73 "quote_calc.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 367 "quote_calc.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 35 "quote_calc.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 39 "quote_calc.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 41 "quote_calc.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 45 "quote_calc.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 47 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 49 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 51 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 53 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 55 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 57 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 59 "quote_calc.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 61 "quote_calc.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 63 "quote_calc.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 68 "quote_calc.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 70 "quote_calc.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 633 "quote_calc.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/quote_calc.tab.h b/test/quote_calc.tab.h
new file mode 100644
index 0000000..498eff2
--- /dev/null
+++ b/test/quote_calc.tab.h
@@ -0,0 +1,15 @@
+#define OP_ADD 257
+#define ADD 258
+#define OP_SUB 259
+#define SUB 260
+#define OP_MUL 261
+#define MUL 262
+#define OP_DIV 263
+#define DIV 264
+#define OP_MOD 265
+#define MOD 266
+#define OP_AND 267
+#define AND 268
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
diff --git a/test/quote_calc.y b/test/quote_calc.y
new file mode 100644
index 0000000..9304dd8
--- /dev/null
+++ b/test/quote_calc.y
@@ -0,0 +1,112 @@
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+%}
+
+%start list
+
+%token OP_ADD "ADD"
+%token OP_SUB "SUB"
+%token OP_MUL "MUL"
+%token OP_DIV "DIV"
+%token OP_MOD "MOD"
+%token OP_AND "AND"
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr OP_ADD expr
+ { $$ = $1 + $3; }
+ | expr OP_SUB expr
+ { $$ = $1 - $3; }
+ | expr OP_MUL expr
+ { $$ = $1 * $3; }
+ | expr OP_DIV expr
+ { $$ = $1 / $3; }
+ | expr OP_MOD expr
+ { $$ = $1 % $3; }
+ | expr OP_AND expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | OP_SUB expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
diff --git a/test/quote_calc2-s.output b/test/quote_calc2-s.output
new file mode 100644
index 0000000..ed28ae2
--- /dev/null
+++ b/test/quote_calc2-s.output
@@ -0,0 +1,557 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr "ADD" expr
+ 8 | expr "SUB" expr
+ 9 | expr "MUL" expr
+ 10 | expr "DIV" expr
+ 11 | expr "MOD" expr
+ 12 | expr "AND" expr
+ 13 | expr '|' expr
+ 14 | "SUB" expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ expr : "SUB" . expr (14)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 12
+ number goto 9
+
+
+state 4
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 5
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 13
+ "ADD" reduce 15
+ "SUB" reduce 15
+ "MUL" reduce 15
+ "DIV" reduce 15
+ "MOD" reduce 15
+ "AND" reduce 15
+ '|' reduce 15
+ '\n' reduce 15
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ "ADD" reduce 16
+ "SUB" reduce 16
+ "MUL" reduce 16
+ "DIV" reduce 16
+ "MOD" reduce 16
+ "AND" reduce 16
+ '|' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+12: shift/reduce conflict (shift 16, reduce 14) on "ADD"
+12: shift/reduce conflict (shift 17, reduce 14) on "SUB"
+12: shift/reduce conflict (shift 18, reduce 14) on "MUL"
+12: shift/reduce conflict (shift 19, reduce 14) on "DIV"
+12: shift/reduce conflict (shift 20, reduce 14) on "MOD"
+12: shift/reduce conflict (shift 21, reduce 14) on "AND"
+state 12
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+ expr : "SUB" expr . (14)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' reduce 14
+ '\n' reduce 14
+ ')' reduce 14
+
+
+state 13
+ stat : LETTER '=' . expr (5)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr "ADD" . expr (7)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr "SUB" . expr (8)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr "MUL" . expr (9)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr "DIV" . expr (10)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr "MOD" . expr (11)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr "AND" . expr (12)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '|' . expr (13)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+26: shift/reduce conflict (shift 16, reduce 7) on "ADD"
+26: shift/reduce conflict (shift 17, reduce 7) on "SUB"
+26: shift/reduce conflict (shift 18, reduce 7) on "MUL"
+26: shift/reduce conflict (shift 19, reduce 7) on "DIV"
+26: shift/reduce conflict (shift 20, reduce 7) on "MOD"
+26: shift/reduce conflict (shift 21, reduce 7) on "AND"
+26: shift/reduce conflict (shift 22, reduce 7) on '|'
+state 26
+ expr : expr . "ADD" expr (7)
+ expr : expr "ADD" expr . (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 7
+ ')' reduce 7
+
+
+27: shift/reduce conflict (shift 16, reduce 8) on "ADD"
+27: shift/reduce conflict (shift 17, reduce 8) on "SUB"
+27: shift/reduce conflict (shift 18, reduce 8) on "MUL"
+27: shift/reduce conflict (shift 19, reduce 8) on "DIV"
+27: shift/reduce conflict (shift 20, reduce 8) on "MOD"
+27: shift/reduce conflict (shift 21, reduce 8) on "AND"
+27: shift/reduce conflict (shift 22, reduce 8) on '|'
+state 27
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr "SUB" expr . (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 8
+ ')' reduce 8
+
+
+28: shift/reduce conflict (shift 16, reduce 9) on "ADD"
+28: shift/reduce conflict (shift 17, reduce 9) on "SUB"
+28: shift/reduce conflict (shift 18, reduce 9) on "MUL"
+28: shift/reduce conflict (shift 19, reduce 9) on "DIV"
+28: shift/reduce conflict (shift 20, reduce 9) on "MOD"
+28: shift/reduce conflict (shift 21, reduce 9) on "AND"
+28: shift/reduce conflict (shift 22, reduce 9) on '|'
+state 28
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr "MUL" expr . (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 9
+ ')' reduce 9
+
+
+29: shift/reduce conflict (shift 16, reduce 10) on "ADD"
+29: shift/reduce conflict (shift 17, reduce 10) on "SUB"
+29: shift/reduce conflict (shift 18, reduce 10) on "MUL"
+29: shift/reduce conflict (shift 19, reduce 10) on "DIV"
+29: shift/reduce conflict (shift 20, reduce 10) on "MOD"
+29: shift/reduce conflict (shift 21, reduce 10) on "AND"
+29: shift/reduce conflict (shift 22, reduce 10) on '|'
+state 29
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr "DIV" expr . (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 10
+ ')' reduce 10
+
+
+30: shift/reduce conflict (shift 16, reduce 11) on "ADD"
+30: shift/reduce conflict (shift 17, reduce 11) on "SUB"
+30: shift/reduce conflict (shift 18, reduce 11) on "MUL"
+30: shift/reduce conflict (shift 19, reduce 11) on "DIV"
+30: shift/reduce conflict (shift 20, reduce 11) on "MOD"
+30: shift/reduce conflict (shift 21, reduce 11) on "AND"
+30: shift/reduce conflict (shift 22, reduce 11) on '|'
+state 30
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr "MOD" expr . (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 11
+ ')' reduce 11
+
+
+31: shift/reduce conflict (shift 16, reduce 12) on "ADD"
+31: shift/reduce conflict (shift 17, reduce 12) on "SUB"
+31: shift/reduce conflict (shift 18, reduce 12) on "MUL"
+31: shift/reduce conflict (shift 19, reduce 12) on "DIV"
+31: shift/reduce conflict (shift 20, reduce 12) on "MOD"
+31: shift/reduce conflict (shift 21, reduce 12) on "AND"
+31: shift/reduce conflict (shift 22, reduce 12) on '|'
+state 31
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr "AND" expr . (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 12
+ ')' reduce 12
+
+
+32: shift/reduce conflict (shift 16, reduce 13) on "ADD"
+32: shift/reduce conflict (shift 17, reduce 13) on "SUB"
+32: shift/reduce conflict (shift 18, reduce 13) on "MUL"
+32: shift/reduce conflict (shift 19, reduce 13) on "DIV"
+32: shift/reduce conflict (shift 20, reduce 13) on "MOD"
+32: shift/reduce conflict (shift 21, reduce 13) on "AND"
+state 32
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+State 12 contains 6 shift/reduce conflicts.
+State 26 contains 7 shift/reduce conflicts.
+State 27 contains 7 shift/reduce conflicts.
+State 28 contains 7 shift/reduce conflicts.
+State 29 contains 7 shift/reduce conflicts.
+State 30 contains 7 shift/reduce conflicts.
+State 31 contains 7 shift/reduce conflicts.
+State 32 contains 6 shift/reduce conflicts.
+
+
+28 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/quote_calc2-s.tab.c b/test/quote_calc2-s.tab.c
new file mode 100644
index 0000000..06c574b
--- /dev/null
+++ b/test/quote_calc2-s.tab.c
@@ -0,0 +1,687 @@
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse quote_calc2_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex quote_calc2_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror quote_calc2_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar quote_calc2_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval quote_calc2_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval quote_calc2_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug quote_calc2_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs quote_calc2_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag quote_calc2_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs quote_calc2_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen quote_calc2_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred quote_calc2_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto quote_calc2_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex quote_calc2_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex quote_calc2_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex quote_calc2_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable quote_calc2_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck quote_calc2_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname quote_calc2_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule quote_calc2_rule
+#endif /* yyrule */
+#define YYPREFIX "quote_calc2_"
+
+#define YYPURE 0
+
+#line 2 "quote_calc2.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+#line 109 "quote_calc2-s.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
+#define YYERRCODE 256
+static const short quote_calc2_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short quote_calc2_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short quote_calc2_defred[] = { 1,
+ 0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
+ 15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
+ 0, 0,
+};
+static const short quote_calc2_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short quote_calc2_sindex[] = { 0,
+ -38, 4, -36, 0, -51, -36, 6, -121, -249, 0,
+ 0, -243, -36, -23, 0, -36, -36, -36, -36, -36,
+ -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
+ -121, -243,
+};
+static const short quote_calc2_rindex[] = { 0,
+ 0, 0, 0, 0, -9, 0, 0, 12, -10, 0,
+ 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 14, 0, -3, -2, -1, 1, 2,
+ 3, -4,
+};
+static const short quote_calc2_gindex[] = { 0,
+ 0, 42, 0,
+};
+#define YYTABLESIZE 259
+static const short quote_calc2_table[] = { 16,
+ 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
+ 10, 11, 12, 10, 16, 15, 17, 25, 18, 23,
+ 19, 4, 20, 5, 21, 0, 0, 0, 0, 0,
+ 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
+ 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
+ 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
+ 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 22, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 16, 0, 17, 0,
+ 18, 0, 19, 0, 20, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
+ 0, 3, 0, 3, 0, 0, 0, 0, 0, 0,
+ 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
+ 19, 0, 20, 0, 21, 0, 0, 16, 15, 16,
+ 15, 16, 15, 16, 15, 16, 15, 16, 15,
+};
+static const short quote_calc2_check[] = { 10,
+ 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
+ 10, 10, 10, 10, 258, 10, 260, 41, 262, 269,
+ 264, 10, 266, 10, 268, -1, -1, -1, -1, -1,
+ 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
+ -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
+ -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
+ 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 258, -1, 260, -1,
+ 262, -1, 264, -1, 266, -1, 268, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
+ -1, 260, -1, 260, -1, -1, -1, -1, -1, -1,
+ 269, 270, 269, 270, 258, -1, 260, -1, 262, -1,
+ 264, -1, 266, -1, 268, -1, -1, 258, 258, 260,
+ 260, 262, 262, 264, 264, 266, 266, 268, 268,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 271
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
+"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr \"ADD\" expr",
+"expr : expr \"SUB\" expr",
+"expr : expr \"MUL\" expr",
+"expr : expr \"DIV\" expr",
+"expr : expr \"MOD\" expr",
+"expr : expr \"AND\" expr",
+"expr : expr '|' expr",
+"expr : \"SUB\" expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 73 "quote_calc2.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 361 "quote_calc2-s.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 35 "quote_calc2.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 39 "quote_calc2.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 41 "quote_calc2.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 45 "quote_calc2.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 47 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 49 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 51 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 53 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 55 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 57 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 59 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 61 "quote_calc2.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 63 "quote_calc2.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 68 "quote_calc2.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 70 "quote_calc2.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 627 "quote_calc2-s.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/quote_calc2-s.tab.h b/test/quote_calc2-s.tab.h
new file mode 100644
index 0000000..1a46579
--- /dev/null
+++ b/test/quote_calc2-s.tab.h
@@ -0,0 +1,9 @@
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
diff --git a/test/quote_calc2.output b/test/quote_calc2.output
new file mode 100644
index 0000000..ed28ae2
--- /dev/null
+++ b/test/quote_calc2.output
@@ -0,0 +1,557 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr "ADD" expr
+ 8 | expr "SUB" expr
+ 9 | expr "MUL" expr
+ 10 | expr "DIV" expr
+ 11 | expr "MOD" expr
+ 12 | expr "AND" expr
+ 13 | expr '|' expr
+ 14 | "SUB" expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ expr : "SUB" . expr (14)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 12
+ number goto 9
+
+
+state 4
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 5
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 13
+ "ADD" reduce 15
+ "SUB" reduce 15
+ "MUL" reduce 15
+ "DIV" reduce 15
+ "MOD" reduce 15
+ "AND" reduce 15
+ '|' reduce 15
+ '\n' reduce 15
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ "ADD" reduce 16
+ "SUB" reduce 16
+ "MUL" reduce 16
+ "DIV" reduce 16
+ "MOD" reduce 16
+ "AND" reduce 16
+ '|' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+12: shift/reduce conflict (shift 16, reduce 14) on "ADD"
+12: shift/reduce conflict (shift 17, reduce 14) on "SUB"
+12: shift/reduce conflict (shift 18, reduce 14) on "MUL"
+12: shift/reduce conflict (shift 19, reduce 14) on "DIV"
+12: shift/reduce conflict (shift 20, reduce 14) on "MOD"
+12: shift/reduce conflict (shift 21, reduce 14) on "AND"
+state 12
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+ expr : "SUB" expr . (14)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' reduce 14
+ '\n' reduce 14
+ ')' reduce 14
+
+
+state 13
+ stat : LETTER '=' . expr (5)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr "ADD" . expr (7)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr "SUB" . expr (8)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr "MUL" . expr (9)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr "DIV" . expr (10)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr "MOD" . expr (11)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr "AND" . expr (12)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '|' . expr (13)
+
+ "SUB" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+26: shift/reduce conflict (shift 16, reduce 7) on "ADD"
+26: shift/reduce conflict (shift 17, reduce 7) on "SUB"
+26: shift/reduce conflict (shift 18, reduce 7) on "MUL"
+26: shift/reduce conflict (shift 19, reduce 7) on "DIV"
+26: shift/reduce conflict (shift 20, reduce 7) on "MOD"
+26: shift/reduce conflict (shift 21, reduce 7) on "AND"
+26: shift/reduce conflict (shift 22, reduce 7) on '|'
+state 26
+ expr : expr . "ADD" expr (7)
+ expr : expr "ADD" expr . (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 7
+ ')' reduce 7
+
+
+27: shift/reduce conflict (shift 16, reduce 8) on "ADD"
+27: shift/reduce conflict (shift 17, reduce 8) on "SUB"
+27: shift/reduce conflict (shift 18, reduce 8) on "MUL"
+27: shift/reduce conflict (shift 19, reduce 8) on "DIV"
+27: shift/reduce conflict (shift 20, reduce 8) on "MOD"
+27: shift/reduce conflict (shift 21, reduce 8) on "AND"
+27: shift/reduce conflict (shift 22, reduce 8) on '|'
+state 27
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr "SUB" expr . (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 8
+ ')' reduce 8
+
+
+28: shift/reduce conflict (shift 16, reduce 9) on "ADD"
+28: shift/reduce conflict (shift 17, reduce 9) on "SUB"
+28: shift/reduce conflict (shift 18, reduce 9) on "MUL"
+28: shift/reduce conflict (shift 19, reduce 9) on "DIV"
+28: shift/reduce conflict (shift 20, reduce 9) on "MOD"
+28: shift/reduce conflict (shift 21, reduce 9) on "AND"
+28: shift/reduce conflict (shift 22, reduce 9) on '|'
+state 28
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr "MUL" expr . (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 9
+ ')' reduce 9
+
+
+29: shift/reduce conflict (shift 16, reduce 10) on "ADD"
+29: shift/reduce conflict (shift 17, reduce 10) on "SUB"
+29: shift/reduce conflict (shift 18, reduce 10) on "MUL"
+29: shift/reduce conflict (shift 19, reduce 10) on "DIV"
+29: shift/reduce conflict (shift 20, reduce 10) on "MOD"
+29: shift/reduce conflict (shift 21, reduce 10) on "AND"
+29: shift/reduce conflict (shift 22, reduce 10) on '|'
+state 29
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr "DIV" expr . (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 10
+ ')' reduce 10
+
+
+30: shift/reduce conflict (shift 16, reduce 11) on "ADD"
+30: shift/reduce conflict (shift 17, reduce 11) on "SUB"
+30: shift/reduce conflict (shift 18, reduce 11) on "MUL"
+30: shift/reduce conflict (shift 19, reduce 11) on "DIV"
+30: shift/reduce conflict (shift 20, reduce 11) on "MOD"
+30: shift/reduce conflict (shift 21, reduce 11) on "AND"
+30: shift/reduce conflict (shift 22, reduce 11) on '|'
+state 30
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr "MOD" expr . (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 11
+ ')' reduce 11
+
+
+31: shift/reduce conflict (shift 16, reduce 12) on "ADD"
+31: shift/reduce conflict (shift 17, reduce 12) on "SUB"
+31: shift/reduce conflict (shift 18, reduce 12) on "MUL"
+31: shift/reduce conflict (shift 19, reduce 12) on "DIV"
+31: shift/reduce conflict (shift 20, reduce 12) on "MOD"
+31: shift/reduce conflict (shift 21, reduce 12) on "AND"
+31: shift/reduce conflict (shift 22, reduce 12) on '|'
+state 31
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr "AND" expr . (12)
+ expr : expr . '|' expr (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' shift 22
+ '\n' reduce 12
+ ')' reduce 12
+
+
+32: shift/reduce conflict (shift 16, reduce 13) on "ADD"
+32: shift/reduce conflict (shift 17, reduce 13) on "SUB"
+32: shift/reduce conflict (shift 18, reduce 13) on "MUL"
+32: shift/reduce conflict (shift 19, reduce 13) on "DIV"
+32: shift/reduce conflict (shift 20, reduce 13) on "MOD"
+32: shift/reduce conflict (shift 21, reduce 13) on "AND"
+state 32
+ expr : expr . "ADD" expr (7)
+ expr : expr . "SUB" expr (8)
+ expr : expr . "MUL" expr (9)
+ expr : expr . "DIV" expr (10)
+ expr : expr . "MOD" expr (11)
+ expr : expr . "AND" expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ "ADD" shift 16
+ "SUB" shift 17
+ "MUL" shift 18
+ "DIV" shift 19
+ "MOD" shift 20
+ "AND" shift 21
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+State 12 contains 6 shift/reduce conflicts.
+State 26 contains 7 shift/reduce conflicts.
+State 27 contains 7 shift/reduce conflicts.
+State 28 contains 7 shift/reduce conflicts.
+State 29 contains 7 shift/reduce conflicts.
+State 30 contains 7 shift/reduce conflicts.
+State 31 contains 7 shift/reduce conflicts.
+State 32 contains 6 shift/reduce conflicts.
+
+
+28 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/quote_calc2.tab.c b/test/quote_calc2.tab.c
new file mode 100644
index 0000000..958a736
--- /dev/null
+++ b/test/quote_calc2.tab.c
@@ -0,0 +1,693 @@
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse quote_calc2_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex quote_calc2_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror quote_calc2_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar quote_calc2_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval quote_calc2_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval quote_calc2_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug quote_calc2_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs quote_calc2_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag quote_calc2_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs quote_calc2_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen quote_calc2_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred quote_calc2_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto quote_calc2_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex quote_calc2_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex quote_calc2_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex quote_calc2_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable quote_calc2_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck quote_calc2_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname quote_calc2_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule quote_calc2_rule
+#endif /* yyrule */
+#define YYPREFIX "quote_calc2_"
+
+#define YYPURE 0
+
+#line 2 "quote_calc2.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+#line 109 "quote_calc2.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define OP_ADD 257
+#define ADD 258
+#define OP_SUB 259
+#define SUB 260
+#define OP_MUL 261
+#define MUL 262
+#define OP_DIV 263
+#define DIV 264
+#define OP_MOD 265
+#define MOD 266
+#define OP_AND 267
+#define AND 268
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
+#define YYERRCODE 256
+static const short quote_calc2_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short quote_calc2_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short quote_calc2_defred[] = { 1,
+ 0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
+ 15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
+ 0, 0,
+};
+static const short quote_calc2_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short quote_calc2_sindex[] = { 0,
+ -38, 4, -36, 0, -51, -36, 6, -121, -249, 0,
+ 0, -243, -36, -23, 0, -36, -36, -36, -36, -36,
+ -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
+ -121, -243,
+};
+static const short quote_calc2_rindex[] = { 0,
+ 0, 0, 0, 0, -9, 0, 0, 12, -10, 0,
+ 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 14, 0, -3, -2, -1, 1, 2,
+ 3, -4,
+};
+static const short quote_calc2_gindex[] = { 0,
+ 0, 42, 0,
+};
+#define YYTABLESIZE 259
+static const short quote_calc2_table[] = { 16,
+ 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
+ 10, 11, 12, 10, 16, 15, 17, 25, 18, 23,
+ 19, 4, 20, 5, 21, 0, 0, 0, 0, 0,
+ 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
+ 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
+ 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
+ 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 22, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 16, 0, 17, 0,
+ 18, 0, 19, 0, 20, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
+ 0, 3, 0, 3, 0, 0, 0, 0, 0, 0,
+ 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
+ 19, 0, 20, 0, 21, 0, 0, 16, 15, 16,
+ 15, 16, 15, 16, 15, 16, 15, 16, 15,
+};
+static const short quote_calc2_check[] = { 10,
+ 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
+ 10, 10, 10, 10, 258, 10, 260, 41, 262, 269,
+ 264, 10, 266, 10, 268, -1, -1, -1, -1, -1,
+ 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
+ -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
+ -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
+ 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 258, -1, 260, -1,
+ 262, -1, 264, -1, 266, -1, 268, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
+ -1, 260, -1, 260, -1, -1, -1, -1, -1, -1,
+ 269, 270, 269, 270, 258, -1, 260, -1, 262, -1,
+ 264, -1, 266, -1, 268, -1, -1, 258, 258, 260,
+ 260, 262, 262, 264, 264, 266, 266, 268, 268,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 271
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
+"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr \"ADD\" expr",
+"expr : expr \"SUB\" expr",
+"expr : expr \"MUL\" expr",
+"expr : expr \"DIV\" expr",
+"expr : expr \"MOD\" expr",
+"expr : expr \"AND\" expr",
+"expr : expr '|' expr",
+"expr : \"SUB\" expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 73 "quote_calc2.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 367 "quote_calc2.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 35 "quote_calc2.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 39 "quote_calc2.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 41 "quote_calc2.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 45 "quote_calc2.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 47 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 49 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 51 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 53 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 55 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 57 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 59 "quote_calc2.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 61 "quote_calc2.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 63 "quote_calc2.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 68 "quote_calc2.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 70 "quote_calc2.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 633 "quote_calc2.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/quote_calc2.tab.h b/test/quote_calc2.tab.h
new file mode 100644
index 0000000..498eff2
--- /dev/null
+++ b/test/quote_calc2.tab.h
@@ -0,0 +1,15 @@
+#define OP_ADD 257
+#define ADD 258
+#define OP_SUB 259
+#define SUB 260
+#define OP_MUL 261
+#define MUL 262
+#define OP_DIV 263
+#define DIV 264
+#define OP_MOD 265
+#define MOD 266
+#define OP_AND 267
+#define AND 268
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
diff --git a/test/quote_calc2.y b/test/quote_calc2.y
new file mode 100644
index 0000000..ab72a28
--- /dev/null
+++ b/test/quote_calc2.y
@@ -0,0 +1,112 @@
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+%}
+
+%start list
+
+%token OP_ADD "ADD"
+%token OP_SUB "SUB"
+%token OP_MUL "MUL"
+%token OP_DIV "DIV"
+%token OP_MOD "MOD"
+%token OP_AND "AND"
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr "ADD" expr
+ { $$ = $1 + $3; }
+ | expr "SUB" expr
+ { $$ = $1 - $3; }
+ | expr "MUL" expr
+ { $$ = $1 * $3; }
+ | expr "DIV" expr
+ { $$ = $1 / $3; }
+ | expr "MOD" expr
+ { $$ = $1 % $3; }
+ | expr "AND" expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | "SUB" expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
diff --git a/test/quote_calc3-s.output b/test/quote_calc3-s.output
new file mode 100644
index 0000000..0306652
--- /dev/null
+++ b/test/quote_calc3-s.output
@@ -0,0 +1,557 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr OP_ADD expr
+ 8 | expr OP_SUB expr
+ 9 | expr OP_MUL expr
+ 10 | expr OP_DIV expr
+ 11 | expr OP_MOD expr
+ 12 | expr OP_AND expr
+ 13 | expr '|' expr
+ 14 | OP_SUB expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ expr : OP_SUB . expr (14)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 12
+ number goto 9
+
+
+state 4
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 5
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 13
+ OP_ADD reduce 15
+ OP_SUB reduce 15
+ OP_MUL reduce 15
+ OP_DIV reduce 15
+ OP_MOD reduce 15
+ OP_AND reduce 15
+ '|' reduce 15
+ '\n' reduce 15
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ OP_ADD reduce 16
+ OP_SUB reduce 16
+ OP_MUL reduce 16
+ OP_DIV reduce 16
+ OP_MOD reduce 16
+ OP_AND reduce 16
+ '|' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD
+12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB
+12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL
+12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV
+12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD
+12: shift/reduce conflict (shift 21, reduce 14) on OP_AND
+state 12
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+ expr : OP_SUB expr . (14)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' reduce 14
+ '\n' reduce 14
+ ')' reduce 14
+
+
+state 13
+ stat : LETTER '=' . expr (5)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr OP_ADD . expr (7)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr OP_SUB . expr (8)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr OP_MUL . expr (9)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr OP_DIV . expr (10)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr OP_MOD . expr (11)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr OP_AND . expr (12)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '|' . expr (13)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD
+26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB
+26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL
+26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV
+26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD
+26: shift/reduce conflict (shift 21, reduce 7) on OP_AND
+26: shift/reduce conflict (shift 22, reduce 7) on '|'
+state 26
+ expr : expr . OP_ADD expr (7)
+ expr : expr OP_ADD expr . (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 7
+ ')' reduce 7
+
+
+27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD
+27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB
+27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL
+27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV
+27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD
+27: shift/reduce conflict (shift 21, reduce 8) on OP_AND
+27: shift/reduce conflict (shift 22, reduce 8) on '|'
+state 27
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr OP_SUB expr . (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 8
+ ')' reduce 8
+
+
+28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD
+28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB
+28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL
+28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV
+28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD
+28: shift/reduce conflict (shift 21, reduce 9) on OP_AND
+28: shift/reduce conflict (shift 22, reduce 9) on '|'
+state 28
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr OP_MUL expr . (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 9
+ ')' reduce 9
+
+
+29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD
+29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB
+29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL
+29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV
+29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD
+29: shift/reduce conflict (shift 21, reduce 10) on OP_AND
+29: shift/reduce conflict (shift 22, reduce 10) on '|'
+state 29
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr OP_DIV expr . (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 10
+ ')' reduce 10
+
+
+30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD
+30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB
+30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL
+30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV
+30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD
+30: shift/reduce conflict (shift 21, reduce 11) on OP_AND
+30: shift/reduce conflict (shift 22, reduce 11) on '|'
+state 30
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr OP_MOD expr . (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 11
+ ')' reduce 11
+
+
+31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD
+31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB
+31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL
+31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV
+31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD
+31: shift/reduce conflict (shift 21, reduce 12) on OP_AND
+31: shift/reduce conflict (shift 22, reduce 12) on '|'
+state 31
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr OP_AND expr . (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 12
+ ')' reduce 12
+
+
+32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD
+32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB
+32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL
+32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV
+32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD
+32: shift/reduce conflict (shift 21, reduce 13) on OP_AND
+state 32
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+State 12 contains 6 shift/reduce conflicts.
+State 26 contains 7 shift/reduce conflicts.
+State 27 contains 7 shift/reduce conflicts.
+State 28 contains 7 shift/reduce conflicts.
+State 29 contains 7 shift/reduce conflicts.
+State 30 contains 7 shift/reduce conflicts.
+State 31 contains 7 shift/reduce conflicts.
+State 32 contains 6 shift/reduce conflicts.
+
+
+28 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/quote_calc3-s.tab.c b/test/quote_calc3-s.tab.c
new file mode 100644
index 0000000..0953fbb
--- /dev/null
+++ b/test/quote_calc3-s.tab.c
@@ -0,0 +1,688 @@
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse quote_calc3_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex quote_calc3_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror quote_calc3_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar quote_calc3_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval quote_calc3_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval quote_calc3_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug quote_calc3_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs quote_calc3_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag quote_calc3_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs quote_calc3_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen quote_calc3_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred quote_calc3_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto quote_calc3_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex quote_calc3_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex quote_calc3_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex quote_calc3_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable quote_calc3_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck quote_calc3_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname quote_calc3_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule quote_calc3_rule
+#endif /* yyrule */
+#define YYPREFIX "quote_calc3_"
+
+#define YYPURE 0
+
+#line 2 "quote_calc3.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+#line 109 "quote_calc3-s.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
+#define YYERRCODE 256
+static const short quote_calc3_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short quote_calc3_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short quote_calc3_defred[] = { 1,
+ 0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
+ 15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
+ 0, 0,
+};
+static const short quote_calc3_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short quote_calc3_sindex[] = { 0,
+ -38, 5, -36, 0, -51, -36, 7, -121, -248, 0,
+ 0, -243, -36, -22, 0, -36, -36, -36, -36, -36,
+ -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
+ -121, -243,
+};
+static const short quote_calc3_rindex[] = { 0,
+ 0, 0, 0, 0, -9, 0, 0, 13, -10, 0,
+ 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 15, 0, -3, -2, -1, 1, 2,
+ 3, -4,
+};
+static const short quote_calc3_gindex[] = { 0,
+ 0, 42, 0,
+};
+#define YYTABLESIZE 258
+static const short quote_calc3_table[] = { 16,
+ 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
+ 10, 11, 12, 16, 10, 17, 15, 18, 25, 19,
+ 23, 20, 4, 21, 5, 0, 0, 0, 0, 0,
+ 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
+ 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
+ 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
+ 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 16, 0, 17, 0, 18,
+ 0, 19, 0, 20, 0, 21, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
+ 3, 0, 3, 0, 0, 0, 0, 0, 0, 0,
+ 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
+ 19, 0, 20, 0, 21, 0, 16, 15, 16, 15,
+ 16, 15, 16, 15, 16, 15, 16, 15,
+};
+static const short quote_calc3_check[] = { 10,
+ 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
+ 10, 10, 10, 257, 10, 259, 10, 261, 41, 263,
+ 269, 265, 10, 267, 10, -1, -1, -1, -1, -1,
+ 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
+ -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
+ -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
+ 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 124, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 257, -1, 259, -1, 261,
+ -1, 263, -1, 265, -1, 267, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
+ 259, -1, 259, -1, -1, -1, -1, -1, -1, -1,
+ 269, 270, 269, 270, 257, -1, 259, -1, 261, -1,
+ 263, -1, 265, -1, 267, -1, 257, 257, 259, 259,
+ 261, 261, 263, 263, 265, 265, 267, 267,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 271
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL",
+"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"",
+"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr OP_ADD expr",
+"expr : expr OP_SUB expr",
+"expr : expr OP_MUL expr",
+"expr : expr OP_DIV expr",
+"expr : expr OP_MOD expr",
+"expr : expr OP_AND expr",
+"expr : expr '|' expr",
+"expr : OP_SUB expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 73 "quote_calc3.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 362 "quote_calc3-s.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 35 "quote_calc3.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 39 "quote_calc3.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 41 "quote_calc3.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 45 "quote_calc3.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 47 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 49 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 51 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 53 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 55 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 57 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 59 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 61 "quote_calc3.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 63 "quote_calc3.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 68 "quote_calc3.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 70 "quote_calc3.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 628 "quote_calc3-s.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/quote_calc3-s.tab.h b/test/quote_calc3-s.tab.h
new file mode 100644
index 0000000..1a46579
--- /dev/null
+++ b/test/quote_calc3-s.tab.h
@@ -0,0 +1,9 @@
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
diff --git a/test/quote_calc3.output b/test/quote_calc3.output
new file mode 100644
index 0000000..0306652
--- /dev/null
+++ b/test/quote_calc3.output
@@ -0,0 +1,557 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr OP_ADD expr
+ 8 | expr OP_SUB expr
+ 9 | expr OP_MUL expr
+ 10 | expr OP_DIV expr
+ 11 | expr OP_MOD expr
+ 12 | expr OP_AND expr
+ 13 | expr '|' expr
+ 14 | OP_SUB expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ expr : OP_SUB . expr (14)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 12
+ number goto 9
+
+
+state 4
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 5
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 13
+ OP_ADD reduce 15
+ OP_SUB reduce 15
+ OP_MUL reduce 15
+ OP_DIV reduce 15
+ OP_MOD reduce 15
+ OP_AND reduce 15
+ '|' reduce 15
+ '\n' reduce 15
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ OP_ADD reduce 16
+ OP_SUB reduce 16
+ OP_MUL reduce 16
+ OP_DIV reduce 16
+ OP_MOD reduce 16
+ OP_AND reduce 16
+ '|' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD
+12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB
+12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL
+12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV
+12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD
+12: shift/reduce conflict (shift 21, reduce 14) on OP_AND
+state 12
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+ expr : OP_SUB expr . (14)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' reduce 14
+ '\n' reduce 14
+ ')' reduce 14
+
+
+state 13
+ stat : LETTER '=' . expr (5)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr OP_ADD . expr (7)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr OP_SUB . expr (8)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr OP_MUL . expr (9)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr OP_DIV . expr (10)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr OP_MOD . expr (11)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr OP_AND . expr (12)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '|' . expr (13)
+
+ OP_SUB shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD
+26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB
+26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL
+26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV
+26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD
+26: shift/reduce conflict (shift 21, reduce 7) on OP_AND
+26: shift/reduce conflict (shift 22, reduce 7) on '|'
+state 26
+ expr : expr . OP_ADD expr (7)
+ expr : expr OP_ADD expr . (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 7
+ ')' reduce 7
+
+
+27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD
+27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB
+27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL
+27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV
+27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD
+27: shift/reduce conflict (shift 21, reduce 8) on OP_AND
+27: shift/reduce conflict (shift 22, reduce 8) on '|'
+state 27
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr OP_SUB expr . (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 8
+ ')' reduce 8
+
+
+28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD
+28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB
+28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL
+28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV
+28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD
+28: shift/reduce conflict (shift 21, reduce 9) on OP_AND
+28: shift/reduce conflict (shift 22, reduce 9) on '|'
+state 28
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr OP_MUL expr . (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 9
+ ')' reduce 9
+
+
+29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD
+29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB
+29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL
+29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV
+29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD
+29: shift/reduce conflict (shift 21, reduce 10) on OP_AND
+29: shift/reduce conflict (shift 22, reduce 10) on '|'
+state 29
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr OP_DIV expr . (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 10
+ ')' reduce 10
+
+
+30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD
+30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB
+30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL
+30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV
+30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD
+30: shift/reduce conflict (shift 21, reduce 11) on OP_AND
+30: shift/reduce conflict (shift 22, reduce 11) on '|'
+state 30
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr OP_MOD expr . (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 11
+ ')' reduce 11
+
+
+31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD
+31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB
+31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL
+31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV
+31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD
+31: shift/reduce conflict (shift 21, reduce 12) on OP_AND
+31: shift/reduce conflict (shift 22, reduce 12) on '|'
+state 31
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr OP_AND expr . (12)
+ expr : expr . '|' expr (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' shift 22
+ '\n' reduce 12
+ ')' reduce 12
+
+
+32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD
+32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB
+32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL
+32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV
+32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD
+32: shift/reduce conflict (shift 21, reduce 13) on OP_AND
+state 32
+ expr : expr . OP_ADD expr (7)
+ expr : expr . OP_SUB expr (8)
+ expr : expr . OP_MUL expr (9)
+ expr : expr . OP_DIV expr (10)
+ expr : expr . OP_MOD expr (11)
+ expr : expr . OP_AND expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ OP_ADD shift 16
+ OP_SUB shift 17
+ OP_MUL shift 18
+ OP_DIV shift 19
+ OP_MOD shift 20
+ OP_AND shift 21
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+State 12 contains 6 shift/reduce conflicts.
+State 26 contains 7 shift/reduce conflicts.
+State 27 contains 7 shift/reduce conflicts.
+State 28 contains 7 shift/reduce conflicts.
+State 29 contains 7 shift/reduce conflicts.
+State 30 contains 7 shift/reduce conflicts.
+State 31 contains 7 shift/reduce conflicts.
+State 32 contains 6 shift/reduce conflicts.
+
+
+28 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/quote_calc3.tab.c b/test/quote_calc3.tab.c
new file mode 100644
index 0000000..731b4ab
--- /dev/null
+++ b/test/quote_calc3.tab.c
@@ -0,0 +1,688 @@
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse quote_calc3_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex quote_calc3_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror quote_calc3_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar quote_calc3_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval quote_calc3_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval quote_calc3_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug quote_calc3_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs quote_calc3_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag quote_calc3_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs quote_calc3_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen quote_calc3_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred quote_calc3_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto quote_calc3_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex quote_calc3_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex quote_calc3_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex quote_calc3_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable quote_calc3_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck quote_calc3_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname quote_calc3_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule quote_calc3_rule
+#endif /* yyrule */
+#define YYPREFIX "quote_calc3_"
+
+#define YYPURE 0
+
+#line 2 "quote_calc3.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+#line 109 "quote_calc3.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
+#define YYERRCODE 256
+static const short quote_calc3_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short quote_calc3_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short quote_calc3_defred[] = { 1,
+ 0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
+ 15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
+ 0, 0,
+};
+static const short quote_calc3_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short quote_calc3_sindex[] = { 0,
+ -38, 5, -36, 0, -51, -36, 7, -121, -248, 0,
+ 0, -243, -36, -22, 0, -36, -36, -36, -36, -36,
+ -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
+ -121, -243,
+};
+static const short quote_calc3_rindex[] = { 0,
+ 0, 0, 0, 0, -9, 0, 0, 13, -10, 0,
+ 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 15, 0, -3, -2, -1, 1, 2,
+ 3, -4,
+};
+static const short quote_calc3_gindex[] = { 0,
+ 0, 42, 0,
+};
+#define YYTABLESIZE 258
+static const short quote_calc3_table[] = { 16,
+ 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
+ 10, 11, 12, 16, 10, 17, 15, 18, 25, 19,
+ 23, 20, 4, 21, 5, 0, 0, 0, 0, 0,
+ 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
+ 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
+ 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
+ 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 16, 0, 17, 0, 18,
+ 0, 19, 0, 20, 0, 21, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
+ 3, 0, 3, 0, 0, 0, 0, 0, 0, 0,
+ 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
+ 19, 0, 20, 0, 21, 0, 16, 15, 16, 15,
+ 16, 15, 16, 15, 16, 15, 16, 15,
+};
+static const short quote_calc3_check[] = { 10,
+ 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
+ 10, 10, 10, 257, 10, 259, 10, 261, 41, 263,
+ 269, 265, 10, 267, 10, -1, -1, -1, -1, -1,
+ 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
+ -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
+ -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
+ 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 124, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 257, -1, 259, -1, 261,
+ -1, 263, -1, 265, -1, 267, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
+ 259, -1, 259, -1, -1, -1, -1, -1, -1, -1,
+ 269, 270, 269, 270, 257, -1, 259, -1, 261, -1,
+ 263, -1, 265, -1, 267, -1, 257, 257, 259, 259,
+ 261, 261, 263, 263, 265, 265, 267, 267,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 271
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL",
+"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"",
+"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr OP_ADD expr",
+"expr : expr OP_SUB expr",
+"expr : expr OP_MUL expr",
+"expr : expr OP_DIV expr",
+"expr : expr OP_MOD expr",
+"expr : expr OP_AND expr",
+"expr : expr '|' expr",
+"expr : OP_SUB expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 73 "quote_calc3.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 362 "quote_calc3.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 35 "quote_calc3.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 39 "quote_calc3.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 41 "quote_calc3.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 45 "quote_calc3.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 47 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 49 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 51 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 53 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 55 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 57 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 59 "quote_calc3.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 61 "quote_calc3.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 63 "quote_calc3.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 68 "quote_calc3.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 70 "quote_calc3.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 628 "quote_calc3.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/quote_calc3.tab.h b/test/quote_calc3.tab.h
new file mode 100644
index 0000000..1a46579
--- /dev/null
+++ b/test/quote_calc3.tab.h
@@ -0,0 +1,9 @@
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
diff --git a/test/quote_calc3.y b/test/quote_calc3.y
new file mode 100644
index 0000000..5feeb4a
--- /dev/null
+++ b/test/quote_calc3.y
@@ -0,0 +1,112 @@
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+%}
+
+%start list
+
+%token OP_ADD "ADD-operator"
+%token OP_SUB "SUB-operator"
+%token OP_MUL "MUL-operator"
+%token OP_DIV "DIV-operator"
+%token OP_MOD "MOD-operator"
+%token OP_AND "AND-operator"
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr OP_ADD expr
+ { $$ = $1 + $3; }
+ | expr OP_SUB expr
+ { $$ = $1 - $3; }
+ | expr OP_MUL expr
+ { $$ = $1 * $3; }
+ | expr OP_DIV expr
+ { $$ = $1 / $3; }
+ | expr OP_MOD expr
+ { $$ = $1 % $3; }
+ | expr OP_AND expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | OP_SUB expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
diff --git a/test/quote_calc4-s.output b/test/quote_calc4-s.output
new file mode 100644
index 0000000..a1d5afc
--- /dev/null
+++ b/test/quote_calc4-s.output
@@ -0,0 +1,557 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr "ADD-operator" expr
+ 8 | expr "SUB-operator" expr
+ 9 | expr "MUL-operator" expr
+ 10 | expr "DIV-operator" expr
+ 11 | expr "MOD-operator" expr
+ 12 | expr "AND-operator" expr
+ 13 | expr '|' expr
+ 14 | "SUB-operator" expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ expr : "SUB-operator" . expr (14)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 12
+ number goto 9
+
+
+state 4
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 5
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 13
+ "ADD-operator" reduce 15
+ "SUB-operator" reduce 15
+ "MUL-operator" reduce 15
+ "DIV-operator" reduce 15
+ "MOD-operator" reduce 15
+ "AND-operator" reduce 15
+ '|' reduce 15
+ '\n' reduce 15
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ "ADD-operator" reduce 16
+ "SUB-operator" reduce 16
+ "MUL-operator" reduce 16
+ "DIV-operator" reduce 16
+ "MOD-operator" reduce 16
+ "AND-operator" reduce 16
+ '|' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+12: shift/reduce conflict (shift 16, reduce 14) on "ADD-operator"
+12: shift/reduce conflict (shift 17, reduce 14) on "SUB-operator"
+12: shift/reduce conflict (shift 18, reduce 14) on "MUL-operator"
+12: shift/reduce conflict (shift 19, reduce 14) on "DIV-operator"
+12: shift/reduce conflict (shift 20, reduce 14) on "MOD-operator"
+12: shift/reduce conflict (shift 21, reduce 14) on "AND-operator"
+state 12
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+ expr : "SUB-operator" expr . (14)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' reduce 14
+ '\n' reduce 14
+ ')' reduce 14
+
+
+state 13
+ stat : LETTER '=' . expr (5)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr "ADD-operator" . expr (7)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr "SUB-operator" . expr (8)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr "MUL-operator" . expr (9)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr "DIV-operator" . expr (10)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr "MOD-operator" . expr (11)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr "AND-operator" . expr (12)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '|' . expr (13)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+26: shift/reduce conflict (shift 16, reduce 7) on "ADD-operator"
+26: shift/reduce conflict (shift 17, reduce 7) on "SUB-operator"
+26: shift/reduce conflict (shift 18, reduce 7) on "MUL-operator"
+26: shift/reduce conflict (shift 19, reduce 7) on "DIV-operator"
+26: shift/reduce conflict (shift 20, reduce 7) on "MOD-operator"
+26: shift/reduce conflict (shift 21, reduce 7) on "AND-operator"
+26: shift/reduce conflict (shift 22, reduce 7) on '|'
+state 26
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr "ADD-operator" expr . (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 7
+ ')' reduce 7
+
+
+27: shift/reduce conflict (shift 16, reduce 8) on "ADD-operator"
+27: shift/reduce conflict (shift 17, reduce 8) on "SUB-operator"
+27: shift/reduce conflict (shift 18, reduce 8) on "MUL-operator"
+27: shift/reduce conflict (shift 19, reduce 8) on "DIV-operator"
+27: shift/reduce conflict (shift 20, reduce 8) on "MOD-operator"
+27: shift/reduce conflict (shift 21, reduce 8) on "AND-operator"
+27: shift/reduce conflict (shift 22, reduce 8) on '|'
+state 27
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr "SUB-operator" expr . (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 8
+ ')' reduce 8
+
+
+28: shift/reduce conflict (shift 16, reduce 9) on "ADD-operator"
+28: shift/reduce conflict (shift 17, reduce 9) on "SUB-operator"
+28: shift/reduce conflict (shift 18, reduce 9) on "MUL-operator"
+28: shift/reduce conflict (shift 19, reduce 9) on "DIV-operator"
+28: shift/reduce conflict (shift 20, reduce 9) on "MOD-operator"
+28: shift/reduce conflict (shift 21, reduce 9) on "AND-operator"
+28: shift/reduce conflict (shift 22, reduce 9) on '|'
+state 28
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr "MUL-operator" expr . (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 9
+ ')' reduce 9
+
+
+29: shift/reduce conflict (shift 16, reduce 10) on "ADD-operator"
+29: shift/reduce conflict (shift 17, reduce 10) on "SUB-operator"
+29: shift/reduce conflict (shift 18, reduce 10) on "MUL-operator"
+29: shift/reduce conflict (shift 19, reduce 10) on "DIV-operator"
+29: shift/reduce conflict (shift 20, reduce 10) on "MOD-operator"
+29: shift/reduce conflict (shift 21, reduce 10) on "AND-operator"
+29: shift/reduce conflict (shift 22, reduce 10) on '|'
+state 29
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr "DIV-operator" expr . (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 10
+ ')' reduce 10
+
+
+30: shift/reduce conflict (shift 16, reduce 11) on "ADD-operator"
+30: shift/reduce conflict (shift 17, reduce 11) on "SUB-operator"
+30: shift/reduce conflict (shift 18, reduce 11) on "MUL-operator"
+30: shift/reduce conflict (shift 19, reduce 11) on "DIV-operator"
+30: shift/reduce conflict (shift 20, reduce 11) on "MOD-operator"
+30: shift/reduce conflict (shift 21, reduce 11) on "AND-operator"
+30: shift/reduce conflict (shift 22, reduce 11) on '|'
+state 30
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr "MOD-operator" expr . (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 11
+ ')' reduce 11
+
+
+31: shift/reduce conflict (shift 16, reduce 12) on "ADD-operator"
+31: shift/reduce conflict (shift 17, reduce 12) on "SUB-operator"
+31: shift/reduce conflict (shift 18, reduce 12) on "MUL-operator"
+31: shift/reduce conflict (shift 19, reduce 12) on "DIV-operator"
+31: shift/reduce conflict (shift 20, reduce 12) on "MOD-operator"
+31: shift/reduce conflict (shift 21, reduce 12) on "AND-operator"
+31: shift/reduce conflict (shift 22, reduce 12) on '|'
+state 31
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr "AND-operator" expr . (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 12
+ ')' reduce 12
+
+
+32: shift/reduce conflict (shift 16, reduce 13) on "ADD-operator"
+32: shift/reduce conflict (shift 17, reduce 13) on "SUB-operator"
+32: shift/reduce conflict (shift 18, reduce 13) on "MUL-operator"
+32: shift/reduce conflict (shift 19, reduce 13) on "DIV-operator"
+32: shift/reduce conflict (shift 20, reduce 13) on "MOD-operator"
+32: shift/reduce conflict (shift 21, reduce 13) on "AND-operator"
+state 32
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+State 12 contains 6 shift/reduce conflicts.
+State 26 contains 7 shift/reduce conflicts.
+State 27 contains 7 shift/reduce conflicts.
+State 28 contains 7 shift/reduce conflicts.
+State 29 contains 7 shift/reduce conflicts.
+State 30 contains 7 shift/reduce conflicts.
+State 31 contains 7 shift/reduce conflicts.
+State 32 contains 6 shift/reduce conflicts.
+
+
+28 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/quote_calc4-s.tab.c b/test/quote_calc4-s.tab.c
new file mode 100644
index 0000000..29e176a
--- /dev/null
+++ b/test/quote_calc4-s.tab.c
@@ -0,0 +1,688 @@
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse quote_calc4_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex quote_calc4_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror quote_calc4_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar quote_calc4_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval quote_calc4_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval quote_calc4_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug quote_calc4_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs quote_calc4_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag quote_calc4_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs quote_calc4_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen quote_calc4_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred quote_calc4_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto quote_calc4_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex quote_calc4_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex quote_calc4_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex quote_calc4_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable quote_calc4_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck quote_calc4_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname quote_calc4_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule quote_calc4_rule
+#endif /* yyrule */
+#define YYPREFIX "quote_calc4_"
+
+#define YYPURE 0
+
+#line 2 "quote_calc4.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+#line 109 "quote_calc4-s.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
+#define YYERRCODE 256
+static const short quote_calc4_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short quote_calc4_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short quote_calc4_defred[] = { 1,
+ 0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
+ 15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
+ 0, 0,
+};
+static const short quote_calc4_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short quote_calc4_sindex[] = { 0,
+ -38, 4, -36, 0, -51, -36, 6, -121, -249, 0,
+ 0, -243, -36, -23, 0, -36, -36, -36, -36, -36,
+ -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
+ -121, -243,
+};
+static const short quote_calc4_rindex[] = { 0,
+ 0, 0, 0, 0, -9, 0, 0, 12, -10, 0,
+ 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 14, 0, -3, -2, -1, 1, 2,
+ 3, -4,
+};
+static const short quote_calc4_gindex[] = { 0,
+ 0, 42, 0,
+};
+#define YYTABLESIZE 259
+static const short quote_calc4_table[] = { 16,
+ 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
+ 10, 11, 12, 10, 16, 15, 17, 25, 18, 23,
+ 19, 4, 20, 5, 21, 0, 0, 0, 0, 0,
+ 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
+ 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
+ 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
+ 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 22, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 16, 0, 17, 0,
+ 18, 0, 19, 0, 20, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
+ 0, 3, 0, 3, 0, 0, 0, 0, 0, 0,
+ 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
+ 19, 0, 20, 0, 21, 0, 0, 16, 15, 16,
+ 15, 16, 15, 16, 15, 16, 15, 16, 15,
+};
+static const short quote_calc4_check[] = { 10,
+ 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
+ 10, 10, 10, 10, 258, 10, 260, 41, 262, 269,
+ 264, 10, 266, 10, 268, -1, -1, -1, -1, -1,
+ 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
+ -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
+ -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
+ 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 258, -1, 260, -1,
+ 262, -1, 264, -1, 266, -1, 268, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
+ -1, 260, -1, 260, -1, -1, -1, -1, -1, -1,
+ 269, 270, 269, 270, 258, -1, 260, -1, 262, -1,
+ 264, -1, 266, -1, 268, -1, -1, 258, 258, 260,
+ 260, 262, 262, 264, 264, 266, 266, 268, 268,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 271
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL",
+"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"",
+"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr \"ADD-operator\" expr",
+"expr : expr \"SUB-operator\" expr",
+"expr : expr \"MUL-operator\" expr",
+"expr : expr \"DIV-operator\" expr",
+"expr : expr \"MOD-operator\" expr",
+"expr : expr \"AND-operator\" expr",
+"expr : expr '|' expr",
+"expr : \"SUB-operator\" expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 73 "quote_calc4.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 362 "quote_calc4-s.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 35 "quote_calc4.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 39 "quote_calc4.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 41 "quote_calc4.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 45 "quote_calc4.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 47 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 49 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 51 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 53 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 55 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 57 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 59 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 61 "quote_calc4.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 63 "quote_calc4.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 68 "quote_calc4.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 70 "quote_calc4.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 628 "quote_calc4-s.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/quote_calc4-s.tab.h b/test/quote_calc4-s.tab.h
new file mode 100644
index 0000000..1a46579
--- /dev/null
+++ b/test/quote_calc4-s.tab.h
@@ -0,0 +1,9 @@
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
diff --git a/test/quote_calc4.output b/test/quote_calc4.output
new file mode 100644
index 0000000..a1d5afc
--- /dev/null
+++ b/test/quote_calc4.output
@@ -0,0 +1,557 @@
+ 0 $accept : list $end
+
+ 1 list :
+ 2 | list stat '\n'
+ 3 | list error '\n'
+
+ 4 stat : expr
+ 5 | LETTER '=' expr
+
+ 6 expr : '(' expr ')'
+ 7 | expr "ADD-operator" expr
+ 8 | expr "SUB-operator" expr
+ 9 | expr "MUL-operator" expr
+ 10 | expr "DIV-operator" expr
+ 11 | expr "MOD-operator" expr
+ 12 | expr "AND-operator" expr
+ 13 | expr '|' expr
+ 14 | "SUB-operator" expr
+ 15 | LETTER
+ 16 | number
+
+ 17 number : DIGIT
+ 18 | number DIGIT
+
+state 0
+ $accept : . list $end (0)
+ list : . (1)
+
+ . reduce 1
+
+ list goto 1
+
+
+state 1
+ $accept : list . $end (0)
+ list : list . stat '\n' (2)
+ list : list . error '\n' (3)
+
+ $end accept
+ error shift 2
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 5
+ '(' shift 6
+ . error
+
+ stat goto 7
+ expr goto 8
+ number goto 9
+
+
+state 2
+ list : list error . '\n' (3)
+
+ '\n' shift 10
+ . error
+
+
+state 3
+ expr : "SUB-operator" . expr (14)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 12
+ number goto 9
+
+
+state 4
+ number : DIGIT . (17)
+
+ . reduce 17
+
+
+state 5
+ stat : LETTER . '=' expr (5)
+ expr : LETTER . (15)
+
+ '=' shift 13
+ "ADD-operator" reduce 15
+ "SUB-operator" reduce 15
+ "MUL-operator" reduce 15
+ "DIV-operator" reduce 15
+ "MOD-operator" reduce 15
+ "AND-operator" reduce 15
+ '|' reduce 15
+ '\n' reduce 15
+
+
+state 6
+ expr : '(' . expr ')' (6)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 14
+ number goto 9
+
+
+state 7
+ list : list stat . '\n' (2)
+
+ '\n' shift 15
+ . error
+
+
+state 8
+ stat : expr . (4)
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 4
+
+
+state 9
+ expr : number . (16)
+ number : number . DIGIT (18)
+
+ DIGIT shift 23
+ "ADD-operator" reduce 16
+ "SUB-operator" reduce 16
+ "MUL-operator" reduce 16
+ "DIV-operator" reduce 16
+ "MOD-operator" reduce 16
+ "AND-operator" reduce 16
+ '|' reduce 16
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 10
+ list : list error '\n' . (3)
+
+ . reduce 3
+
+
+state 11
+ expr : LETTER . (15)
+
+ . reduce 15
+
+
+12: shift/reduce conflict (shift 16, reduce 14) on "ADD-operator"
+12: shift/reduce conflict (shift 17, reduce 14) on "SUB-operator"
+12: shift/reduce conflict (shift 18, reduce 14) on "MUL-operator"
+12: shift/reduce conflict (shift 19, reduce 14) on "DIV-operator"
+12: shift/reduce conflict (shift 20, reduce 14) on "MOD-operator"
+12: shift/reduce conflict (shift 21, reduce 14) on "AND-operator"
+state 12
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+ expr : "SUB-operator" expr . (14)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' reduce 14
+ '\n' reduce 14
+ ')' reduce 14
+
+
+state 13
+ stat : LETTER '=' . expr (5)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 24
+ number goto 9
+
+
+state 14
+ expr : '(' expr . ')' (6)
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ ')' shift 25
+ . error
+
+
+state 15
+ list : list stat '\n' . (2)
+
+ . reduce 2
+
+
+state 16
+ expr : expr "ADD-operator" . expr (7)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 26
+ number goto 9
+
+
+state 17
+ expr : expr "SUB-operator" . expr (8)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 27
+ number goto 9
+
+
+state 18
+ expr : expr "MUL-operator" . expr (9)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 28
+ number goto 9
+
+
+state 19
+ expr : expr "DIV-operator" . expr (10)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 29
+ number goto 9
+
+
+state 20
+ expr : expr "MOD-operator" . expr (11)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 30
+ number goto 9
+
+
+state 21
+ expr : expr "AND-operator" . expr (12)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 31
+ number goto 9
+
+
+state 22
+ expr : expr '|' . expr (13)
+
+ "SUB-operator" shift 3
+ DIGIT shift 4
+ LETTER shift 11
+ '(' shift 6
+ . error
+
+ expr goto 32
+ number goto 9
+
+
+state 23
+ number : number DIGIT . (18)
+
+ . reduce 18
+
+
+state 24
+ stat : LETTER '=' expr . (5)
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 5
+
+
+state 25
+ expr : '(' expr ')' . (6)
+
+ . reduce 6
+
+
+26: shift/reduce conflict (shift 16, reduce 7) on "ADD-operator"
+26: shift/reduce conflict (shift 17, reduce 7) on "SUB-operator"
+26: shift/reduce conflict (shift 18, reduce 7) on "MUL-operator"
+26: shift/reduce conflict (shift 19, reduce 7) on "DIV-operator"
+26: shift/reduce conflict (shift 20, reduce 7) on "MOD-operator"
+26: shift/reduce conflict (shift 21, reduce 7) on "AND-operator"
+26: shift/reduce conflict (shift 22, reduce 7) on '|'
+state 26
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr "ADD-operator" expr . (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 7
+ ')' reduce 7
+
+
+27: shift/reduce conflict (shift 16, reduce 8) on "ADD-operator"
+27: shift/reduce conflict (shift 17, reduce 8) on "SUB-operator"
+27: shift/reduce conflict (shift 18, reduce 8) on "MUL-operator"
+27: shift/reduce conflict (shift 19, reduce 8) on "DIV-operator"
+27: shift/reduce conflict (shift 20, reduce 8) on "MOD-operator"
+27: shift/reduce conflict (shift 21, reduce 8) on "AND-operator"
+27: shift/reduce conflict (shift 22, reduce 8) on '|'
+state 27
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr "SUB-operator" expr . (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 8
+ ')' reduce 8
+
+
+28: shift/reduce conflict (shift 16, reduce 9) on "ADD-operator"
+28: shift/reduce conflict (shift 17, reduce 9) on "SUB-operator"
+28: shift/reduce conflict (shift 18, reduce 9) on "MUL-operator"
+28: shift/reduce conflict (shift 19, reduce 9) on "DIV-operator"
+28: shift/reduce conflict (shift 20, reduce 9) on "MOD-operator"
+28: shift/reduce conflict (shift 21, reduce 9) on "AND-operator"
+28: shift/reduce conflict (shift 22, reduce 9) on '|'
+state 28
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr "MUL-operator" expr . (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 9
+ ')' reduce 9
+
+
+29: shift/reduce conflict (shift 16, reduce 10) on "ADD-operator"
+29: shift/reduce conflict (shift 17, reduce 10) on "SUB-operator"
+29: shift/reduce conflict (shift 18, reduce 10) on "MUL-operator"
+29: shift/reduce conflict (shift 19, reduce 10) on "DIV-operator"
+29: shift/reduce conflict (shift 20, reduce 10) on "MOD-operator"
+29: shift/reduce conflict (shift 21, reduce 10) on "AND-operator"
+29: shift/reduce conflict (shift 22, reduce 10) on '|'
+state 29
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr "DIV-operator" expr . (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 10
+ ')' reduce 10
+
+
+30: shift/reduce conflict (shift 16, reduce 11) on "ADD-operator"
+30: shift/reduce conflict (shift 17, reduce 11) on "SUB-operator"
+30: shift/reduce conflict (shift 18, reduce 11) on "MUL-operator"
+30: shift/reduce conflict (shift 19, reduce 11) on "DIV-operator"
+30: shift/reduce conflict (shift 20, reduce 11) on "MOD-operator"
+30: shift/reduce conflict (shift 21, reduce 11) on "AND-operator"
+30: shift/reduce conflict (shift 22, reduce 11) on '|'
+state 30
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr "MOD-operator" expr . (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 11
+ ')' reduce 11
+
+
+31: shift/reduce conflict (shift 16, reduce 12) on "ADD-operator"
+31: shift/reduce conflict (shift 17, reduce 12) on "SUB-operator"
+31: shift/reduce conflict (shift 18, reduce 12) on "MUL-operator"
+31: shift/reduce conflict (shift 19, reduce 12) on "DIV-operator"
+31: shift/reduce conflict (shift 20, reduce 12) on "MOD-operator"
+31: shift/reduce conflict (shift 21, reduce 12) on "AND-operator"
+31: shift/reduce conflict (shift 22, reduce 12) on '|'
+state 31
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr "AND-operator" expr . (12)
+ expr : expr . '|' expr (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' shift 22
+ '\n' reduce 12
+ ')' reduce 12
+
+
+32: shift/reduce conflict (shift 16, reduce 13) on "ADD-operator"
+32: shift/reduce conflict (shift 17, reduce 13) on "SUB-operator"
+32: shift/reduce conflict (shift 18, reduce 13) on "MUL-operator"
+32: shift/reduce conflict (shift 19, reduce 13) on "DIV-operator"
+32: shift/reduce conflict (shift 20, reduce 13) on "MOD-operator"
+32: shift/reduce conflict (shift 21, reduce 13) on "AND-operator"
+state 32
+ expr : expr . "ADD-operator" expr (7)
+ expr : expr . "SUB-operator" expr (8)
+ expr : expr . "MUL-operator" expr (9)
+ expr : expr . "DIV-operator" expr (10)
+ expr : expr . "MOD-operator" expr (11)
+ expr : expr . "AND-operator" expr (12)
+ expr : expr . '|' expr (13)
+ expr : expr '|' expr . (13)
+
+ "ADD-operator" shift 16
+ "SUB-operator" shift 17
+ "MUL-operator" shift 18
+ "DIV-operator" shift 19
+ "MOD-operator" shift 20
+ "AND-operator" shift 21
+ '|' reduce 13
+ '\n' reduce 13
+ ')' reduce 13
+
+
+State 12 contains 6 shift/reduce conflicts.
+State 26 contains 7 shift/reduce conflicts.
+State 27 contains 7 shift/reduce conflicts.
+State 28 contains 7 shift/reduce conflicts.
+State 29 contains 7 shift/reduce conflicts.
+State 30 contains 7 shift/reduce conflicts.
+State 31 contains 7 shift/reduce conflicts.
+State 32 contains 6 shift/reduce conflicts.
+
+
+28 terminals, 5 nonterminals
+19 grammar rules, 33 states
diff --git a/test/quote_calc4.tab.c b/test/quote_calc4.tab.c
new file mode 100644
index 0000000..da2f25e
--- /dev/null
+++ b/test/quote_calc4.tab.c
@@ -0,0 +1,688 @@
+#ifndef lint
+static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
+#endif
+
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+
+#define YYEMPTY (-1)
+#define yyclearin (yychar = YYEMPTY)
+#define yyerrok (yyerrflag = 0)
+#define YYRECOVERING() (yyerrflag != 0)
+
+
+#ifndef yyparse
+#define yyparse quote_calc4_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex quote_calc4_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror quote_calc4_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar quote_calc4_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval quote_calc4_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval quote_calc4_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug quote_calc4_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs quote_calc4_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag quote_calc4_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs quote_calc4_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen quote_calc4_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred quote_calc4_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto quote_calc4_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex quote_calc4_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex quote_calc4_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex quote_calc4_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable quote_calc4_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck quote_calc4_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname quote_calc4_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule quote_calc4_rule
+#endif /* yyrule */
+#define YYPREFIX "quote_calc4_"
+
+#define YYPURE 0
+
+#line 2 "quote_calc4.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+#line 109 "quote_calc4.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
+/* compatibility with bison */
+#ifdef YYPARSE_PARAM
+/* compatibility with FreeBSD */
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
+#else
+# define YYPARSE_DECL() yyparse(void)
+#endif
+
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
+
+/* Parameters sent to yyerror. */
+#ifndef YYERROR_DECL
+#define YYERROR_DECL() yyerror(const char *s)
+#endif
+#ifndef YYERROR_CALL
+#define YYERROR_CALL(msg) yyerror(msg)
+#endif
+
+extern int YYPARSE_DECL();
+
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
+#define YYERRCODE 256
+static const short quote_calc4_lhs[] = { -1,
+ 0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 3, 3,
+};
+static const short quote_calc4_len[] = { 2,
+ 0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 2, 1, 1, 1, 2,
+};
+static const short quote_calc4_defred[] = { 1,
+ 0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
+ 15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
+ 0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
+ 0, 0,
+};
+static const short quote_calc4_dgoto[] = { 1,
+ 7, 8, 9,
+};
+static const short quote_calc4_sindex[] = { 0,
+ -38, 4, -36, 0, -51, -36, 6, -121, -249, 0,
+ 0, -243, -36, -23, 0, -36, -36, -36, -36, -36,
+ -36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
+ -121, -243,
+};
+static const short quote_calc4_rindex[] = { 0,
+ 0, 0, 0, 0, -9, 0, 0, 12, -10, 0,
+ 0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 14, 0, -3, -2, -1, 1, 2,
+ 3, -4,
+};
+static const short quote_calc4_gindex[] = { 0,
+ 0, 42, 0,
+};
+#define YYTABLESIZE 259
+static const short quote_calc4_table[] = { 16,
+ 15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
+ 10, 11, 12, 10, 16, 15, 17, 25, 18, 23,
+ 19, 4, 20, 5, 21, 0, 0, 0, 0, 0,
+ 16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
+ 0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
+ 0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
+ 29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 22, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 16, 0, 17, 0,
+ 18, 0, 19, 0, 20, 0, 21, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
+ 0, 3, 0, 3, 0, 0, 0, 0, 0, 0,
+ 4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
+ 19, 0, 20, 0, 21, 0, 0, 16, 15, 16,
+ 15, 16, 15, 16, 15, 16, 15, 16, 15,
+};
+static const short quote_calc4_check[] = { 10,
+ 10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
+ 10, 10, 10, 10, 258, 10, 260, 41, 262, 269,
+ 264, 10, 266, 10, 268, -1, -1, -1, -1, -1,
+ 41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
+ -1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
+ -1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
+ 19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 258, -1, 260, -1,
+ 262, -1, 264, -1, 266, -1, 268, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
+ -1, 260, -1, 260, -1, -1, -1, -1, -1, -1,
+ 269, 270, 269, 270, 258, -1, 260, -1, 262, -1,
+ 264, -1, 266, -1, 268, -1, -1, 258, 258, 260,
+ 260, 262, 262, 264, 264, 266, 266, 268, 268,
+};
+#define YYFINAL 1
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 271
+#if YYDEBUG
+static const char *yyname[] = {
+
+"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL",
+"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"",
+"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : list",
+"list :",
+"list : list stat '\\n'",
+"list : list error '\\n'",
+"stat : expr",
+"stat : LETTER '=' expr",
+"expr : '(' expr ')'",
+"expr : expr \"ADD-operator\" expr",
+"expr : expr \"SUB-operator\" expr",
+"expr : expr \"MUL-operator\" expr",
+"expr : expr \"DIV-operator\" expr",
+"expr : expr \"MOD-operator\" expr",
+"expr : expr \"AND-operator\" expr",
+"expr : expr '|' expr",
+"expr : \"SUB-operator\" expr",
+"expr : LETTER",
+"expr : number",
+"number : DIGIT",
+"number : number DIGIT",
+
+};
+#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* define the initial stack-sizes */
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 500
+#define YYMAXDEPTH 500
+#endif
+#endif
+
+#define YYINITSTACKSIZE 500
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 73 "quote_calc4.y"
+ /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 362 "quote_calc4.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
+
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack(YYSTACKDATA *data)
+{
+ int i;
+ unsigned newsize;
+ short *newss;
+ YYSTYPE *newvs;
+
+ if ((newsize = data->stacksize) == 0)
+ newsize = YYINITSTACKSIZE;
+ else if (newsize >= YYMAXDEPTH)
+ return -1;
+ else if ((newsize *= 2) > YYMAXDEPTH)
+ newsize = YYMAXDEPTH;
+
+ i = data->s_mark - data->s_base;
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
+ if (newvs == 0)
+ return -1;
+
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
+ return 0;
+}
+
+#if YYPURE || defined(YY_NO_LEAKS)
+static void yyfreestack(YYSTACKDATA *data)
+{
+ free(data->s_base);
+ free(data->l_base);
+ memset(data, 0, sizeof(*data));
+}
+#else
+#define yyfreestack(data) /* nothing */
+#endif
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+int
+YYPARSE_DECL()
+{
+ int yym, yyn, yystate;
+#if YYDEBUG
+ const char *yys;
+
+ if ((yys = getenv("YYDEBUG")) != 0)
+ {
+ yyn = *yys;
+ if (yyn >= '0' && yyn <= '9')
+ yydebug = yyn - '0';
+ }
+#endif
+
+ yynerrs = 0;
+ yyerrflag = 0;
+ yychar = YYEMPTY;
+ yystate = 0;
+
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
+ yystate = 0;
+ *yystack.s_mark = 0;
+
+yyloop:
+ if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ }
+ if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, shifting to state %d\n",
+ YYPREFIX, yystate, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ yychar = YYEMPTY;
+ if (yyerrflag > 0) --yyerrflag;
+ goto yyloop;
+ }
+ if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+ {
+ yyn = yytable[yyn];
+ goto yyreduce;
+ }
+ if (yyerrflag) goto yyinrecovery;
+
+ yyerror("syntax error");
+
+ goto yyerrlab;
+
+yyerrlab:
+ ++yynerrs;
+
+yyinrecovery:
+ if (yyerrflag < 3)
+ {
+ yyerrflag = 3;
+ for (;;)
+ {
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ yystate = yytable[yyn];
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
+ goto yyloop;
+ }
+ else
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: error recovery discarding state %d\n",
+ YYPREFIX, *yystack.s_mark);
+#endif
+ if (yystack.s_mark <= yystack.s_base) goto yyabort;
+ --yystack.s_mark;
+ --yystack.l_mark;
+ }
+ }
+ }
+ else
+ {
+ if (yychar == 0) goto yyabort;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+ YYPREFIX, yystate, yychar, yys);
+ }
+#endif
+ yychar = YYEMPTY;
+ goto yyloop;
+ }
+
+yyreduce:
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+ YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+ yym = yylen[yyn];
+ if (yym)
+ yyval = yystack.l_mark[1-yym];
+ else
+ memset(&yyval, 0, sizeof yyval);
+ switch (yyn)
+ {
+case 3:
+#line 35 "quote_calc4.y"
+ { yyerrok ; }
+break;
+case 4:
+#line 39 "quote_calc4.y"
+ { printf("%d\n",yystack.l_mark[0]);}
+break;
+case 5:
+#line 41 "quote_calc4.y"
+ { regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
+break;
+case 6:
+#line 45 "quote_calc4.y"
+ { yyval = yystack.l_mark[-1]; }
+break;
+case 7:
+#line 47 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
+break;
+case 8:
+#line 49 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
+break;
+case 9:
+#line 51 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
+break;
+case 10:
+#line 53 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
+break;
+case 11:
+#line 55 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
+break;
+case 12:
+#line 57 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
+break;
+case 13:
+#line 59 "quote_calc4.y"
+ { yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
+break;
+case 14:
+#line 61 "quote_calc4.y"
+ { yyval = - yystack.l_mark[0]; }
+break;
+case 15:
+#line 63 "quote_calc4.y"
+ { yyval = regs[yystack.l_mark[0]]; }
+break;
+case 17:
+#line 68 "quote_calc4.y"
+ { yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
+break;
+case 18:
+#line 70 "quote_calc4.y"
+ { yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
+break;
+#line 628 "quote_calc4.tab.c"
+ }
+ yystack.s_mark -= yym;
+ yystate = *yystack.s_mark;
+ yystack.l_mark -= yym;
+ yym = yylhs[yyn];
+ if (yystate == 0 && yym == 0)
+ {
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+ yystate = YYFINAL;
+ *++yystack.s_mark = YYFINAL;
+ *++yystack.l_mark = yyval;
+ if (yychar < 0)
+ {
+ if ((yychar = YYLEX) < 0) yychar = 0;
+#if YYDEBUG
+ if (yydebug)
+ {
+ yys = 0;
+ if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+ if (!yys) yys = "illegal-symbol";
+ printf("%sdebug: state %d, reading %d (%s)\n",
+ YYPREFIX, YYFINAL, yychar, yys);
+ }
+#endif
+ }
+ if (yychar == 0) goto yyaccept;
+ goto yyloop;
+ }
+ if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+ yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+ yystate = yytable[yyn];
+ else
+ yystate = yydgoto[yym];
+#if YYDEBUG
+ if (yydebug)
+ printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
+#endif
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
+ {
+ goto yyoverflow;
+ }
+ *++yystack.s_mark = (short) yystate;
+ *++yystack.l_mark = yyval;
+ goto yyloop;
+
+yyoverflow:
+ yyerror("yacc stack overflow");
+
+yyabort:
+ yyfreestack(&yystack);
+ return (1);
+
+yyaccept:
+ yyfreestack(&yystack);
+ return (0);
+}
diff --git a/test/quote_calc4.tab.h b/test/quote_calc4.tab.h
new file mode 100644
index 0000000..1a46579
--- /dev/null
+++ b/test/quote_calc4.tab.h
@@ -0,0 +1,9 @@
+#define OP_ADD 257
+#define OP_SUB 259
+#define OP_MUL 261
+#define OP_DIV 263
+#define OP_MOD 265
+#define OP_AND 267
+#define DIGIT 269
+#define LETTER 270
+#define UMINUS 271
diff --git a/test/quote_calc4.y b/test/quote_calc4.y
new file mode 100644
index 0000000..34b790e
--- /dev/null
+++ b/test/quote_calc4.y
@@ -0,0 +1,112 @@
+%{
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+int yylex(void);
+static void yyerror(const char *s);
+
+%}
+
+%start list
+
+%token OP_ADD "ADD-operator"
+%token OP_SUB "SUB-operator"
+%token OP_MUL "MUL-operator"
+%token OP_DIV "DIV-operator"
+%token OP_MOD "MOD-operator"
+%token OP_AND "AND-operator"
+
+%token DIGIT LETTER
+
+%left '|'
+%left '&'
+%left '+' '-'
+%left '*' '/' '%'
+%left UMINUS /* supplies precedence for unary minus */
+
+%% /* beginning of rules section */
+
+list : /* empty */
+ | list stat '\n'
+ | list error '\n'
+ { yyerrok ; }
+ ;
+
+stat : expr
+ { printf("%d\n",$1);}
+ | LETTER '=' expr
+ { regs[$1] = $3; }
+ ;
+
+expr : '(' expr ')'
+ { $$ = $2; }
+ | expr "ADD-operator" expr
+ { $$ = $1 + $3; }
+ | expr "SUB-operator" expr
+ { $$ = $1 - $3; }
+ | expr "MUL-operator" expr
+ { $$ = $1 * $3; }
+ | expr "DIV-operator" expr
+ { $$ = $1 / $3; }
+ | expr "MOD-operator" expr
+ { $$ = $1 % $3; }
+ | expr "AND-operator" expr
+ { $$ = $1 & $3; }
+ | expr '|' expr
+ { $$ = $1 | $3; }
+ | "SUB-operator" expr %prec UMINUS
+ { $$ = - $2; }
+ | LETTER
+ { $$ = regs[$1]; }
+ | number
+ ;
+
+number: DIGIT
+ { $$ = $1; base = ($1==0) ? 8 : 10; }
+ | number DIGIT
+ { $$ = base * $1 + $2; }
+ ;
+
+%% /* start of programs */
+
+int
+main (void)
+{
+ while(!feof(stdin)) {
+ yyparse();
+ }
+ return 0;
+}
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void) {
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
+
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+
+ /* c is now nonblank */
+
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
diff --git a/test/run_make.sh b/test/run_make.sh
index 2e61a69..2bbe95d 100755
--- a/test/run_make.sh
+++ b/test/run_make.sh
@@ -1,9 +1,11 @@
#!/bin/sh
-# $Id: run_make.sh,v 1.1 2010/06/08 09:00:39 tom Exp $
+# $Id: run_make.sh,v 1.9 2012/01/15 22:35:01 tom Exp $
# vi:ts=4 sw=4:
# do a test-compile on each of the ".c" files in the test-directory
+BISON=`bison --version 2>/dev/null | head -n 1 | sed -e 's/^[^0-9.]*//' -e 's/[^0-9.]*$//'`
+
if test $# = 1
then
PROG_DIR=`pwd`
@@ -13,10 +15,125 @@ else
TEST_DIR=.
fi
+MY_MAKE="make -f $PROG_DIR/makefile srcdir=$PROG_DIR VPATH=$TEST_DIR"
+
echo '** '`date`
-for i in ${TEST_DIR}/*.c
+for input in ${TEST_DIR}/*.c
do
- obj=`echo "$i" |sed -e 's/\.c$/.o/'`
- make -f $PROG_DIR/makefile $obj C_FILES=$i srcdir=$PROG_DIR
+ test -f "$input" || continue
+
+ obj=`basename "$input" .c`.o
+
+ $MY_MAKE $obj C_FILES=$input
test -f $obj && rm $obj
+
+ DEFS=
+ case $input in #(vi
+ ${TEST_DIR}/pure_*)
+ # DEFS="-DYYLEX_PARAM=flag -DYYLEX_PARAM_TYPE=int"
+ ;;
+ esac
+
+ if test "x$DEFS" != "x"
+ then
+ $MY_MAKE $obj C_FILES=$input DEFINES="$DEFS"
+ test -f $obj && rm -f $obj
+ fi
+done
+
+if test -n "$BISON"
+then
+ echo "** compare with bison $BISON"
+ for input in ${TEST_DIR}/*.y
+ do
+ test -f "$input" || continue
+
+ # Bison does not support pure-parser from command-line.
+ # Also, its support for %expect is generally broken.
+ # Work around these issues using a temporary file.
+
+ echo "... testing $input"
+ rm -f run_make.[coy]
+
+ case $input in
+ pure_*)
+ if test -z `fgrep -l '%pure-parser' $input`
+ then
+ echo "%pure-parser" >>run_make.y
+ fi
+ ;;
+ esac
+
+ sed -e '/^%expect/s,%expect.*,,' $input >>run_make.y
+
+ bison -y run_make.y
+ sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c
+
+ rm -f y.tab.c
+
+ input=run_make.c
+ object=run_make.o
+ if test -f $input
+ then
+ $MY_MAKE $object DEFINES='-DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=1 -DYYSTACK_USE_ALLOCA=0 -DYYMAXDEPTH=0'
+ else
+ echo "?? $input not found"
+ fi
+ rm -f run_make.[coy]
+ done
+fi
+
+YACC=
+for name in /usr/ccs/bin/yacc
+do
+ if test -f $name
+ then
+ YACC=$name
+ fi
done
+
+if test -n "$YACC"
+then
+ echo "** compare with $YACC"
+ for input in ${TEST_DIR}/*.y
+ do
+ test -f "$input" || continue
+
+ echo "... testing $input"
+ rm -f run_make.[coy]
+
+ case $input in
+ pure_*)
+ echo "... skipping $input"
+ continue;
+ ;;
+ *)
+ if fgrep '%pure-parser' $input >/dev/null ||
+ fgrep '%parse-param' $input >/dev/null ||
+ fgrep '%lex-param' $input >/dev/null ||
+ fgrep 'YYLEX_PARAM' $input >/dev/null
+ then
+ echo "... skipping $input"
+ continue;
+ fi
+ ;;
+ esac
+
+ sed -e '/^%expect/s,%expect.*,,' $input >>run_make.y
+
+ $YACC run_make.y
+ sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c
+
+ rm -f y.tab.c
+
+ input=run_make.c
+ object=run_make.o
+ if test -f $input
+ then
+ $MY_MAKE $object
+ else
+ echo "?? $input not found"
+ fi
+ rm -f run_make.[coy]
+ done
+fi
diff --git a/test/run_test.sh b/test/run_test.sh
index 59dbca0..ae8591b 100755
--- a/test/run_test.sh
+++ b/test/run_test.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $Id: run_test.sh,v 1.6 2010/06/08 08:53:38 tom Exp $
+# $Id: run_test.sh,v 1.8 2012/01/15 11:50:35 tom Exp $
# vi:ts=4 sw=4:
if test $# = 1
@@ -14,22 +14,24 @@ fi
YACC=$PROG_DIR/yacc
tmpfile=temp$$
+rm -f test-*
echo '** '`date`
-for i in ${TEST_DIR}/*.y
+for input in ${TEST_DIR}/*.y
do
- case $i in
+ case $input in
test*)
- echo "?? ignored $i"
+ echo "?? ignored $input"
;;
*)
- root=`basename $i .y`
+ root=`basename $input .y`
ROOT="test-$root"
prefix=${root}_
OPTS=
+ OPT2=
TYPE=".output .tab.c .tab.h"
- case $i in
+ case $input in
${TEST_DIR}/code_*)
OPTS="$OPTS -r"
TYPE="$TYPE .code.c"
@@ -39,34 +41,41 @@ do
OPTS="$OPTS -P"
prefix=`echo "$prefix" | sed -e 's/^pure_//'`
;;
+ ${TEST_DIR}/quote_*)
+ OPT2="-s"
+ ;;
esac
- $YACC $OPTS -v -d -p $prefix -b $ROOT $i
- for type in $TYPE
+ for opt2 in "" $OPT2
do
- REF=${TEST_DIR}/${root}${type}
- CMP=${ROOT}${type}
- if test ! -f $CMP ; then
- echo "...not found $CMP"
- continue
- fi
- sed -e s,$CMP,$REF, \
- -e /YYPATCH/d \
- -e 's,#line \([1-9][0-9]*\) "'$TEST_DIR'/,#line \1 ",' \
- < $CMP >$tmpfile \
- && mv $tmpfile $CMP
- if test ! -f $REF
- then
- mv $CMP $REF
- echo "...saved $REF"
- elif ( cmp -s $REF $CMP )
- then
- echo "...ok $REF"
- rm -f $CMP
- else
- echo "...diff $REF"
- diff -u $REF $CMP
- fi
+ $YACC $OPTS $opt2 -v -d -p $prefix -b $ROOT${opt2} $input
+ for type in $TYPE
+ do
+ REF=${TEST_DIR}/${root}${opt2}${type}
+ CMP=${ROOT}${opt2}${type}
+ if test ! -f $CMP
+ then
+ echo "...not found $CMP"
+ else
+ sed -e s,$CMP,$REF, \
+ -e /YYPATCH/d \
+ -e 's,#line \([1-9][0-9]*\) "'$TEST_DIR'/,#line \1 ",' \
+ < $CMP >$tmpfile \
+ && mv $tmpfile $CMP
+ if test ! -f $REF
+ then
+ mv $CMP $REF
+ echo "...saved $REF"
+ elif ( cmp -s $REF $CMP )
+ then
+ echo "...ok $REF"
+ rm -f $CMP
+ else
+ echo "...diff $REF"
+ diff -u $REF $CMP
+ fi
+ fi
+ done
done
;;
esac