Import byacc 20170201.
This commit is contained in:
parent
af7e34d5cb
commit
8992b86776
30
CHANGES
30
CHANGES
@ -1,3 +1,33 @@
|
||||
2017-02-01 Thomas E. Dickey <dickey@invisible-island.net>
|
||||
|
||||
* test/btyacc/expr.oxout.error, test/btyacc/expr.oxout.output, test/btyacc/expr.oxout.tab.c, test/btyacc/expr.oxout.tab.h, test/yacc/expr.oxout.error, test/yacc/expr.oxout.output, test/yacc/expr.oxout.tab.c, test/yacc/expr.oxout.tab.h:
|
||||
RCS_BASE
|
||||
|
||||
* package/debian/copyright: update copyright
|
||||
|
||||
* reader.c, defs.h, main.c:
|
||||
avoid using regex.h since some low-end platforms do not have this
|
||||
|
||||
* test/expr.oxout.y: RCS_BASE
|
||||
|
||||
* configure: regen
|
||||
|
||||
* aclocal.m4: quiet a strict gcc warning in CF_MKSTEMP
|
||||
|
||||
2017-02-01 Tom.Shields
|
||||
|
||||
* main.c, reader.c, defs.h:
|
||||
process #line directives, like bison and flex
|
||||
|
||||
2017-02-01 Thomas E. Dickey <dickey@invisible-island.net>
|
||||
|
||||
* VERSION, package/byacc.spec, package/debian/changelog, package/mingw-byacc.spec, package/pkgsrc/Makefile:
|
||||
bump
|
||||
|
||||
2016-12-31 Thomas E. Dickey <dickey@invisible-island.net>
|
||||
|
||||
* config.guess, config.sub: 2017-01-01
|
||||
|
||||
2016-12-02 Thomas E. Dickey <dickey@invisible-island.net>
|
||||
|
||||
* test/btyacc/quote_calc4-s.tab.c, test/btyacc/varsyntax_calc1.tab.c, test/btyacc/error.tab.c, test/btyacc/grammar.tab.c, test/btyacc/inherit0.tab.c, test/btyacc/inherit1.tab.c, test/btyacc/inherit2.tab.c, test/btyacc/ok_syntax1.tab.c, test/btyacc/pure_calc.tab.c, test/btyacc/pure_error.tab.c, test/btyacc/quote_calc-s.tab.c, test/btyacc/quote_calc.tab.c, test/btyacc/quote_calc2-s.tab.c, test/btyacc/quote_calc2.tab.c, test/btyacc/quote_calc3-s.tab.c, test/btyacc/quote_calc3.tab.c, test/btyacc/quote_calc4.tab.c, test/btyacc/calc.tab.c, test/btyacc/calc1.tab.c, test/btyacc/calc2.tab.c, test/btyacc/calc3.tab.c, test/btyacc/code_calc.code.c, test/btyacc/code_error.code.c, test/btyacc/empty.tab.c, test/btyacc/err_inherit3.tab.c, test/btyacc/err_inherit4.tab.c, test/btyacc/err_syntax10.tab.c, test/btyacc/err_syntax11.tab.c, test/btyacc/err_syntax12.tab.c, test/btyacc/err_syntax18.tab.c, test/btyacc/err_syntax20.tab.c, test/btyacc/rename_debug.c, test/btyacc/btyacc_calc1.tab.c, test/btyacc/btyacc_demo.tab.c, test/btyacc/btyacc_destroy1.tab.c, test/btyacc/btyacc_destroy2.tab.c, test/btyacc/btyacc_destroy3.tab.c, btyaccpar.c:
|
||||
|
30
MANIFEST
30
MANIFEST
@ -1,4 +1,4 @@
|
||||
MANIFEST for byacc-20161202, version t20161202
|
||||
MANIFEST for byacc-20170201, version t20170201
|
||||
--------------------------------------------------------------------------------
|
||||
MANIFEST this file
|
||||
ACKNOWLEDGEMENTS original version of byacc - 1993
|
||||
@ -77,6 +77,22 @@ test/btyacc/btyacc_demo.error reference output for testing
|
||||
test/btyacc/btyacc_demo.output reference output for testing
|
||||
test/btyacc/btyacc_demo.tab.c reference output for testing
|
||||
test/btyacc/btyacc_demo.tab.h reference output for testing
|
||||
test/btyacc/btyacc_demo2.error reference output for testing
|
||||
test/btyacc/btyacc_demo2.output reference output for testing
|
||||
test/btyacc/btyacc_demo2.tab.c reference output for testing
|
||||
test/btyacc/btyacc_demo2.tab.h reference output for testing
|
||||
test/btyacc/btyacc_destroy1.error reference output for testing
|
||||
test/btyacc/btyacc_destroy1.output reference output for testing
|
||||
test/btyacc/btyacc_destroy1.tab.c reference output for testing
|
||||
test/btyacc/btyacc_destroy1.tab.h reference output for testing
|
||||
test/btyacc/btyacc_destroy2.error reference output for testing
|
||||
test/btyacc/btyacc_destroy2.output reference output for testing
|
||||
test/btyacc/btyacc_destroy2.tab.c reference output for testing
|
||||
test/btyacc/btyacc_destroy2.tab.h reference output for testing
|
||||
test/btyacc/btyacc_destroy3.error reference output for testing
|
||||
test/btyacc/btyacc_destroy3.output reference output for testing
|
||||
test/btyacc/btyacc_destroy3.tab.c reference output for testing
|
||||
test/btyacc/btyacc_destroy3.tab.h reference output for testing
|
||||
test/btyacc/calc.error reference output for testing
|
||||
test/btyacc/calc.output reference output for testing
|
||||
test/btyacc/calc.tab.c reference output for testing
|
||||
@ -256,6 +272,10 @@ test/btyacc/error.error reference output for testing
|
||||
test/btyacc/error.output reference output for testing
|
||||
test/btyacc/error.tab.c reference output for testing
|
||||
test/btyacc/error.tab.h reference output for testing
|
||||
test/btyacc/expr.oxout.error reference output for testing
|
||||
test/btyacc/expr.oxout.output reference output for testing
|
||||
test/btyacc/expr.oxout.tab.c reference output for testing
|
||||
test/btyacc/expr.oxout.tab.h reference output for testing
|
||||
test/btyacc/grammar.dot reference output for testing
|
||||
test/btyacc/grammar.error reference output for testing
|
||||
test/btyacc/grammar.output reference output for testing
|
||||
@ -359,6 +379,9 @@ test/btyacc/varsyntax_calc1.tab.h reference output for testing
|
||||
test subdirectory
|
||||
test/btyacc_calc1.y testcase for btyacc
|
||||
test/btyacc_demo.y testcase for btyacc
|
||||
test/btyacc_destroy1.y btyacc test-case for %parse-param
|
||||
test/btyacc_destroy2.y btyacc test-case for %parse-param
|
||||
test/btyacc_destroy3.y btyacc test-case for %parse-param
|
||||
test/calc.y example from VMS freeware version of byacc
|
||||
test/calc1.y advanced example from Steve Johnson's paper.
|
||||
test/calc2.y test-cases and reference files for %lex-param / %parse-param
|
||||
@ -403,6 +426,7 @@ test/err_syntax8.y testcase for used_reserved()
|
||||
test/err_syntax8a.y testcase for used_reserved()
|
||||
test/err_syntax9.y testcase for tokenized_start()
|
||||
test/error.y original version of byacc - 1993
|
||||
test/expr.oxout.y test-case for "#line" feature
|
||||
test/grammar.y grammar from cproto
|
||||
test/inherit0.y testcase for btyacc
|
||||
test/inherit1.y testcase for btyacc
|
||||
@ -577,6 +601,10 @@ test/yacc/error.error reference output for testing
|
||||
test/yacc/error.output reference output for testing
|
||||
test/yacc/error.tab.c reference output for testing
|
||||
test/yacc/error.tab.h reference output for testing
|
||||
test/yacc/expr.oxout.error reference output for testing
|
||||
test/yacc/expr.oxout.output reference output for testing
|
||||
test/yacc/expr.oxout.tab.c reference output for testing
|
||||
test/yacc/expr.oxout.tab.h reference output for testing
|
||||
test/yacc/grammar.dot reference output for testing
|
||||
test/yacc/grammar.error reference output for testing
|
||||
test/yacc/grammar.output reference output for testing
|
||||
|
14
aclocal.m4
vendored
14
aclocal.m4
vendored
@ -1,7 +1,7 @@
|
||||
dnl $Id: aclocal.m4,v 1.41 2016/12/02 13:03:06 tom Exp $
|
||||
dnl $Id: aclocal.m4,v 1.42 2017/02/01 10:12:21 tom Exp $
|
||||
dnl Macros for byacc configure script (Thomas E. Dickey)
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Copyright 2004-2015,2016 Thomas E. Dickey
|
||||
dnl Copyright 2004-2016,2017 Thomas E. Dickey
|
||||
dnl
|
||||
dnl Permission is hereby granted, free of charge, to any person obtaining a
|
||||
dnl copy of this software and associated documentation files (the
|
||||
@ -803,20 +803,26 @@ fi
|
||||
test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
|
||||
])dnl
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl CF_MKSTEMP version: 9 updated: 2012/10/03 04:34:49
|
||||
dnl CF_MKSTEMP version: 10 updated: 2017/01/21 11:12:16
|
||||
dnl ----------
|
||||
dnl Check for a working mkstemp. This creates two files, checks that they are
|
||||
dnl successfully created and distinct (AmigaOS apparently fails on the last).
|
||||
AC_DEFUN([CF_MKSTEMP],[
|
||||
AC_CHECK_HEADERS( \
|
||||
unistd.h \
|
||||
)
|
||||
AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
|
||||
rm -rf conftest*
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
int main()
|
||||
int main(void)
|
||||
{
|
||||
char *tmpl = "conftestXXXXXX";
|
||||
char name[2][80];
|
||||
|
6
config.guess
vendored
6
config.guess
vendored
@ -1,8 +1,8 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright 1992-2016 Free Software Foundation, Inc.
|
||||
# Copyright 1992-2017 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2016-10-02'
|
||||
timestamp='2017-01-01'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@ -50,7 +50,7 @@ version="\
|
||||
GNU config.guess ($timestamp)
|
||||
|
||||
Originally written by Per Bothner.
|
||||
Copyright 1992-2016 Free Software Foundation, Inc.
|
||||
Copyright 1992-2017 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
|
11
config.sub
vendored
11
config.sub
vendored
@ -1,8 +1,8 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright 1992-2016 Free Software Foundation, Inc.
|
||||
# Copyright 1992-2017 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2016-11-19'
|
||||
timestamp='2017-01-01'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@ -67,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
|
||||
version="\
|
||||
GNU config.sub ($timestamp)
|
||||
|
||||
Copyright 1992-2016 Free Software Foundation, Inc.
|
||||
Copyright 1992-2017 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
@ -1409,7 +1409,7 @@ case $os in
|
||||
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
|
||||
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
|
||||
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
|
||||
| -onefs* | -tirtos* | -phoenix* | -fuchsia*)
|
||||
| -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-qnx*)
|
||||
@ -1638,6 +1638,9 @@ case $basic_machine in
|
||||
sparc-* | *-sun)
|
||||
os=-sunos4.1.1
|
||||
;;
|
||||
pru-*)
|
||||
os=-elf
|
||||
;;
|
||||
*-be)
|
||||
os=-beos
|
||||
;;
|
||||
|
3
defs.h
3
defs.h
@ -1,4 +1,4 @@
|
||||
/* $Id: defs.h,v 1.54 2016/12/02 19:27:56 tom Exp $ */
|
||||
/* $Id: defs.h,v 1.56 2017/02/02 00:44:38 tom Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
@ -313,6 +313,7 @@ extern const char *const trailer[];
|
||||
|
||||
extern char *code_file_name;
|
||||
extern char *input_file_name;
|
||||
extern size_t input_file_name_len;
|
||||
extern char *defines_file_name;
|
||||
extern char *externs_file_name;
|
||||
|
||||
|
11
main.c
11
main.c
@ -1,4 +1,4 @@
|
||||
/* $Id: main.c,v 1.57 2016/12/02 18:44:44 tom Exp $ */
|
||||
/* $Id: main.c,v 1.59 2017/02/02 00:44:38 tom Exp $ */
|
||||
|
||||
#include <signal.h>
|
||||
#ifndef _WIN32
|
||||
@ -48,13 +48,13 @@ const char *myname = "yacc";
|
||||
int lineno;
|
||||
int outline;
|
||||
|
||||
static char empty_string[] = "";
|
||||
static char default_file_prefix[] = "y";
|
||||
|
||||
static char *file_prefix = default_file_prefix;
|
||||
|
||||
char *code_file_name;
|
||||
char *input_file_name = empty_string;
|
||||
char *input_file_name;
|
||||
size_t input_file_name_len = 0;
|
||||
char *defines_file_name;
|
||||
char *externs_file_name;
|
||||
|
||||
@ -381,7 +381,10 @@ getargs(int argc, char *argv[])
|
||||
no_more_options:;
|
||||
if (i + 1 != argc)
|
||||
usage();
|
||||
input_file_name = argv[i];
|
||||
input_file_name_len = strlen(argv[i]);
|
||||
input_file_name = TMALLOC(char, input_file_name_len + 1);
|
||||
NO_SPACE(input_file_name);
|
||||
strcpy(input_file_name, argv[i]);
|
||||
}
|
||||
|
||||
void *
|
||||
|
@ -1,8 +1,8 @@
|
||||
Summary: byacc - public domain Berkeley LALR Yacc parser generator
|
||||
%define AppProgram byacc
|
||||
%define AppVersion 20161202
|
||||
%define AppVersion 20170201
|
||||
%define UseProgram yacc
|
||||
# $XTermId: byacc.spec,v 1.32 2016/12/02 12:58:46 tom Exp $
|
||||
# $XTermId: byacc.spec,v 1.33 2017/02/01 09:55:04 tom Exp $
|
||||
Name: %{AppProgram}
|
||||
Version: %{AppVersion}
|
||||
Release: 1
|
||||
|
@ -1,3 +1,9 @@
|
||||
byacc (20170201) unstable; urgency=low
|
||||
|
||||
* maintenance updates
|
||||
|
||||
-- Thomas E. Dickey <dickey@invisible-island.net> Wed, 01 Feb 2017 04:55:04 -0500
|
||||
|
||||
byacc (20161202) unstable; urgency=low
|
||||
|
||||
* maintenance updates
|
||||
|
@ -36,7 +36,7 @@ skeleton.c with the bug report. Do not expect rapid responses.
|
||||
|
||||
Files: aclocal.m4
|
||||
Licence: other-BSD
|
||||
Copyright: 2004-2015,2016 by Thomas E. Dickey
|
||||
Copyright: 2004-2016,2017 by Thomas E. Dickey
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
|
@ -1,8 +1,8 @@
|
||||
Summary: byacc - public domain Berkeley LALR Yacc parser generator
|
||||
%define AppProgram byacc
|
||||
%define AppVersion 20161202
|
||||
%define AppVersion 20170201
|
||||
%define UseProgram yacc
|
||||
# $XTermId: mingw-byacc.spec,v 1.14 2016/12/02 12:58:46 tom Exp $
|
||||
# $XTermId: mingw-byacc.spec,v 1.15 2017/02/01 09:55:04 tom Exp $
|
||||
Name: %{AppProgram}
|
||||
Version: %{AppVersion}
|
||||
Release: 1
|
||||
|
@ -1,7 +1,7 @@
|
||||
# $NetBSD: Makefile,v 1.9 2008/07/24 17:13:00 tonnerre Exp $
|
||||
#
|
||||
|
||||
DISTNAME= byacc-20161202
|
||||
DISTNAME= byacc-20170201
|
||||
PKGREVISION= 1
|
||||
CATEGORIES= devel
|
||||
MASTER_SITES= ftp://invisible-island.net/byacc/
|
||||
|
200
reader.c
200
reader.c
@ -1,4 +1,4 @@
|
||||
/* $Id: reader.c,v 1.66 2016/12/02 20:14:34 tom Exp $ */
|
||||
/* $Id: reader.c,v 1.68 2017/02/02 01:05:36 tom Exp $ */
|
||||
|
||||
#include "defs.h"
|
||||
|
||||
@ -108,6 +108,134 @@ cachec(int c)
|
||||
++cinc;
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ldSPC1,
|
||||
ldSPC2,
|
||||
ldNAME,
|
||||
ldSPC3,
|
||||
ldNUM,
|
||||
ldSPC4,
|
||||
ldFILE,
|
||||
ldOK,
|
||||
ldERR
|
||||
}
|
||||
LINE_DIR;
|
||||
|
||||
/*
|
||||
* Expect this pattern:
|
||||
* /^[[:space:]]*#[[:space:]]*
|
||||
* line[[:space:]]+
|
||||
* [[:digit:]]+
|
||||
* ([[:space:]]*|[[:space:]]+"[^"]+")/
|
||||
*/
|
||||
static int
|
||||
line_directive(void)
|
||||
{
|
||||
#define UNLESS(what) if (what) { ld = ldERR; break; }
|
||||
int n;
|
||||
int line_1st = -1;
|
||||
int name_1st = -1;
|
||||
int name_end = -1;
|
||||
LINE_DIR ld = ldSPC1;
|
||||
for (n = 0; (ld <= ldOK) && (line[n] != '\0'); ++n)
|
||||
{
|
||||
int ch = UCH(line[n]);
|
||||
switch (ld)
|
||||
{
|
||||
case ldSPC1:
|
||||
if (isspace(ch))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
UNLESS(ch != '#');
|
||||
ld = ldSPC2;
|
||||
break;
|
||||
case ldSPC2:
|
||||
if (isspace(ch))
|
||||
{
|
||||
break;
|
||||
}
|
||||
/* FALLTHRU */
|
||||
case ldNAME:
|
||||
UNLESS(strncmp(line + n, "line", 4));
|
||||
n += 4;
|
||||
if (line[n] == '\0')
|
||||
{
|
||||
ld = ldOK;
|
||||
break;
|
||||
}
|
||||
else
|
||||
UNLESS(!isspace(UCH(line[n])));
|
||||
ld = ldSPC3;
|
||||
break;
|
||||
case ldSPC3:
|
||||
if (isspace(ch))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
UNLESS(!isdigit(ch));
|
||||
line_1st = n;
|
||||
ld = ldNUM;
|
||||
/* FALLTHRU */
|
||||
case ldNUM:
|
||||
if (isdigit(ch))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
UNLESS(!isspace(ch));
|
||||
ld = ldSPC4;
|
||||
break;
|
||||
case ldSPC4:
|
||||
if (isspace(ch))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
UNLESS(ch != '"');
|
||||
UNLESS(line[n + 1] == '"');
|
||||
ld = ldFILE;
|
||||
name_1st = n;
|
||||
break;
|
||||
case ldFILE:
|
||||
if (ch != '"')
|
||||
{
|
||||
break;
|
||||
}
|
||||
ld = ldOK;
|
||||
name_end = n;
|
||||
/* FALLTHRU */
|
||||
case ldERR:
|
||||
case ldOK:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ld == ldOK)
|
||||
{
|
||||
size_t need = (size_t) (name_end - name_1st);
|
||||
if (need > input_file_name_len)
|
||||
{
|
||||
input_file_name_len = need;
|
||||
input_file_name = TREALLOC(char, input_file_name, need + 1);
|
||||
NO_SPACE(input_file_name);
|
||||
}
|
||||
memcpy(input_file_name, line + name_1st + 1, need - 1);
|
||||
input_file_name[need - 1] = '\0';
|
||||
}
|
||||
|
||||
if (ld >= ldNUM && ld < ldERR)
|
||||
{
|
||||
lineno = (int)strtol(line + line_1st, NULL, 10) - 1;
|
||||
}
|
||||
|
||||
return (ld == ldOK);
|
||||
#undef UNLESS
|
||||
}
|
||||
|
||||
static void
|
||||
get_line(void)
|
||||
{
|
||||
@ -115,49 +243,53 @@ get_line(void)
|
||||
int c;
|
||||
int i;
|
||||
|
||||
if (saw_eof || (c = getc(f)) == EOF)
|
||||
do
|
||||
{
|
||||
if (line)
|
||||
if (saw_eof || (c = getc(f)) == EOF)
|
||||
{
|
||||
FREE(line);
|
||||
line = 0;
|
||||
if (line)
|
||||
{
|
||||
FREE(line);
|
||||
line = 0;
|
||||
}
|
||||
cptr = 0;
|
||||
saw_eof = 1;
|
||||
return;
|
||||
}
|
||||
cptr = 0;
|
||||
saw_eof = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (line == NULL || linesize != (LINESIZE + 1))
|
||||
{
|
||||
if (line)
|
||||
FREE(line);
|
||||
linesize = LINESIZE + 1;
|
||||
line = TMALLOC(char, linesize);
|
||||
NO_SPACE(line);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
++lineno;
|
||||
for (;;)
|
||||
{
|
||||
line[i++] = (char)c;
|
||||
if (c == '\n')
|
||||
break;
|
||||
if ((i + 3) >= linesize)
|
||||
if (line == NULL || linesize != (LINESIZE + 1))
|
||||
{
|
||||
linesize += LINESIZE;
|
||||
line = TREALLOC(char, line, linesize);
|
||||
if (line)
|
||||
FREE(line);
|
||||
linesize = LINESIZE + 1;
|
||||
line = TMALLOC(char, linesize);
|
||||
NO_SPACE(line);
|
||||
}
|
||||
c = getc(f);
|
||||
if (c == EOF)
|
||||
|
||||
i = 0;
|
||||
++lineno;
|
||||
for (;;)
|
||||
{
|
||||
line[i++] = '\n';
|
||||
saw_eof = 1;
|
||||
break;
|
||||
line[i++] = (char)c;
|
||||
if (c == '\n')
|
||||
break;
|
||||
if ((i + 3) >= linesize)
|
||||
{
|
||||
linesize += LINESIZE;
|
||||
line = TREALLOC(char, line, linesize);
|
||||
NO_SPACE(line);
|
||||
}
|
||||
c = getc(f);
|
||||
if (c == EOF)
|
||||
{
|
||||
line[i++] = '\n';
|
||||
saw_eof = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
line[i] = '\0';
|
||||
}
|
||||
line[i] = '\0';
|
||||
while (line_directive());
|
||||
cptr = line;
|
||||
return;
|
||||
}
|
||||
|
1
test/btyacc/expr.oxout.error
Normal file
1
test/btyacc/expr.oxout.error
Normal file
@ -0,0 +1 @@
|
||||
YACC: w - line 6 of "expr.Y", the precedence of '*' has been redeclared
|
227
test/btyacc/expr.oxout.output
Normal file
227
test/btyacc/expr.oxout.output
Normal file
@ -0,0 +1,227 @@
|
||||
0 $accept : yyyAugNonterm $end
|
||||
|
||||
1 $$1 :
|
||||
|
||||
2 yyyAugNonterm : $$1 s
|
||||
|
||||
3 s : expr
|
||||
|
||||
4 expr : expr '*' expr
|
||||
5 | expr '+' expr
|
||||
6 | expr '/' expr
|
||||
7 | expr '-' expr
|
||||
8 | '(' expr ')'
|
||||
9 | ID
|
||||
10 | CONST
|
||||
|
||||
state 0
|
||||
$accept : . yyyAugNonterm $end (0)
|
||||
$$1 : . (1)
|
||||
|
||||
. reduce 1
|
||||
|
||||
yyyAugNonterm goto 1
|
||||
$$1 goto 2
|
||||
|
||||
|
||||
state 1
|
||||
$accept : yyyAugNonterm . $end (0)
|
||||
|
||||
$end accept
|
||||
|
||||
|
||||
state 2
|
||||
yyyAugNonterm : $$1 . s (2)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
s goto 6
|
||||
expr goto 7
|
||||
|
||||
|
||||
state 3
|
||||
expr : ID . (9)
|
||||
|
||||
. reduce 9
|
||||
|
||||
|
||||
state 4
|
||||
expr : CONST . (10)
|
||||
|
||||
. reduce 10
|
||||
|
||||
|
||||
state 5
|
||||
expr : '(' . expr ')' (8)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
expr goto 8
|
||||
|
||||
|
||||
state 6
|
||||
yyyAugNonterm : $$1 s . (2)
|
||||
|
||||
. reduce 2
|
||||
|
||||
|
||||
state 7
|
||||
s : expr . (3)
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr . '-' expr (7)
|
||||
|
||||
'+' shift 9
|
||||
'-' shift 10
|
||||
'*' shift 11
|
||||
'/' shift 12
|
||||
$end reduce 3
|
||||
|
||||
|
||||
state 8
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr . '-' expr (7)
|
||||
expr : '(' expr . ')' (8)
|
||||
|
||||
'+' shift 9
|
||||
'-' shift 10
|
||||
'*' shift 11
|
||||
'/' shift 12
|
||||
')' shift 13
|
||||
. error
|
||||
|
||||
|
||||
state 9
|
||||
expr : expr '+' . expr (5)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
expr goto 14
|
||||
|
||||
|
||||
state 10
|
||||
expr : expr '-' . expr (7)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
expr goto 15
|
||||
|
||||
|
||||
state 11
|
||||
expr : expr '*' . expr (4)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
expr goto 16
|
||||
|
||||
|
||||
state 12
|
||||
expr : expr '/' . expr (6)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
expr goto 17
|
||||
|
||||
|
||||
state 13
|
||||
expr : '(' expr ')' . (8)
|
||||
|
||||
. reduce 8
|
||||
|
||||
|
||||
state 14
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr '+' expr . (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr . '-' expr (7)
|
||||
|
||||
'*' shift 11
|
||||
'/' shift 12
|
||||
$end reduce 5
|
||||
'+' reduce 5
|
||||
'-' reduce 5
|
||||
')' reduce 5
|
||||
|
||||
|
||||
state 15
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr . '-' expr (7)
|
||||
expr : expr '-' expr . (7)
|
||||
|
||||
'*' shift 11
|
||||
'/' shift 12
|
||||
$end reduce 7
|
||||
'+' reduce 7
|
||||
'-' reduce 7
|
||||
')' reduce 7
|
||||
|
||||
|
||||
state 16
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr '*' expr . (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr . '-' expr (7)
|
||||
|
||||
. reduce 4
|
||||
|
||||
|
||||
state 17
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr '/' expr . (6)
|
||||
expr : expr . '-' expr (7)
|
||||
|
||||
'*' shift 11
|
||||
$end reduce 6
|
||||
'+' reduce 6
|
||||
'-' reduce 6
|
||||
'/' reduce 6
|
||||
')' reduce 6
|
||||
|
||||
|
||||
10 terminals, 5 nonterminals
|
||||
11 grammar rules, 18 states
|
||||
|
||||
grammar parser grammar
|
||||
symbol# value# symbol
|
||||
0 0 $end
|
||||
1 256 error
|
||||
2 257 ID
|
||||
3 258 CONST
|
||||
4 43 '+'
|
||||
5 45 '-'
|
||||
6 42 '*'
|
||||
7 47 '/'
|
||||
8 40 '('
|
||||
9 41 ')'
|
||||
10 259 $accept
|
||||
11 260 yyyAugNonterm
|
||||
12 261 s
|
||||
13 262 $$1
|
||||
14 263 expr
|
2752
test/btyacc/expr.oxout.tab.c
Normal file
2752
test/btyacc/expr.oxout.tab.c
Normal file
File diff suppressed because it is too large
Load Diff
20
test/btyacc/expr.oxout.tab.h
Normal file
20
test/btyacc/expr.oxout.tab.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef _expr.oxout__defines_h_
|
||||
#define _expr.oxout__defines_h_
|
||||
|
||||
#define ID 257
|
||||
#define CONST 258
|
||||
#ifdef YYSTYPE
|
||||
#undef YYSTYPE_IS_DECLARED
|
||||
#define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
#ifndef YYSTYPE_IS_DECLARED
|
||||
#define YYSTYPE_IS_DECLARED 1
|
||||
typedef union {
|
||||
struct yyyOxAttrbs {
|
||||
struct yyyStackItem *yyyOxStackItem;
|
||||
} yyyOxAttrbs;
|
||||
} YYSTYPE;
|
||||
#endif /* !YYSTYPE_IS_DECLARED */
|
||||
extern YYSTYPE expr.oxout_lval;
|
||||
|
||||
#endif /* _expr.oxout__defines_h_ */
|
1446
test/expr.oxout.y
Normal file
1446
test/expr.oxout.y
Normal file
File diff suppressed because it is too large
Load Diff
1
test/yacc/expr.oxout.error
Normal file
1
test/yacc/expr.oxout.error
Normal file
@ -0,0 +1 @@
|
||||
YACC: w - line 6 of "expr.Y", the precedence of '*' has been redeclared
|
209
test/yacc/expr.oxout.output
Normal file
209
test/yacc/expr.oxout.output
Normal file
@ -0,0 +1,209 @@
|
||||
0 $accept : yyyAugNonterm $end
|
||||
|
||||
1 $$1 :
|
||||
|
||||
2 yyyAugNonterm : $$1 s
|
||||
|
||||
3 s : expr
|
||||
|
||||
4 expr : expr '*' expr
|
||||
5 | expr '+' expr
|
||||
6 | expr '/' expr
|
||||
7 | expr '-' expr
|
||||
8 | '(' expr ')'
|
||||
9 | ID
|
||||
10 | CONST
|
||||
|
||||
state 0
|
||||
$accept : . yyyAugNonterm $end (0)
|
||||
$$1 : . (1)
|
||||
|
||||
. reduce 1
|
||||
|
||||
yyyAugNonterm goto 1
|
||||
$$1 goto 2
|
||||
|
||||
|
||||
state 1
|
||||
$accept : yyyAugNonterm . $end (0)
|
||||
|
||||
$end accept
|
||||
|
||||
|
||||
state 2
|
||||
yyyAugNonterm : $$1 . s (2)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
s goto 6
|
||||
expr goto 7
|
||||
|
||||
|
||||
state 3
|
||||
expr : ID . (9)
|
||||
|
||||
. reduce 9
|
||||
|
||||
|
||||
state 4
|
||||
expr : CONST . (10)
|
||||
|
||||
. reduce 10
|
||||
|
||||
|
||||
state 5
|
||||
expr : '(' . expr ')' (8)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
expr goto 8
|
||||
|
||||
|
||||
state 6
|
||||
yyyAugNonterm : $$1 s . (2)
|
||||
|
||||
. reduce 2
|
||||
|
||||
|
||||
state 7
|
||||
s : expr . (3)
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr . '-' expr (7)
|
||||
|
||||
'+' shift 9
|
||||
'-' shift 10
|
||||
'*' shift 11
|
||||
'/' shift 12
|
||||
$end reduce 3
|
||||
|
||||
|
||||
state 8
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr . '-' expr (7)
|
||||
expr : '(' expr . ')' (8)
|
||||
|
||||
'+' shift 9
|
||||
'-' shift 10
|
||||
'*' shift 11
|
||||
'/' shift 12
|
||||
')' shift 13
|
||||
. error
|
||||
|
||||
|
||||
state 9
|
||||
expr : expr '+' . expr (5)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
expr goto 14
|
||||
|
||||
|
||||
state 10
|
||||
expr : expr '-' . expr (7)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
expr goto 15
|
||||
|
||||
|
||||
state 11
|
||||
expr : expr '*' . expr (4)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
expr goto 16
|
||||
|
||||
|
||||
state 12
|
||||
expr : expr '/' . expr (6)
|
||||
|
||||
ID shift 3
|
||||
CONST shift 4
|
||||
'(' shift 5
|
||||
. error
|
||||
|
||||
expr goto 17
|
||||
|
||||
|
||||
state 13
|
||||
expr : '(' expr ')' . (8)
|
||||
|
||||
. reduce 8
|
||||
|
||||
|
||||
state 14
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr '+' expr . (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr . '-' expr (7)
|
||||
|
||||
'*' shift 11
|
||||
'/' shift 12
|
||||
$end reduce 5
|
||||
'+' reduce 5
|
||||
'-' reduce 5
|
||||
')' reduce 5
|
||||
|
||||
|
||||
state 15
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr . '-' expr (7)
|
||||
expr : expr '-' expr . (7)
|
||||
|
||||
'*' shift 11
|
||||
'/' shift 12
|
||||
$end reduce 7
|
||||
'+' reduce 7
|
||||
'-' reduce 7
|
||||
')' reduce 7
|
||||
|
||||
|
||||
state 16
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr '*' expr . (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr . '-' expr (7)
|
||||
|
||||
. reduce 4
|
||||
|
||||
|
||||
state 17
|
||||
expr : expr . '*' expr (4)
|
||||
expr : expr . '+' expr (5)
|
||||
expr : expr . '/' expr (6)
|
||||
expr : expr '/' expr . (6)
|
||||
expr : expr . '-' expr (7)
|
||||
|
||||
'*' shift 11
|
||||
$end reduce 6
|
||||
'+' reduce 6
|
||||
'-' reduce 6
|
||||
'/' reduce 6
|
||||
')' reduce 6
|
||||
|
||||
|
||||
10 terminals, 5 nonterminals
|
||||
11 grammar rules, 18 states
|
1958
test/yacc/expr.oxout.tab.c
Normal file
1958
test/yacc/expr.oxout.tab.c
Normal file
File diff suppressed because it is too large
Load Diff
15
test/yacc/expr.oxout.tab.h
Normal file
15
test/yacc/expr.oxout.tab.h
Normal file
@ -0,0 +1,15 @@
|
||||
#define ID 257
|
||||
#define CONST 258
|
||||
#ifdef YYSTYPE
|
||||
#undef YYSTYPE_IS_DECLARED
|
||||
#define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
#ifndef YYSTYPE_IS_DECLARED
|
||||
#define YYSTYPE_IS_DECLARED 1
|
||||
typedef union {
|
||||
struct yyyOxAttrbs {
|
||||
struct yyyStackItem *yyyOxStackItem;
|
||||
} yyyOxAttrbs;
|
||||
} YYSTYPE;
|
||||
#endif /* !YYSTYPE_IS_DECLARED */
|
||||
extern YYSTYPE expr.oxout_lval;
|
Loading…
Reference in New Issue
Block a user