summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-10-01 14:46:22 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-10-01 14:46:22 +0900
commit74fdfc49f1b98f7007cda639fa4bcb6b349a8a37 (patch)
treef9213deba0e82ac139381e1503a188a44ab5189f
parent372b8dfcdaf5efa7cc9e068843717e9621562c76 (diff)
downloadbyacc-74fdfc49f1b98f7007cda639fa4bcb6b349a8a37.tar.gz
byacc-74fdfc49f1b98f7007cda639fa4bcb6b349a8a37.tar.bz2
byacc-74fdfc49f1b98f7007cda639fa4bcb6b349a8a37.zip
Imported Upstream version 20101122upstream/20101122
-rw-r--r--CHANGES38
-rw-r--r--VERSION2
-rw-r--r--output.c8
-rw-r--r--package/byacc.spec4
-rw-r--r--package/debian/changelog6
-rw-r--r--reader.c64
-rw-r--r--test/calc1.output877
-rw-r--r--test/calc1.tab.c899
-rw-r--r--test/calc1.tab.h13
-rw-r--r--test/calc1.y301
-rw-r--r--test/calc2.tab.c2
-rw-r--r--test/calc2.y2
-rw-r--r--test/calc3.tab.c2
-rw-r--r--test/calc3.y2
-rw-r--r--test/ftp.tab.c10
-rw-r--r--test/ftp.y10
-rw-r--r--test/grammar.y4
17 files changed, 2186 insertions, 58 deletions
diff --git a/CHANGES b/CHANGES
index 3333eec..0e5bbb6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,35 @@
+2010-11-22 Thomas Dickey <tom@crayon>
+
+ * output.c:
+ add ifdef to guard against redefinition of YYSTYPE union (request by Clifford Yapp).
+
+ * test/calc1.tab.c: regen
+
+ * test/calc1.y: cleanup compiler warnings
+
+ * test/grammar.y: add "%expect"
+
+ * test/calc1.tab.h: regen
+
+ * test/calc1.output, test/calc1.tab.c, test/calc1.tab.h: RCS_BASE
+
+ * test/calc2.tab.c, test/calc3.tab.c: regen
+
+ * test/calc1.y:
+ advanced example from Steve Johnson's paper, uses unions
+
+ * test/calc3.y, test/calc2.y: init 'base', so examples can run
+
+ * test/ftp.tab.c, test/ftp.y: tweaks to compile with g++
+
+ * output.c: compensate for fix in reader.c
+
+ * reader.c:
+ add/use putc_both() and puts_both(), incidentally fixing a place where
+ a union copied to the union_file may be missing the end of the last line.
+
+ * package/debian/changelog, package/byacc.spec, VERSION: bump
+
2010-06-10 Thomas Dickey <tom@crayon>
* yacc.1, package/debian/changelog, package/byacc.spec, VERSION:
@@ -531,7 +563,7 @@
the VERSION file holds the patch-date. Define YYPATCH, so this will be
compiled into the skeleton.
- * VERSION: RCS_BASE
+ * VERSION: patch-level for byacc
* main.c:
add "-o" to usage message. It is too long for a single line; rewrite usage()
@@ -671,7 +703,9 @@
2000-11-20 Thomas Dickey <tom@crayon>
- * test/calc.y, test/code_calc.y, test/pure_calc.y: RCS_BASE
+ * test/calc.y: RCS_BASE
+
+ * test/code_calc.y, test/pure_calc.y: copy of calc.y
* vmsbuild.com: original version
diff --git a/VERSION b/VERSION
index 4474107..9981c77 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-20100610
+20101122
diff --git a/output.c b/output.c
index 73840f7..4495917 100644
--- a/output.c
+++ b/output.c
@@ -1,4 +1,4 @@
-/* $Id: output.c,v 1.29 2010/06/09 21:25:18 tom Exp $ */
+/* $Id: output.c,v 1.31 2010/11/23 01:45:45 tom Exp $ */
#include "defs.h"
@@ -841,9 +841,13 @@ output_defines(void)
if (dflag && unionized)
{
rewind(union_file);
+ fprintf(defines_file,
+ "#if !(defined(YYSTYPE) || defined(YYSTYPE_IS_DECLARED))\n");
while ((c = getc(union_file)) != EOF)
putc(c, defines_file);
- fprintf(defines_file, " YYSTYPE;\nextern YYSTYPE %slval;\n",
+ fprintf(defines_file,
+ "#endif /* !(YYSTYPE || YYSTYPE_IS_DECLARED) */\n");
+ fprintf(defines_file, "extern YYSTYPE %slval;\n",
symbol_prefix);
}
}
diff --git a/package/byacc.spec b/package/byacc.spec
index f1c970f..44cf75b 100644
--- a/package/byacc.spec
+++ b/package/byacc.spec
@@ -1,8 +1,8 @@
Summary: byacc - public domain Berkeley LALR Yacc parser generator
%define AppProgram byacc
-%define AppVersion 20100610
+%define AppVersion 20101122
%define UseProgram yacc
-# $XTermId: byacc.spec,v 1.2 2010/06/10 12:35:23 tom Exp $
+# $XTermId: byacc.spec,v 1.3 2010/11/22 13:20:54 tom Exp $
Name: %{AppProgram}
Version: %{AppVersion}
Release: 1
diff --git a/package/debian/changelog b/package/debian/changelog
index 0f5f92b..8fe1f34 100644
--- a/package/debian/changelog
+++ b/package/debian/changelog
@@ -1,3 +1,9 @@
+byacc (20101122) unstable; urgency=low
+
+ * fix for generated header to avoid symbol conflict
+
+ -- Thomas E. Dickey <dickey@invisible-island.net> Mon, 22 Nov 2010 08:21:23 -0500
+
byacc (20100610) unstable; urgency=low
* Add package scripts to upstream source, for test-builds.
diff --git a/reader.c b/reader.c
index 72ee01a..b0ac58b 100644
--- a/reader.c
+++ b/reader.c
@@ -1,4 +1,4 @@
-/* $Id: reader.c,v 1.26 2010/06/10 00:44:38 tom Exp $ */
+/* $Id: reader.c,v 1.27 2010/11/22 19:19:17 tom Exp $ */
#include "defs.h"
@@ -468,6 +468,22 @@ copy_text(void)
}
static void
+puts_both(const char *s)
+{
+ fputs(s, text_file);
+ if (dflag)
+ fputs(s, union_file);
+}
+
+static void
+putc_both(int c)
+{
+ putc(c, text_file);
+ if (dflag)
+ putc(c, union_file);
+}
+
+static void
copy_union(void)
{
int c;
@@ -484,16 +500,12 @@ copy_union(void)
if (!lflag)
fprintf(text_file, line_format, lineno, input_file_name);
- fprintf(text_file, "typedef union");
- if (dflag)
- fprintf(union_file, "typedef union");
+ puts_both("typedef union");
depth = 0;
loop:
c = *cptr++;
- putc(c, text_file);
- if (dflag)
- putc(c, union_file);
+ putc_both(c);
switch (c)
{
case '\n':
@@ -510,7 +522,7 @@ copy_union(void)
case R_CURL:
if (--depth == 0)
{
- fprintf(text_file, " YYSTYPE;\n");
+ puts_both(" YYSTYPE;\n");
FREE(u_line);
return;
}
@@ -527,9 +539,7 @@ copy_union(void)
for (;;)
{
c = *cptr++;
- putc(c, text_file);
- if (dflag)
- putc(c, union_file);
+ putc_both(c);
if (c == quote)
{
FREE(s_line);
@@ -540,9 +550,7 @@ copy_union(void)
if (c == '\\')
{
c = *cptr++;
- putc(c, text_file);
- if (dflag)
- putc(c, union_file);
+ putc_both(c);
if (c == '\n')
{
get_line();
@@ -557,27 +565,19 @@ copy_union(void)
c = *cptr;
if (c == '/')
{
- putc('*', text_file);
- if (dflag)
- putc('*', union_file);
+ putc_both('*');
while ((c = *++cptr) != '\n')
{
if (c == '*' && cptr[1] == '/')
{
- fprintf(text_file, "* ");
- if (dflag)
- fprintf(union_file, "* ");
+ puts_both("* ");
}
else
{
- putc(c, text_file);
- if (dflag)
- putc(c, union_file);
+ putc_both(c);
}
}
- fprintf(text_file, "*/\n");
- if (dflag)
- fprintf(union_file, "*/\n");
+ puts_both("*/\n");
goto next_line;
}
if (c == '*')
@@ -586,21 +586,15 @@ copy_union(void)
char *c_line = dup_line();
char *c_cptr = c_line + (cptr - line - 1);
- putc('*', text_file);
- if (dflag)
- putc('*', union_file);
+ putc_both('*');
++cptr;
for (;;)
{
c = *cptr++;
- putc(c, text_file);
- if (dflag)
- putc(c, union_file);
+ putc_both(c);
if (c == '*' && *cptr == '/')
{
- putc('/', text_file);
- if (dflag)
- putc('/', union_file);
+ putc_both('/');
++cptr;
FREE(c_line);
goto loop;
diff --git a/test/calc1.output b/test/calc1.output
new file mode 100644
index 0000000..2b628d4
--- /dev/null
+++ b/test/calc1.output
@@ -0,0 +1,877 @@
+ 0 $accept : line $end
+
+ 1 lines :
+ 2 | lines line
+
+ 3 line : dexp '\n'
+ 4 | vexp '\n'
+ 5 | DREG '=' dexp '\n'
+ 6 | VREG '=' vexp '\n'
+ 7 | error '\n'
+
+ 8 dexp : CONST
+ 9 | DREG
+ 10 | dexp '+' dexp
+ 11 | dexp '-' dexp
+ 12 | dexp '*' dexp
+ 13 | dexp '/' dexp
+ 14 | '-' dexp
+ 15 | '(' dexp ')'
+
+ 16 vexp : dexp
+ 17 | '(' dexp ',' dexp ')'
+ 18 | VREG
+ 19 | vexp '+' vexp
+ 20 | dexp '+' vexp
+ 21 | vexp '-' vexp
+ 22 | dexp '-' vexp
+ 23 | vexp '*' vexp
+ 24 | dexp '*' vexp
+ 25 | vexp '/' vexp
+ 26 | dexp '/' vexp
+ 27 | '-' vexp
+ 28 | '(' vexp ')'
+
+state 0
+ $accept : . line $end (0)
+
+ error shift 1
+ DREG shift 2
+ VREG shift 3
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ line goto 7
+ dexp goto 8
+ vexp goto 9
+
+
+state 1
+ line : error . '\n' (7)
+
+ '\n' shift 10
+ . error
+
+
+state 2
+ line : DREG . '=' dexp '\n' (5)
+ dexp : DREG . (9)
+
+ '=' shift 11
+ '+' reduce 9
+ '-' reduce 9
+ '*' reduce 9
+ '/' reduce 9
+ '\n' reduce 9
+
+
+state 3
+ line : VREG . '=' vexp '\n' (6)
+ vexp : VREG . (18)
+
+ '=' shift 12
+ '+' reduce 18
+ '-' reduce 18
+ '*' reduce 18
+ '/' reduce 18
+ '\n' reduce 18
+
+
+state 4
+ dexp : CONST . (8)
+
+ . reduce 8
+
+
+state 5
+ dexp : '-' . dexp (14)
+ vexp : '-' . vexp (27)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 15
+ vexp goto 16
+
+
+state 6
+ dexp : '(' . dexp ')' (15)
+ vexp : '(' . dexp ',' dexp ')' (17)
+ vexp : '(' . vexp ')' (28)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 17
+ vexp goto 18
+
+
+state 7
+ $accept : line . $end (0)
+
+ $end accept
+
+
+8: shift/reduce conflict (shift 19, reduce 16) on '+'
+8: shift/reduce conflict (shift 20, reduce 16) on '-'
+8: shift/reduce conflict (shift 21, reduce 16) on '*'
+8: shift/reduce conflict (shift 22, reduce 16) on '/'
+8: shift/reduce conflict (shift 23, reduce 16) on '\n'
+state 8
+ line : dexp . '\n' (3)
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ '+' shift 19
+ '-' shift 20
+ '*' shift 21
+ '/' shift 22
+ '\n' shift 23
+
+
+state 9
+ line : vexp . '\n' (4)
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '+' shift 24
+ '-' shift 25
+ '*' shift 26
+ '/' shift 27
+ '\n' shift 28
+ . error
+
+
+state 10
+ line : error '\n' . (7)
+
+ . reduce 7
+
+
+state 11
+ line : DREG '=' . dexp '\n' (5)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 31
+
+
+state 12
+ line : VREG '=' . vexp '\n' (6)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 32
+ vexp goto 33
+
+
+state 13
+ dexp : DREG . (9)
+
+ . reduce 9
+
+
+state 14
+ vexp : VREG . (18)
+
+ . reduce 18
+
+
+15: reduce/reduce conflict (reduce 14, reduce 16) on '+'
+15: reduce/reduce conflict (reduce 14, reduce 16) on '-'
+15: reduce/reduce conflict (reduce 14, reduce 16) on '*'
+15: reduce/reduce conflict (reduce 14, reduce 16) on '/'
+15: reduce/reduce conflict (reduce 14, reduce 16) on '\n'
+15: reduce/reduce conflict (reduce 14, reduce 16) on ')'
+state 15
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : '-' dexp . (14)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ . reduce 14
+
+
+state 16
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+ vexp : '-' vexp . (27)
+
+ . reduce 27
+
+
+17: shift/reduce conflict (shift 19, reduce 16) on '+'
+17: shift/reduce conflict (shift 20, reduce 16) on '-'
+17: shift/reduce conflict (shift 21, reduce 16) on '*'
+17: shift/reduce conflict (shift 22, reduce 16) on '/'
+17: shift/reduce conflict (shift 34, reduce 16) on ')'
+state 17
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : '(' dexp . ')' (15)
+ vexp : dexp . (16)
+ vexp : '(' dexp . ',' dexp ')' (17)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ '+' shift 19
+ '-' shift 20
+ '*' shift 21
+ '/' shift 22
+ ')' shift 34
+ ',' shift 35
+
+
+state 18
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+ vexp : '(' vexp . ')' (28)
+
+ '+' shift 24
+ '-' shift 25
+ '*' shift 26
+ '/' shift 27
+ ')' shift 36
+ . error
+
+
+state 19
+ dexp : dexp '+' . dexp (10)
+ vexp : dexp '+' . vexp (20)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 37
+ vexp goto 38
+
+
+state 20
+ dexp : dexp '-' . dexp (11)
+ vexp : dexp '-' . vexp (22)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 39
+ vexp goto 40
+
+
+state 21
+ dexp : dexp '*' . dexp (12)
+ vexp : dexp '*' . vexp (24)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 41
+ vexp goto 42
+
+
+state 22
+ dexp : dexp '/' . dexp (13)
+ vexp : dexp '/' . vexp (26)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 43
+ vexp goto 44
+
+
+state 23
+ line : dexp '\n' . (3)
+
+ . reduce 3
+
+
+state 24
+ vexp : vexp '+' . vexp (19)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 32
+ vexp goto 45
+
+
+state 25
+ vexp : vexp '-' . vexp (21)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 32
+ vexp goto 46
+
+
+state 26
+ vexp : vexp '*' . vexp (23)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 32
+ vexp goto 47
+
+
+state 27
+ vexp : vexp '/' . vexp (25)
+
+ DREG shift 13
+ VREG shift 14
+ CONST shift 4
+ '-' shift 5
+ '(' shift 6
+ . error
+
+ dexp goto 32
+ vexp goto 48
+
+
+state 28
+ line : vexp '\n' . (4)
+
+ . reduce 4
+
+
+state 29
+ dexp : '-' . dexp (14)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 49
+
+
+state 30
+ dexp : '(' . dexp ')' (15)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 50
+
+
+state 31
+ line : DREG '=' dexp . '\n' (5)
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+
+ '+' shift 51
+ '-' shift 52
+ '*' shift 53
+ '/' shift 54
+ '\n' shift 55
+ . error
+
+
+32: shift/reduce conflict (shift 19, reduce 16) on '+'
+32: shift/reduce conflict (shift 20, reduce 16) on '-'
+32: shift/reduce conflict (shift 21, reduce 16) on '*'
+32: shift/reduce conflict (shift 22, reduce 16) on '/'
+state 32
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ '+' shift 19
+ '-' shift 20
+ '*' shift 21
+ '/' shift 22
+ '\n' reduce 16
+ ')' reduce 16
+
+
+state 33
+ line : VREG '=' vexp . '\n' (6)
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '+' shift 24
+ '-' shift 25
+ '*' shift 26
+ '/' shift 27
+ '\n' shift 56
+ . error
+
+
+state 34
+ dexp : '(' dexp ')' . (15)
+
+ . reduce 15
+
+
+state 35
+ vexp : '(' dexp ',' . dexp ')' (17)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 57
+
+
+state 36
+ vexp : '(' vexp ')' . (28)
+
+ . reduce 28
+
+
+37: reduce/reduce conflict (reduce 10, reduce 16) on '+'
+37: reduce/reduce conflict (reduce 10, reduce 16) on '-'
+37: shift/reduce conflict (shift 21, reduce 16) on '*'
+37: shift/reduce conflict (shift 22, reduce 16) on '/'
+37: reduce/reduce conflict (reduce 10, reduce 16) on '\n'
+37: reduce/reduce conflict (reduce 10, reduce 16) on ')'
+state 37
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp '+' dexp . (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ '*' shift 21
+ '/' shift 22
+ '+' reduce 10
+ '-' reduce 10
+ '\n' reduce 10
+ ')' reduce 10
+ ',' reduce 10
+
+
+state 38
+ vexp : vexp . '+' vexp (19)
+ vexp : dexp '+' vexp . (20)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '*' shift 26
+ '/' shift 27
+ '+' reduce 20
+ '-' reduce 20
+ '\n' reduce 20
+ ')' reduce 20
+
+
+39: reduce/reduce conflict (reduce 11, reduce 16) on '+'
+39: reduce/reduce conflict (reduce 11, reduce 16) on '-'
+39: shift/reduce conflict (shift 21, reduce 16) on '*'
+39: shift/reduce conflict (shift 22, reduce 16) on '/'
+39: reduce/reduce conflict (reduce 11, reduce 16) on '\n'
+39: reduce/reduce conflict (reduce 11, reduce 16) on ')'
+state 39
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp '-' dexp . (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ '*' shift 21
+ '/' shift 22
+ '+' reduce 11
+ '-' reduce 11
+ '\n' reduce 11
+ ')' reduce 11
+ ',' reduce 11
+
+
+state 40
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : dexp '-' vexp . (22)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '*' shift 26
+ '/' shift 27
+ '+' reduce 22
+ '-' reduce 22
+ '\n' reduce 22
+ ')' reduce 22
+
+
+41: reduce/reduce conflict (reduce 12, reduce 16) on '+'
+41: reduce/reduce conflict (reduce 12, reduce 16) on '-'
+41: reduce/reduce conflict (reduce 12, reduce 16) on '*'
+41: reduce/reduce conflict (reduce 12, reduce 16) on '/'
+41: reduce/reduce conflict (reduce 12, reduce 16) on '\n'
+41: reduce/reduce conflict (reduce 12, reduce 16) on ')'
+state 41
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp '*' dexp . (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ . reduce 12
+
+
+state 42
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : dexp '*' vexp . (24)
+ vexp : vexp . '/' vexp (25)
+
+ . reduce 24
+
+
+43: reduce/reduce conflict (reduce 13, reduce 16) on '+'
+43: reduce/reduce conflict (reduce 13, reduce 16) on '-'
+43: reduce/reduce conflict (reduce 13, reduce 16) on '*'
+43: reduce/reduce conflict (reduce 13, reduce 16) on '/'
+43: reduce/reduce conflict (reduce 13, reduce 16) on '\n'
+43: reduce/reduce conflict (reduce 13, reduce 16) on ')'
+state 43
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : dexp '/' dexp . (13)
+ vexp : dexp . (16)
+ vexp : dexp . '+' vexp (20)
+ vexp : dexp . '-' vexp (22)
+ vexp : dexp . '*' vexp (24)
+ vexp : dexp . '/' vexp (26)
+
+ . reduce 13
+
+
+state 44
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+ vexp : dexp '/' vexp . (26)
+
+ . reduce 26
+
+
+state 45
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp '+' vexp . (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '*' shift 26
+ '/' shift 27
+ '+' reduce 19
+ '-' reduce 19
+ '\n' reduce 19
+ ')' reduce 19
+
+
+state 46
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp '-' vexp . (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+
+ '*' shift 26
+ '/' shift 27
+ '+' reduce 21
+ '-' reduce 21
+ '\n' reduce 21
+ ')' reduce 21
+
+
+state 47
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp '*' vexp . (23)
+ vexp : vexp . '/' vexp (25)
+
+ . reduce 23
+
+
+state 48
+ vexp : vexp . '+' vexp (19)
+ vexp : vexp . '-' vexp (21)
+ vexp : vexp . '*' vexp (23)
+ vexp : vexp . '/' vexp (25)
+ vexp : vexp '/' vexp . (25)
+
+ . reduce 25
+
+
+state 49
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : '-' dexp . (14)
+
+ . reduce 14
+
+
+state 50
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : '(' dexp . ')' (15)
+
+ '+' shift 51
+ '-' shift 52
+ '*' shift 53
+ '/' shift 54
+ ')' shift 34
+ . error
+
+
+state 51
+ dexp : dexp '+' . dexp (10)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 58
+
+
+state 52
+ dexp : dexp '-' . dexp (11)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 59
+
+
+state 53
+ dexp : dexp '*' . dexp (12)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 60
+
+
+state 54
+ dexp : dexp '/' . dexp (13)
+
+ DREG shift 13
+ CONST shift 4
+ '-' shift 29
+ '(' shift 30
+ . error
+
+ dexp goto 61
+
+
+state 55
+ line : DREG '=' dexp '\n' . (5)
+
+ . reduce 5
+
+
+state 56
+ line : VREG '=' vexp '\n' . (6)
+
+ . reduce 6
+
+
+state 57
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ vexp : '(' dexp ',' dexp . ')' (17)
+
+ '+' shift 51
+ '-' shift 52
+ '*' shift 53
+ '/' shift 54
+ ')' shift 62
+ . error
+
+
+state 58
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp '+' dexp . (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+
+ '*' shift 53
+ '/' shift 54
+ '+' reduce 10
+ '-' reduce 10
+ '\n' reduce 10
+ ')' reduce 10
+
+
+state 59
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp '-' dexp . (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+
+ '*' shift 53
+ '/' shift 54
+ '+' reduce 11
+ '-' reduce 11
+ '\n' reduce 11
+ ')' reduce 11
+
+
+state 60
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp '*' dexp . (12)
+ dexp : dexp . '/' dexp (13)
+
+ . reduce 12
+
+
+state 61
+ dexp : dexp . '+' dexp (10)
+ dexp : dexp . '-' dexp (11)
+ dexp : dexp . '*' dexp (12)
+ dexp : dexp . '/' dexp (13)
+ dexp : dexp '/' dexp . (13)
+
+ . reduce 13
+
+
+state 62
+ vexp : '(' dexp ',' dexp ')' . (17)
+
+ . reduce 17
+
+
+Rules never reduced:
+ lines : (1)
+ lines : lines line (2)
+
+
+State 8 contains 5 shift/reduce conflicts.
+State 15 contains 6 reduce/reduce conflicts.
+State 17 contains 5 shift/reduce conflicts.
+State 32 contains 4 shift/reduce conflicts.
+State 37 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts.
+State 39 contains 2 shift/reduce conflicts, 4 reduce/reduce conflicts.
+State 41 contains 6 reduce/reduce conflicts.
+State 43 contains 6 reduce/reduce conflicts.
+
+
+15 terminals, 5 nonterminals
+29 grammar rules, 63 states
diff --git a/test/calc1.tab.c b/test/calc1.tab.c
new file mode 100644
index 0000000..28b45cc
--- /dev/null
+++ b/test/calc1.tab.c
@@ -0,0 +1,899 @@
+#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 calc1_parse
+#endif /* yyparse */
+
+#ifndef yylex
+#define yylex calc1_lex
+#endif /* yylex */
+
+#ifndef yyerror
+#define yyerror calc1_error
+#endif /* yyerror */
+
+#ifndef yychar
+#define yychar calc1_char
+#endif /* yychar */
+
+#ifndef yyval
+#define yyval calc1_val
+#endif /* yyval */
+
+#ifndef yylval
+#define yylval calc1_lval
+#endif /* yylval */
+
+#ifndef yydebug
+#define yydebug calc1_debug
+#endif /* yydebug */
+
+#ifndef yynerrs
+#define yynerrs calc1_nerrs
+#endif /* yynerrs */
+
+#ifndef yyerrflag
+#define yyerrflag calc1_errflag
+#endif /* yyerrflag */
+
+#ifndef yylhs
+#define yylhs calc1_lhs
+#endif /* yylhs */
+
+#ifndef yylen
+#define yylen calc1_len
+#endif /* yylen */
+
+#ifndef yydefred
+#define yydefred calc1_defred
+#endif /* yydefred */
+
+#ifndef yydgoto
+#define yydgoto calc1_dgoto
+#endif /* yydgoto */
+
+#ifndef yysindex
+#define yysindex calc1_sindex
+#endif /* yysindex */
+
+#ifndef yyrindex
+#define yyrindex calc1_rindex
+#endif /* yyrindex */
+
+#ifndef yygindex
+#define yygindex calc1_gindex
+#endif /* yygindex */
+
+#ifndef yytable
+#define yytable calc1_table
+#endif /* yytable */
+
+#ifndef yycheck
+#define yycheck calc1_check
+#endif /* yycheck */
+
+#ifndef yyname
+#define yyname calc1_name
+#endif /* yyname */
+
+#ifndef yyrule
+#define yyrule calc1_rule
+#endif /* yyrule */
+#define YYPREFIX "calc1_"
+
+#define YYPURE 0
+
+#line 2 "calc1.y"
+
+/* http://dinosaur.compilertools.net/yacc/index.html */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+
+typedef struct interval
+{
+ double lo, hi;
+}
+INTERVAL;
+
+INTERVAL vmul(double, double, INTERVAL);
+INTERVAL vdiv(double, double, INTERVAL);
+int dcheck(INTERVAL);
+
+double dreg[26];
+INTERVAL vreg[26];
+
+#line 27 "calc1.y"
+typedef union
+{
+ int ival;
+ double dval;
+ INTERVAL vval;
+} YYSTYPE;
+#line 128 "calc1.tab.c"
+/* 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
+
+extern int YYPARSE_DECL();
+extern int YYLEX_DECL();
+
+#define DREG 257
+#define VREG 258
+#define CONST 259
+#define UMINUS 260
+#define YYERRCODE 256
+static const short calc1_lhs[] = { -1,
+ 3, 3, 0, 0, 0, 0, 0, 1, 1, 1,
+ 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2,
+};
+static const short calc1_len[] = { 2,
+ 0, 2, 2, 2, 4, 4, 2, 1, 1, 3,
+ 3, 3, 3, 2, 3, 1, 5, 1, 3, 3,
+ 3, 3, 3, 3, 3, 3, 2, 3,
+};
+static const short calc1_defred[] = { 0,
+ 0, 0, 0, 8, 0, 0, 0, 0, 0, 7,
+ 0, 0, 9, 18, 14, 27, 0, 0, 0, 0,
+ 0, 0, 3, 0, 0, 0, 0, 4, 0, 0,
+ 0, 0, 0, 15, 0, 28, 0, 0, 0, 0,
+ 12, 24, 13, 26, 0, 0, 23, 25, 14, 0,
+ 0, 0, 0, 0, 5, 6, 0, 0, 0, 12,
+ 13, 17,
+};
+static const short calc1_dgoto[] = { 7,
+ 32, 9, 0,
+};
+static const short calc1_sindex[] = { -40,
+ -8, -48, -47, 0, -37, -37, 0, 2, 17, 0,
+ -34, -37, 0, 0, 0, 0, -25, 90, -37, -37,
+ -37, -37, 0, -37, -37, -37, -37, 0, -34, -34,
+ 25, 125, 31, 0, -34, 0, -11, 37, -11, 37,
+ 0, 0, 0, 0, 37, 37, 0, 0, 0, 111,
+ -34, -34, -34, -34, 0, 0, 118, 69, 69, 0,
+ 0, 0,
+};
+static const short calc1_rindex[] = { 0,
+ 0, 38, 44, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, -9, 0, 0, 0, 0, 51, -3, 56, 61,
+ 0, 0, 0, 0, 67, 72, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 78, 83, 0,
+ 0, 0,
+};
+static const short calc1_gindex[] = { 0,
+ 4, 124, 0,
+};
+#define YYTABLESIZE 225
+static const short calc1_table[] = { 6,
+ 16, 10, 6, 8, 5, 30, 20, 5, 15, 17,
+ 29, 23, 11, 12, 31, 34, 21, 19, 35, 20,
+ 0, 22, 37, 39, 41, 43, 28, 0, 0, 0,
+ 21, 16, 49, 50, 55, 22, 0, 20, 57, 20,
+ 56, 20, 0, 21, 19, 0, 20, 9, 22, 0,
+ 0, 0, 0, 18, 58, 59, 60, 61, 26, 24,
+ 10, 25, 0, 27, 0, 11, 53, 51, 0, 52,
+ 22, 54, 26, 24, 0, 25, 19, 27, 26, 9,
+ 9, 21, 9, 27, 9, 18, 18, 10, 18, 0,
+ 18, 10, 11, 10, 10, 10, 11, 0, 11, 11,
+ 11, 22, 0, 22, 0, 22, 0, 19, 0, 19,
+ 53, 19, 21, 0, 21, 54, 21, 0, 10, 0,
+ 10, 0, 10, 11, 0, 11, 0, 11, 16, 18,
+ 36, 26, 24, 0, 25, 33, 27, 0, 0, 0,
+ 0, 0, 38, 40, 42, 44, 0, 45, 46, 47,
+ 48, 34, 53, 51, 0, 52, 0, 54, 62, 53,
+ 51, 0, 52, 0, 54, 0, 21, 19, 0, 20,
+ 0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 2, 3, 4, 13,
+ 14, 4, 13, 0, 4,
+};
+static const short calc1_check[] = { 40,
+ 10, 10, 40, 0, 45, 40, 10, 45, 5, 6,
+ 45, 10, 61, 61, 11, 41, 42, 43, 44, 45,
+ -1, 47, 19, 20, 21, 22, 10, -1, -1, -1,
+ 42, 41, 29, 30, 10, 47, -1, 41, 35, 43,
+ 10, 45, -1, 42, 43, -1, 45, 10, 47, -1,
+ -1, -1, -1, 10, 51, 52, 53, 54, 42, 43,
+ 10, 45, -1, 47, -1, 10, 42, 43, -1, 45,
+ 10, 47, 42, 43, -1, 45, 10, 47, 42, 42,
+ 43, 10, 45, 47, 47, 42, 43, 10, 45, -1,
+ 47, 41, 10, 43, 44, 45, 41, -1, 43, 44,
+ 45, 41, -1, 43, -1, 45, -1, 41, -1, 43,
+ 42, 45, 41, -1, 43, 47, 45, -1, 41, -1,
+ 43, -1, 45, 41, -1, 43, -1, 45, 5, 6,
+ 41, 42, 43, -1, 45, 12, 47, -1, -1, -1,
+ -1, -1, 19, 20, 21, 22, -1, 24, 25, 26,
+ 27, 41, 42, 43, -1, 45, -1, 47, 41, 42,
+ 43, -1, 45, -1, 47, -1, 42, 43, -1, 45,
+ -1, 47, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -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, 257, 258, 259, 257,
+ 258, 259, 257, -1, 259,
+};
+#define YYFINAL 7
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 260
+#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,
+0,0,"DREG","VREG","CONST","UMINUS",
+};
+static const char *yyrule[] = {
+"$accept : line",
+"lines :",
+"lines : lines line",
+"line : dexp '\\n'",
+"line : vexp '\\n'",
+"line : DREG '=' dexp '\\n'",
+"line : VREG '=' vexp '\\n'",
+"line : error '\\n'",
+"dexp : CONST",
+"dexp : DREG",
+"dexp : dexp '+' dexp",
+"dexp : dexp '-' dexp",
+"dexp : dexp '*' dexp",
+"dexp : dexp '/' dexp",
+"dexp : '-' dexp",
+"dexp : '(' dexp ')'",
+"vexp : dexp",
+"vexp : '(' dexp ',' dexp ')'",
+"vexp : VREG",
+"vexp : vexp '+' vexp",
+"vexp : dexp '+' vexp",
+"vexp : vexp '-' vexp",
+"vexp : dexp '-' vexp",
+"vexp : vexp '*' vexp",
+"vexp : dexp '*' vexp",
+"vexp : vexp '/' vexp",
+"vexp : dexp '/' vexp",
+"vexp : '-' vexp",
+"vexp : '(' vexp ')'",
+
+};
+#endif
+/* 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
+
+int yydebug;
+int yynerrs;
+
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ short *s_last;
+ YYSTYPE *l_base;
+ YYSTYPE *l_mark;
+} YYSTACKDATA;
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
+/* variables for the parser stack */
+static YYSTACKDATA yystack;
+#line 172 "calc1.y"
+ /* beginning of subroutines section */
+
+#define BSZ 50 /* buffer size for floating point numbers */
+
+ /* lexical analysis */
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ int c;
+
+ while ((c = getchar()) == ' ')
+ { /* skip over blanks */
+ }
+
+ if (isupper(c))
+ {
+ yylval.ival = c - 'A';
+ return (VREG);
+ }
+ if (islower(c))
+ {
+ yylval.ival = c - 'a';
+ return (DREG);
+ }
+
+ if (isdigit(c) || c == '.')
+ {
+ /* gobble up digits, points, exponents */
+ char buf[BSZ + 1], *cp = buf;
+ int dot = 0, exp = 0;
+
+ for (; (cp - buf) < BSZ; ++cp, c = getchar())
+ {
+
+ *cp = c;
+ if (isdigit(c))
+ continue;
+ if (c == '.')
+ {
+ if (dot++ || exp)
+ return ('.'); /* will cause syntax error */
+ continue;
+ }
+
+ if (c == 'e')
+ {
+ if (exp++)
+ return ('e'); /* will cause syntax error */
+ continue;
+ }
+
+ /* end of number */
+ break;
+ }
+ *cp = '\0';
+
+ if ((cp - buf) >= BSZ)
+ printf("constant too long: truncated\n");
+ else
+ ungetc(c, stdin); /* push back last char read */
+ yylval.dval = atof(buf);
+ return (CONST);
+ }
+ return (c);
+}
+
+static INTERVAL
+hilo(double a, double b, double c, double d)
+{
+ /* returns the smallest interval containing a, b, c, and d */
+ /* used by *, / routines */
+ INTERVAL v;
+
+ if (a > b)
+ {
+ v.hi = a;
+ v.lo = b;
+ }
+ else
+ {
+ v.hi = b;
+ v.lo = a;
+ }
+
+ if (c > d)
+ {
+ if (c > v.hi)
+ v.hi = c;
+ if (d < v.lo)
+ v.lo = d;
+ }
+ else
+ {
+ if (d > v.hi)
+ v.hi = d;
+ if (c < v.lo)
+ v.lo = c;
+ }
+ return (v);
+}
+
+INTERVAL
+vmul(double a, double b, INTERVAL v)
+{
+ return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo));
+}
+
+int
+dcheck(INTERVAL v)
+{
+ if (v.hi >= 0. && v.lo <= 0.)
+ {
+ printf("divisor interval contains 0.\n");
+ return (1);
+ }
+ return (0);
+}
+
+INTERVAL
+vdiv(double a, double b, INTERVAL v)
+{
+ return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
+}
+#line 466 "calc1.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 = (data->s_base != 0)
+ ? (short *)realloc(data->s_base, newsize * sizeof(*newss))
+ : (short *)malloc(newsize * sizeof(*newss));
+ if (newss == 0)
+ return -1;
+
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (data->l_base != 0)
+ ? (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs))
+ : (YYSTYPE *)malloc(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 53 "calc1.y"
+ {
+ (void) printf("%15.8f\n", yystack.l_mark[-1].dval);
+ }
+break;
+case 4:
+#line 57 "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 61 "calc1.y"
+ {
+ dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval;
+ }
+break;
+case 6:
+#line 65 "calc1.y"
+ {
+ vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval;
+ }
+break;
+case 7:
+#line 69 "calc1.y"
+ {
+ yyerrok;
+ }
+break;
+case 9:
+#line 76 "calc1.y"
+ {
+ yyval.dval = dreg[yystack.l_mark[0].ival];
+ }
+break;
+case 10:
+#line 80 "calc1.y"
+ {
+ yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval;
+ }
+break;
+case 11:
+#line 84 "calc1.y"
+ {
+ yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval;
+ }
+break;
+case 12:
+#line 88 "calc1.y"
+ {
+ yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval;
+ }
+break;
+case 13:
+#line 92 "calc1.y"
+ {
+ yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval;
+ }
+break;
+case 14:
+#line 96 "calc1.y"
+ {
+ yyval.dval = -yystack.l_mark[0].dval;
+ }
+break;
+case 15:
+#line 100 "calc1.y"
+ {
+ yyval.dval = yystack.l_mark[-1].dval;
+ }
+break;
+case 16:
+#line 106 "calc1.y"
+ {
+ yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval;
+ }
+break;
+case 17:
+#line 110 "calc1.y"
+ {
+ yyval.vval.lo = yystack.l_mark[-3].dval;
+ yyval.vval.hi = yystack.l_mark[-1].dval;
+ if ( yyval.vval.lo > yyval.vval.hi )
+ {
+ (void) printf("interval out of order\n");
+ YYERROR;
+ }
+ }
+break;
+case 18:
+#line 120 "calc1.y"
+ {
+ yyval.vval = vreg[yystack.l_mark[0].ival];
+ }
+break;
+case 19:
+#line 124 "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 129 "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 134 "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 139 "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 144 "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 148 "calc1.y"
+ {
+ yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
+ }
+break;
+case 25:
+#line 152 "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 157 "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 162 "calc1.y"
+ {
+ yyval.vval.hi = -yystack.l_mark[0].vval.lo;
+ yyval.vval.lo = -yystack.l_mark[0].vval.hi;
+ }
+break;
+case 28:
+#line 167 "calc1.y"
+ {
+ yyval.vval = yystack.l_mark[-1].vval;
+ }
+break;
+#line 839 "calc1.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/calc1.tab.h b/test/calc1.tab.h
new file mode 100644
index 0000000..38927d5
--- /dev/null
+++ b/test/calc1.tab.h
@@ -0,0 +1,13 @@
+#define DREG 257
+#define VREG 258
+#define CONST 259
+#define UMINUS 260
+#if !(defined(YYSTYPE) || defined(YYSTYPE_IS_DECLARED))
+typedef union
+{
+ int ival;
+ double dval;
+ INTERVAL vval;
+} YYSTYPE;
+#endif /* !(YYSTYPE || YYSTYPE_IS_DECLARED) */
+extern YYSTYPE calc1_lval;
diff --git a/test/calc1.y b/test/calc1.y
new file mode 100644
index 0000000..2c0e55d
--- /dev/null
+++ b/test/calc1.y
@@ -0,0 +1,301 @@
+%{
+
+/* http://dinosaur.compilertools.net/yacc/index.html */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+
+typedef struct interval
+{
+ double lo, hi;
+}
+INTERVAL;
+
+INTERVAL vmul(double, double, INTERVAL);
+INTERVAL vdiv(double, double, INTERVAL);
+int dcheck(INTERVAL);
+
+double dreg[26];
+INTERVAL vreg[26];
+
+%}
+%expect 18
+
+%start line
+%union
+{
+ int ival;
+ double dval;
+ INTERVAL vval;
+}
+
+%token <ival> DREG VREG /* indices into dreg, vreg arrays */
+%token <dval> CONST /* floating point constant */
+
+%type <dval> dexp /* expression */
+%type <vval> vexp /* interval expression */
+
+ /* precedence information about the operators */
+
+%left '+' '-'
+%left '*' '/'
+%left UMINUS /* precedence for unary minus */
+
+%% /* beginning of rules section */
+
+lines : /* empty */
+ | lines line
+ ;
+
+line : dexp '\n'
+ {
+ (void) printf("%15.8f\n", $1);
+ }
+ | vexp '\n'
+ {
+ (void) printf("(%15.8f, %15.8f)\n", $1.lo, $1.hi);
+ }
+ | DREG '=' dexp '\n'
+ {
+ dreg[$1] = $3;
+ }
+ | VREG '=' vexp '\n'
+ {
+ vreg[$1] = $3;
+ }
+ | error '\n'
+ {
+ yyerrok;
+ }
+ ;
+
+dexp : CONST
+ | DREG
+ {
+ $$ = dreg[$1];
+ }
+ | dexp '+' dexp
+ {
+ $$ = $1 + $3;
+ }
+ | dexp '-' dexp
+ {
+ $$ = $1 - $3;
+ }
+ | dexp '*' dexp
+ {
+ $$ = $1 * $3;
+ }
+ | dexp '/' dexp
+ {
+ $$ = $1 / $3;
+ }
+ | '-' dexp %prec UMINUS
+ {
+ $$ = -$2;
+ }
+ | '(' dexp ')'
+ {
+ $$ = $2;
+ }
+ ;
+
+vexp : dexp
+ {
+ $$.hi = $$.lo = $1;
+ }
+ | '(' dexp ',' dexp ')'
+ {
+ $$.lo = $2;
+ $$.hi = $4;
+ if ( $$.lo > $$.hi )
+ {
+ (void) printf("interval out of order\n");
+ YYERROR;
+ }
+ }
+ | VREG
+ {
+ $$ = vreg[$1];
+ }
+ | vexp '+' vexp
+ {
+ $$.hi = $1.hi + $3.hi;
+ $$.lo = $1.lo + $3.lo;
+ }
+ | dexp '+' vexp
+ {
+ $$.hi = $1 + $3.hi;
+ $$.lo = $1 + $3.lo;
+ }
+ | vexp '-' vexp
+ {
+ $$.hi = $1.hi - $3.lo;
+ $$.lo = $1.lo - $3.hi;
+ }
+ | dexp '-' vexp
+ {
+ $$.hi = $1 - $3.lo;
+ $$.lo = $1 - $3.hi;
+ }
+ | vexp '*' vexp
+ {
+ $$ = vmul( $1.lo, $1.hi, $3 );
+ }
+ | dexp '*' vexp
+ {
+ $$ = vmul ($1, $1, $3 );
+ }
+ | vexp '/' vexp
+ {
+ if (dcheck($3)) YYERROR;
+ $$ = vdiv ( $1.lo, $1.hi, $3 );
+ }
+ | dexp '/' vexp
+ {
+ if (dcheck ( $3 )) YYERROR;
+ $$ = vdiv ($1, $1, $3 );
+ }
+ | '-' vexp %prec UMINUS
+ {
+ $$.hi = -$2.lo;
+ $$.lo = -$2.hi;
+ }
+ | '(' vexp ')'
+ {
+ $$ = $2;
+ }
+ ;
+
+%% /* beginning of subroutines section */
+
+#define BSZ 50 /* buffer size for floating point numbers */
+
+ /* lexical analysis */
+
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
+}
+
+int
+yylex(void)
+{
+ int c;
+
+ while ((c = getchar()) == ' ')
+ { /* skip over blanks */
+ }
+
+ if (isupper(c))
+ {
+ yylval.ival = c - 'A';
+ return (VREG);
+ }
+ if (islower(c))
+ {
+ yylval.ival = c - 'a';
+ return (DREG);
+ }
+
+ if (isdigit(c) || c == '.')
+ {
+ /* gobble up digits, points, exponents */
+ char buf[BSZ + 1], *cp = buf;
+ int dot = 0, exp = 0;
+
+ for (; (cp - buf) < BSZ; ++cp, c = getchar())
+ {
+
+ *cp = c;
+ if (isdigit(c))
+ continue;
+ if (c == '.')
+ {
+ if (dot++ || exp)
+ return ('.'); /* will cause syntax error */
+ continue;
+ }
+
+ if (c == 'e')
+ {
+ if (exp++)
+ return ('e'); /* will cause syntax error */
+ continue;
+ }
+
+ /* end of number */
+ break;
+ }
+ *cp = '\0';
+
+ if ((cp - buf) >= BSZ)
+ printf("constant too long: truncated\n");
+ else
+ ungetc(c, stdin); /* push back last char read */
+ yylval.dval = atof(buf);
+ return (CONST);
+ }
+ return (c);
+}
+
+static INTERVAL
+hilo(double a, double b, double c, double d)
+{
+ /* returns the smallest interval containing a, b, c, and d */
+ /* used by *, / routines */
+ INTERVAL v;
+
+ if (a > b)
+ {
+ v.hi = a;
+ v.lo = b;
+ }
+ else
+ {
+ v.hi = b;
+ v.lo = a;
+ }
+
+ if (c > d)
+ {
+ if (c > v.hi)
+ v.hi = c;
+ if (d < v.lo)
+ v.lo = d;
+ }
+ else
+ {
+ if (d > v.hi)
+ v.hi = d;
+ if (c < v.lo)
+ v.lo = c;
+ }
+ return (v);
+}
+
+INTERVAL
+vmul(double a, double b, INTERVAL v)
+{
+ return (hilo(a * v.hi, a * v.lo, b * v.hi, b * v.lo));
+}
+
+int
+dcheck(INTERVAL v)
+{
+ if (v.hi >= 0. && v.lo <= 0.)
+ {
+ printf("divisor interval contains 0.\n");
+ return (1);
+ }
+ return (0);
+}
+
+INTERVAL
+vdiv(double a, double b, INTERVAL v)
+{
+ return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
+}
diff --git a/test/calc2.tab.c b/test/calc2.tab.c
index 1be4d2d..8a33361 100644
--- a/test/calc2.tab.c
+++ b/test/calc2.tab.c
@@ -294,7 +294,7 @@ int
main (void)
{
int regs[26];
- int base;
+ int base = 10;
while(!feof(stdin)) {
yyparse(regs, &base);
diff --git a/test/calc2.y b/test/calc2.y
index 393a38e..9bce132 100644
--- a/test/calc2.y
+++ b/test/calc2.y
@@ -68,7 +68,7 @@ int
main (void)
{
int regs[26];
- int base;
+ int base = 10;
while(!feof(stdin)) {
yyparse(regs, &base);
diff --git a/test/calc3.tab.c b/test/calc3.tab.c
index f3d3ee6..b0a6b56 100644
--- a/test/calc3.tab.c
+++ b/test/calc3.tab.c
@@ -287,7 +287,7 @@ int
main (void)
{
int regs[26];
- int base;
+ int base = 10;
while(!feof(stdin)) {
yyparse(regs, &base);
diff --git a/test/calc3.y b/test/calc3.y
index 4ce1773..efca5eb 100644
--- a/test/calc3.y
+++ b/test/calc3.y
@@ -70,7 +70,7 @@ int
main (void)
{
int regs[26];
- int base;
+ int base = 10;
while(!feof(stdin)) {
yyparse(regs, &base);
diff --git a/test/ftp.tab.c b/test/ftp.tab.c
index 3f07436..93be71a 100644
--- a/test/ftp.tab.c
+++ b/test/ftp.tab.c
@@ -140,7 +140,7 @@ extern char tmpline[];
extern char **glob(char *);
extern char *renamefrom(char *);
extern void cwd(const char *);
-extern void delete(const char *);
+
extern void dologout(int);
extern void fatal(const char *);
extern void makedir(const char *);
@@ -167,7 +167,7 @@ static int cmd_bytesz;
char cbuf[512];
char *fromname;
-extern char *index(const char *, int);
+
static char * copy(const char *);
@@ -735,7 +735,7 @@ yylex(void)
if (strncasecmp(cbuf, "PASS", 4) != 0)
setproctitle("%s: %s", proctitle, cbuf);
#endif /* SETPROCTITLE */
- if ((cp = index(cbuf, '\r'))) {
+ if ((cp = strchr(cbuf, '\r'))) {
*cp++ = '\n';
*cp = '\0';
}
@@ -947,7 +947,7 @@ copy(const char *s)
{
char *p;
- p = malloc((unsigned) strlen(s) + 1);
+ p = (char * )malloc(strlen(s) + 1);
if (p == 0)
fatal("Ran out of memory.");
else
@@ -1464,7 +1464,7 @@ case 22:
#line 285 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
- delete((char *) yystack.l_mark[-1]);
+ remove((char *) yystack.l_mark[-1]);
if (yystack.l_mark[-1] != 0)
free((char *) yystack.l_mark[-1]);
}
diff --git a/test/ftp.y b/test/ftp.y
index 6ef70c2..c9b27bd 100644
--- a/test/ftp.y
+++ b/test/ftp.y
@@ -67,7 +67,7 @@ extern char tmpline[];
extern char **glob(char *);
extern char *renamefrom(char *);
extern void cwd(const char *);
-extern void delete(const char *);
+
extern void dologout(int);
extern void fatal(const char *);
extern void makedir(const char *);
@@ -94,7 +94,7 @@ static int cmd_bytesz;
char cbuf[512];
char *fromname;
-extern char *index(const char *, int);
+
static char * copy(const char *);
@@ -284,7 +284,7 @@ cmd: USER SP username CRLF
| DELE check_login SP pathname CRLF
= {
if ($2 && $4 != 0)
- delete((char *) $4);
+ remove((char *) $4);
if ($4 != 0)
free((char *) $4);
}
@@ -880,7 +880,7 @@ yylex(void)
if (strncasecmp(cbuf, "PASS", 4) != 0)
setproctitle("%s: %s", proctitle, cbuf);
#endif /* SETPROCTITLE */
- if ((cp = index(cbuf, '\r'))) {
+ if ((cp = strchr(cbuf, '\r'))) {
*cp++ = '\n';
*cp = '\0';
}
@@ -1092,7 +1092,7 @@ copy(const char *s)
{
char *p;
- p = malloc((unsigned) strlen(s) + 1);
+ p = (char * )malloc(strlen(s) + 1);
if (p == 0)
fatal("Ran out of memory.");
else
diff --git a/test/grammar.y b/test/grammar.y
index d28f6b8..3b0176a 100644
--- a/test/grammar.y
+++ b/test/grammar.y
@@ -1,10 +1,10 @@
-/* $Id: grammar.y,v 1.2 2010/06/08 22:31:28 tom Exp $
+/* $Id: grammar.y,v 1.3 2010/11/23 01:28:47 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
%token <text> '(' '*' '&'
/* identifiers that are not reserved words */
T_IDENTIFIER T_TYPEDEF_NAME T_DEFINE_NAME