mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 18:23:03 +00:00
* src/location.h: New, extracted from...
* src/reader.h: here. * src/Makefile.am (noinst_HEADERS): Merge into (bison_SOURCES): this. Add location.h. * src/parse-gram.y: Use location_t instead of Bison's. * src/reader.h, src/reader.c (prologue_augment, epilogue_set): Use location_t instead of ints.
This commit is contained in:
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
|||||||
|
2002-06-14 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/location.h: New, extracted from...
|
||||||
|
* src/reader.h: here.
|
||||||
|
* src/Makefile.am (noinst_HEADERS): Merge into
|
||||||
|
(bison_SOURCES): this.
|
||||||
|
Add location.h.
|
||||||
|
* src/parse-gram.y: Use location_t instead of Bison's.
|
||||||
|
* src/reader.h, src/reader.c (prologue_augment, epilogue_set):
|
||||||
|
Use location_t instead of ints.
|
||||||
|
|
||||||
|
|
||||||
2002-06-14 Akim Demaille <akim@epita.fr>
|
2002-06-14 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* data/bison.simple, data/bison.c++: Be sure to restore the
|
* data/bison.simple, data/bison.c++: Be sure to restore the
|
||||||
|
|||||||
@@ -31,16 +31,7 @@ if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
|||||||
fi
|
fi
|
||||||
# `libtool' can also be set to `yes' or `no'.
|
# `libtool' can also be set to `yes' or `no'.
|
||||||
|
|
||||||
if test -z "$depfile"; then
|
depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`}
|
||||||
base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
|
|
||||||
dir=`echo "$object" | sed 's,/.*$,/,'`
|
|
||||||
if test "$dir" = "$object"; then
|
|
||||||
dir=
|
|
||||||
fi
|
|
||||||
# FIXME: should be _deps on DOS.
|
|
||||||
depfile="$dir.deps/$base"
|
|
||||||
fi
|
|
||||||
|
|
||||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||||
|
|
||||||
rm -f "$tmpdepfile"
|
rm -f "$tmpdepfile"
|
||||||
@@ -213,9 +204,8 @@ tru64)
|
|||||||
# dependencies in `foo.d' instead, so we check for that too.
|
# dependencies in `foo.d' instead, so we check for that too.
|
||||||
# Subdirectories are respected.
|
# Subdirectories are respected.
|
||||||
|
|
||||||
base=`echo "$object" | sed -e 's/\.o$/.d/' -e 's/\.lo$/.d/'`
|
tmpdepfile1="$object.d"
|
||||||
tmpdepfile1="$base.o.d"
|
tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'`
|
||||||
tmpdepfile2="$base.d"
|
|
||||||
if test "$libtool" = yes; then
|
if test "$libtool" = yes; then
|
||||||
"$@" -Wc,-MD
|
"$@" -Wc,-MD
|
||||||
else
|
else
|
||||||
@@ -324,7 +314,7 @@ makedepend)
|
|||||||
if test "$stat" != 0; then exit $stat; fi
|
if test "$stat" != 0; then exit $stat; fi
|
||||||
rm -f "$depfile"
|
rm -f "$depfile"
|
||||||
cat < "$tmpdepfile" > "$depfile"
|
cat < "$tmpdepfile" > "$depfile"
|
||||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
tail +3 "$tmpdepfile" | tr ' ' '
|
||||||
' | \
|
' | \
|
||||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||||
## correctly. Breaking it into two sed invocations is a workaround.
|
## correctly. Breaking it into two sed invocations is a workaround.
|
||||||
@@ -392,21 +382,6 @@ msvisualcpp)
|
|||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
for arg
|
|
||||||
do
|
|
||||||
case "$arg" in
|
|
||||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
|
||||||
set fnord "$@"
|
|
||||||
shift
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
set fnord "$@" "$arg"
|
|
||||||
shift
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
"$@" -E |
|
"$@" -E |
|
||||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||||
) &
|
) &
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ then
|
|||||||
echo "install: no input file specified"
|
echo "install: no input file specified"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
:
|
true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ x"$dir_arg" != x ]; then
|
if [ x"$dir_arg" != x ]; then
|
||||||
@@ -120,7 +120,7 @@ if [ x"$dir_arg" != x ]; then
|
|||||||
instcmd=:
|
instcmd=:
|
||||||
chmodcmd=""
|
chmodcmd=""
|
||||||
else
|
else
|
||||||
instcmd=$mkdirprog
|
instcmd=mkdir
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ else
|
|||||||
|
|
||||||
if [ -f $src -o -d $src ]
|
if [ -f $src -o -d $src ]
|
||||||
then
|
then
|
||||||
:
|
true
|
||||||
else
|
else
|
||||||
echo "install: $src does not exist"
|
echo "install: $src does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -141,7 +141,7 @@ else
|
|||||||
echo "install: no destination specified"
|
echo "install: no destination specified"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
:
|
true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If destination is a directory, append the input filename; if your system
|
# If destination is a directory, append the input filename; if your system
|
||||||
@@ -151,7 +151,7 @@ else
|
|||||||
then
|
then
|
||||||
dst="$dst"/`basename $src`
|
dst="$dst"/`basename $src`
|
||||||
else
|
else
|
||||||
:
|
true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -163,8 +163,8 @@ dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
|||||||
|
|
||||||
# Skip lots of stat calls in the usual case.
|
# Skip lots of stat calls in the usual case.
|
||||||
if [ ! -d "$dstdir" ]; then
|
if [ ! -d "$dstdir" ]; then
|
||||||
defaultIFS='
|
defaultIFS='
|
||||||
'
|
'
|
||||||
IFS="${IFS-${defaultIFS}}"
|
IFS="${IFS-${defaultIFS}}"
|
||||||
|
|
||||||
oIFS="${IFS}"
|
oIFS="${IFS}"
|
||||||
@@ -183,7 +183,7 @@ while [ $# -ne 0 ] ; do
|
|||||||
then
|
then
|
||||||
$mkdirprog "${pathcomp}"
|
$mkdirprog "${pathcomp}"
|
||||||
else
|
else
|
||||||
:
|
true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pathcomp="${pathcomp}/"
|
pathcomp="${pathcomp}/"
|
||||||
@@ -194,10 +194,10 @@ if [ x"$dir_arg" != x ]
|
|||||||
then
|
then
|
||||||
$doit $instcmd $dst &&
|
$doit $instcmd $dst &&
|
||||||
|
|
||||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||||
else
|
else
|
||||||
|
|
||||||
# If we're going to rename the final executable, determine the name now.
|
# If we're going to rename the final executable, determine the name now.
|
||||||
@@ -216,7 +216,7 @@ else
|
|||||||
then
|
then
|
||||||
dstfile=`basename $dst`
|
dstfile=`basename $dst`
|
||||||
else
|
else
|
||||||
:
|
true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make a temp file name in the proper directory.
|
# Make a temp file name in the proper directory.
|
||||||
@@ -235,10 +235,10 @@ else
|
|||||||
# ignore errors from any of these, just make sure not to ignore
|
# ignore errors from any of these, just make sure not to ignore
|
||||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||||
|
|
||||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||||
|
|
||||||
# Now rename the file to the real destination.
|
# Now rename the file to the real destination.
|
||||||
|
|
||||||
|
|||||||
@@ -35,27 +35,41 @@ LDADD = $(INTLLIBS) ../lib/libbison.a
|
|||||||
|
|
||||||
bin_PROGRAMS = bison
|
bin_PROGRAMS = bison
|
||||||
|
|
||||||
bison_SOURCES = LR0.c closure.c complain.c conflicts.c \
|
bison_SOURCES = \
|
||||||
parse-gram.y parse-gram.h \
|
LR0.c LR0.h \
|
||||||
scan-gram.c \
|
closure.c closure.h \
|
||||||
derives.c \
|
complain.c complain.h \
|
||||||
files.c getargs.c gram.c lalr.c main.c nullable.c \
|
conflicts.c conflicts.h \
|
||||||
output.h output.c \
|
derives.c derives.h \
|
||||||
state.h state.c \
|
files.c files.h \
|
||||||
print_graph.h print_graph.c \
|
getargs.c getargs.h \
|
||||||
muscle_tab.h muscle_tab.c \
|
gram.c gram.h \
|
||||||
options.h options.c \
|
lalr.h lalr.c \
|
||||||
print.c reader.c reduce.c symtab.c vcg.c \
|
location.h \
|
||||||
scan-skel.l
|
main.c \
|
||||||
|
muscle_tab.c muscle_tab.h \
|
||||||
|
nullable.c nullable.h \
|
||||||
|
options.c options.h \
|
||||||
|
output.c output.h \
|
||||||
|
parse-gram.h parse-gram.y \
|
||||||
|
print.c print.h \
|
||||||
|
print_graph.c print_graph.h \
|
||||||
|
reader.c reader.h \
|
||||||
|
reduce.c reduce.h \
|
||||||
|
scan-gram.l \
|
||||||
|
scan-skel.l \
|
||||||
|
state.c state.h \
|
||||||
|
symtab.c symtab.h \
|
||||||
|
system.h \
|
||||||
|
types.h \
|
||||||
|
vcg.c vcg.h \
|
||||||
|
vcg_defaults.h
|
||||||
|
|
||||||
BUILT_SOURCES = scan-skel.c scan-gram.c parse-gram.c parse-gram.h
|
BUILT_SOURCES = scan-skel.c scan-gram.c parse-gram.c parse-gram.h
|
||||||
|
|
||||||
EXTRA_bison_SOURCES = vmsgetargs.c
|
EXTRA_bison_SOURCES = vmsgetargs.c
|
||||||
|
|
||||||
noinst_HEADERS = LR0.h closure.h complain.h conflicts.h \
|
|
||||||
derives.h \
|
|
||||||
files.h getargs.h gram.h lalr.h nullable.h \
|
|
||||||
print.h reader.h reduce.h symtab.h system.h \
|
|
||||||
types.h vcg.h vcg_defaults.h
|
|
||||||
|
|
||||||
EXTRA_DIST = build.com bison.cld vmshlp.mar
|
EXTRA_DIST = build.com bison.cld vmshlp.mar
|
||||||
|
|
||||||
|
echo:
|
||||||
|
echo $(bison_SOURCES) $(noinst_HEADERS)
|
||||||
|
|||||||
65
src/location.h
Normal file
65
src/location.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/* Locations for Bison
|
||||||
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
|
Bison is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
Bison is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Bison; see the file COPYING. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#ifndef LOCATION_H_
|
||||||
|
# define LOCATION_H_
|
||||||
|
|
||||||
|
typedef struct location_s
|
||||||
|
{
|
||||||
|
int first_line;
|
||||||
|
int first_column;
|
||||||
|
int last_line;
|
||||||
|
int last_column;
|
||||||
|
} location_t;
|
||||||
|
#define YYLTYPE location_t
|
||||||
|
|
||||||
|
/* Initialize LOC. */
|
||||||
|
# define LOCATION_RESET(Loc) \
|
||||||
|
(Loc).first_column = (Loc).first_line = 1; \
|
||||||
|
(Loc).last_column = (Loc).last_line = 1;
|
||||||
|
|
||||||
|
/* Advance of NUM columns. */
|
||||||
|
# define LOCATION_COLUMNS(Loc, Num) \
|
||||||
|
(Loc).last_column += Num;
|
||||||
|
|
||||||
|
/* Advance of NUM lines. */
|
||||||
|
# define LOCATION_LINES(Loc, Num) \
|
||||||
|
(Loc).last_column = 1; \
|
||||||
|
(Loc).last_line += Num;
|
||||||
|
|
||||||
|
/* Restart: move the first cursor to the last position. */
|
||||||
|
# define LOCATION_STEP(Loc) \
|
||||||
|
(Loc).first_column = (Loc).last_column; \
|
||||||
|
(Loc).first_line = (Loc).last_line;
|
||||||
|
|
||||||
|
/* Output LOC on the stream OUT. */
|
||||||
|
# define LOCATION_PRINT(Out, Loc) \
|
||||||
|
fprintf (stderr, "%s:", infile); \
|
||||||
|
if ((Loc).first_line != (Loc).last_line) \
|
||||||
|
fprintf (Out, "%d.%d-%d.%d", \
|
||||||
|
(Loc).first_line, (Loc).first_column, \
|
||||||
|
(Loc).last_line, (Loc).last_column - 1); \
|
||||||
|
else if ((Loc).first_column < (Loc).last_column - 1) \
|
||||||
|
fprintf (Out, "%d.%d-%d", (Loc).first_line, \
|
||||||
|
(Loc).first_column, (Loc).last_column - 1); \
|
||||||
|
else \
|
||||||
|
fprintf (Out, "%d.%d", (Loc).first_line, (Loc).first_column)
|
||||||
|
|
||||||
|
#endif /* !LOCATION_H_ */
|
||||||
1422
src/parse-gram.c
1422
src/parse-gram.c
File diff suppressed because it is too large
Load Diff
146
src/parse-gram.h
146
src/parse-gram.h
@@ -1,122 +1,70 @@
|
|||||||
#ifndef BISON_PARSE_GRAM_H
|
#ifndef BISON_Y_TAB_H
|
||||||
# define BISON_PARSE_GRAM_H
|
# define BISON_Y_TAB_H
|
||||||
|
|
||||||
/* Tokens. */
|
|
||||||
#ifndef YYTOKENTYPE
|
|
||||||
# if defined (__STDC__) || defined (__cplusplus)
|
|
||||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
|
||||||
know about them. */
|
|
||||||
enum yytokentype {
|
|
||||||
GRAM_EOF = 0,
|
|
||||||
STRING = 258,
|
|
||||||
CHARACTER = 259,
|
|
||||||
INT = 260,
|
|
||||||
PERCENT_TOKEN = 261,
|
|
||||||
PERCENT_NTERM = 262,
|
|
||||||
PERCENT_TYPE = 263,
|
|
||||||
PERCENT_UNION = 264,
|
|
||||||
PERCENT_EXPECT = 265,
|
|
||||||
PERCENT_START = 266,
|
|
||||||
PERCENT_LEFT = 267,
|
|
||||||
PERCENT_RIGHT = 268,
|
|
||||||
PERCENT_NONASSOC = 269,
|
|
||||||
PERCENT_PREC = 270,
|
|
||||||
PERCENT_VERBOSE = 271,
|
|
||||||
PERCENT_ERROR_VERBOSE = 272,
|
|
||||||
PERCENT_OUTPUT = 273,
|
|
||||||
PERCENT_FILE_PREFIX = 274,
|
|
||||||
PERCENT_NAME_PREFIX = 275,
|
|
||||||
PERCENT_DEFINE = 276,
|
|
||||||
PERCENT_PURE_PARSER = 277,
|
|
||||||
PERCENT_DEFINES = 278,
|
|
||||||
PERCENT_YACC = 279,
|
|
||||||
PERCENT_DEBUG = 280,
|
|
||||||
PERCENT_LOCATIONS = 281,
|
|
||||||
PERCENT_NO_LINES = 282,
|
|
||||||
PERCENT_SKELETON = 283,
|
|
||||||
PERCENT_TOKEN_TABLE = 284,
|
|
||||||
TYPE = 285,
|
|
||||||
EQUAL = 286,
|
|
||||||
SEMICOLON = 287,
|
|
||||||
COLON = 288,
|
|
||||||
PIPE = 289,
|
|
||||||
ID = 290,
|
|
||||||
PERCENT_PERCENT = 291,
|
|
||||||
PROLOGUE = 292,
|
|
||||||
EPILOGUE = 293,
|
|
||||||
BRACED_CODE = 294
|
|
||||||
};
|
|
||||||
# endif
|
|
||||||
/* POSIX requires `int' for tokens in interfaces. */
|
|
||||||
# define YYTOKENTYPE int
|
|
||||||
#endif /* !YYTOKENTYPE */
|
|
||||||
#define GRAM_EOF 0
|
|
||||||
#define STRING 258
|
|
||||||
#define CHARACTER 259
|
|
||||||
#define INT 260
|
|
||||||
#define PERCENT_TOKEN 261
|
|
||||||
#define PERCENT_NTERM 262
|
|
||||||
#define PERCENT_TYPE 263
|
|
||||||
#define PERCENT_UNION 264
|
|
||||||
#define PERCENT_EXPECT 265
|
|
||||||
#define PERCENT_START 266
|
|
||||||
#define PERCENT_LEFT 267
|
|
||||||
#define PERCENT_RIGHT 268
|
|
||||||
#define PERCENT_NONASSOC 269
|
|
||||||
#define PERCENT_PREC 270
|
|
||||||
#define PERCENT_VERBOSE 271
|
|
||||||
#define PERCENT_ERROR_VERBOSE 272
|
|
||||||
#define PERCENT_OUTPUT 273
|
|
||||||
#define PERCENT_FILE_PREFIX 274
|
|
||||||
#define PERCENT_NAME_PREFIX 275
|
|
||||||
#define PERCENT_DEFINE 276
|
|
||||||
#define PERCENT_PURE_PARSER 277
|
|
||||||
#define PERCENT_DEFINES 278
|
|
||||||
#define PERCENT_YACC 279
|
|
||||||
#define PERCENT_DEBUG 280
|
|
||||||
#define PERCENT_LOCATIONS 281
|
|
||||||
#define PERCENT_NO_LINES 282
|
|
||||||
#define PERCENT_SKELETON 283
|
|
||||||
#define PERCENT_TOKEN_TABLE 284
|
|
||||||
#define TYPE 285
|
|
||||||
#define EQUAL 286
|
|
||||||
#define SEMICOLON 287
|
|
||||||
#define COLON 288
|
|
||||||
#define PIPE 289
|
|
||||||
#define ID 290
|
|
||||||
#define PERCENT_PERCENT 291
|
|
||||||
#define PROLOGUE 292
|
|
||||||
#define EPILOGUE 293
|
|
||||||
#define BRACED_CODE 294
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef YYSTYPE
|
#ifndef YYSTYPE
|
||||||
#line 73 "parse-gram.y"
|
typedef union
|
||||||
typedef union {
|
{
|
||||||
symbol_t *symbol;
|
symbol_t *symbol;
|
||||||
int integer;
|
int integer;
|
||||||
char *string;
|
char *string;
|
||||||
associativity assoc;
|
associativity assoc;
|
||||||
} yystype;
|
} yystype;
|
||||||
# define YYSTYPE yystype
|
# define YYSTYPE yystype
|
||||||
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef YYLTYPE
|
#ifndef YYLTYPE
|
||||||
typedef struct yyltype
|
typedef struct yyltype
|
||||||
{
|
{
|
||||||
int first_line;
|
int first_line;
|
||||||
int first_column;
|
int first_column;
|
||||||
|
|
||||||
int last_line;
|
int last_line;
|
||||||
int last_column;
|
int last_column;
|
||||||
} yyltype;
|
} yyltype;
|
||||||
|
|
||||||
# define YYLTYPE yyltype
|
# define YYLTYPE yyltype
|
||||||
|
# define YYLTYPE_IS_TRIVIAL 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
# define GRAM_EOF 0
|
||||||
|
# define STRING 257
|
||||||
|
# define CHARACTER 258
|
||||||
|
# define INT 259
|
||||||
|
# define PERCENT_TOKEN 260
|
||||||
|
# define PERCENT_NTERM 261
|
||||||
|
# define PERCENT_TYPE 262
|
||||||
|
# define PERCENT_UNION 263
|
||||||
|
# define PERCENT_EXPECT 264
|
||||||
|
# define PERCENT_START 265
|
||||||
|
# define PERCENT_LEFT 266
|
||||||
|
# define PERCENT_RIGHT 267
|
||||||
|
# define PERCENT_NONASSOC 268
|
||||||
|
# define PERCENT_PREC 269
|
||||||
|
# define PERCENT_VERBOSE 270
|
||||||
|
# define PERCENT_ERROR_VERBOSE 271
|
||||||
|
# define PERCENT_OUTPUT 272
|
||||||
|
# define PERCENT_FILE_PREFIX 273
|
||||||
|
# define PERCENT_NAME_PREFIX 274
|
||||||
|
# define PERCENT_DEFINE 275
|
||||||
|
# define PERCENT_PURE_PARSER 276
|
||||||
|
# define PERCENT_DEFINES 277
|
||||||
|
# define PERCENT_YACC 278
|
||||||
|
# define PERCENT_DEBUG 279
|
||||||
|
# define PERCENT_LOCATIONS 280
|
||||||
|
# define PERCENT_NO_LINES 281
|
||||||
|
# define PERCENT_SKELETON 282
|
||||||
|
# define PERCENT_TOKEN_TABLE 283
|
||||||
|
# define TYPE 284
|
||||||
|
# define EQUAL 285
|
||||||
|
# define SEMICOLON 286
|
||||||
|
# define COLON 287
|
||||||
|
# define PIPE 288
|
||||||
|
# define ID 289
|
||||||
|
# define PERCENT_PERCENT 290
|
||||||
|
# define PROLOGUE 291
|
||||||
|
# define EPILOGUE 292
|
||||||
|
# define BRACED_CODE 293
|
||||||
|
|
||||||
|
|
||||||
#endif /* not BISON_PARSE_GRAM_H */
|
#endif /* not BISON_Y_TAB_H */
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "conflicts.h"
|
#include "conflicts.h"
|
||||||
|
|
||||||
|
/* Produce verbose parse errors. */
|
||||||
#define YYERROR_VERBOSE 1
|
#define YYERROR_VERBOSE 1
|
||||||
|
|
||||||
/* Pass the control structure to YYPARSE and YYLEX. */
|
/* Pass the control structure to YYPARSE and YYLEX. */
|
||||||
@@ -57,7 +58,7 @@
|
|||||||
of the tokens. */
|
of the tokens. */
|
||||||
#define YYPRINT(File, Type, Value) \
|
#define YYPRINT(File, Type, Value) \
|
||||||
yyprint (File, &yylloc, Type, &Value)
|
yyprint (File, &yylloc, Type, &Value)
|
||||||
static void yyprint (FILE *file, const yyltype *loc,
|
static void yyprint (FILE *file, const location_t *loc,
|
||||||
int type, const yystype *value);
|
int type, const yystype *value);
|
||||||
|
|
||||||
symbol_class current_class = unknown_sym;
|
symbol_class current_class = unknown_sym;
|
||||||
@@ -132,7 +133,7 @@ input: { LOCATION_RESET (yylloc); }
|
|||||||
directives "%%" gram epilogue.opt
|
directives "%%" gram epilogue.opt
|
||||||
{
|
{
|
||||||
yycontrol->errcode = 0;
|
yycontrol->errcode = 0;
|
||||||
epilogue_set ($5, @5.first_line);
|
epilogue_set ($5, @5);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -145,7 +146,7 @@ directive:
|
|||||||
grammar_directives
|
grammar_directives
|
||||||
| PROLOGUE
|
| PROLOGUE
|
||||||
{
|
{
|
||||||
prologue_augment ($1, @1.first_line);
|
prologue_augment ($1, @1);
|
||||||
}
|
}
|
||||||
| "%debug" { debug_flag = 1; }
|
| "%debug" { debug_flag = 1; }
|
||||||
| "%define" string_content string_content { muscle_insert ($2, $3); }
|
| "%define" string_content string_content { muscle_insert ($2, $3); }
|
||||||
@@ -348,7 +349,7 @@ semi_colon_opt:
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
yyprint (FILE *file,
|
yyprint (FILE *file,
|
||||||
const yyltype *loc, int type, const yystype *value)
|
const location_t *loc, int type, const yystype *value)
|
||||||
{
|
{
|
||||||
fputs (" (", file);
|
fputs (" (", file);
|
||||||
LOCATION_PRINT (file, *loc);
|
LOCATION_PRINT (file, *loc);
|
||||||
@@ -385,7 +386,7 @@ yyprint (FILE *file,
|
|||||||
|
|
||||||
void
|
void
|
||||||
gram_error (gram_control_t *control ATTRIBUTE_UNUSED,
|
gram_error (gram_control_t *control ATTRIBUTE_UNUSED,
|
||||||
yyltype *yylloc, const char *msg)
|
location_t *yylloc, const char *msg)
|
||||||
{
|
{
|
||||||
LOCATION_PRINT (stderr, *yylloc);
|
LOCATION_PRINT (stderr, *yylloc);
|
||||||
fprintf (stderr, ": %s\n", msg);
|
fprintf (stderr, ": %s\n", msg);
|
||||||
|
|||||||
14
src/reader.c
14
src/reader.c
@@ -113,7 +113,7 @@ grammar_start_symbol_set (symbol_t *s)
|
|||||||
`----------------------------------------------------------------*/
|
`----------------------------------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
prologue_augment (const char *prologue, int location)
|
prologue_augment (const char *prologue, location_t location)
|
||||||
{
|
{
|
||||||
struct obstack *oout =
|
struct obstack *oout =
|
||||||
!typed ? &pre_prologue_obstack : &post_prologue_obstack;
|
!typed ? &pre_prologue_obstack : &post_prologue_obstack;
|
||||||
@@ -121,8 +121,9 @@ prologue_augment (const char *prologue, int location)
|
|||||||
if (!no_lines_flag)
|
if (!no_lines_flag)
|
||||||
{
|
{
|
||||||
obstack_fgrow2 (oout, muscle_find ("linef"),
|
obstack_fgrow2 (oout, muscle_find ("linef"),
|
||||||
location, quotearg_style (c_quoting_style,
|
location.first_line,
|
||||||
muscle_find ("filename")));
|
quotearg_style (c_quoting_style,
|
||||||
|
muscle_find ("filename")));
|
||||||
}
|
}
|
||||||
obstack_sgrow (oout, prologue);
|
obstack_sgrow (oout, prologue);
|
||||||
}
|
}
|
||||||
@@ -135,7 +136,7 @@ prologue_augment (const char *prologue, int location)
|
|||||||
`----------------------*/
|
`----------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
epilogue_set (const char *epilogue, int location)
|
epilogue_set (const char *epilogue, location_t location)
|
||||||
{
|
{
|
||||||
struct obstack el_obstack;
|
struct obstack el_obstack;
|
||||||
obstack_init (&el_obstack);
|
obstack_init (&el_obstack);
|
||||||
@@ -143,8 +144,9 @@ epilogue_set (const char *epilogue, int location)
|
|||||||
if (!no_lines_flag)
|
if (!no_lines_flag)
|
||||||
{
|
{
|
||||||
obstack_fgrow2 (&el_obstack, muscle_find ("linef"),
|
obstack_fgrow2 (&el_obstack, muscle_find ("linef"),
|
||||||
location, quotearg_style (c_quoting_style,
|
location.first_line,
|
||||||
muscle_find ("filename")));
|
quotearg_style (c_quoting_style,
|
||||||
|
muscle_find ("filename")));
|
||||||
}
|
}
|
||||||
obstack_sgrow (&el_obstack, epilogue);
|
obstack_sgrow (&el_obstack, epilogue);
|
||||||
obstack_1grow (&el_obstack, 0);
|
obstack_1grow (&el_obstack, 0);
|
||||||
|
|||||||
40
src/reader.h
40
src/reader.h
@@ -21,6 +21,8 @@
|
|||||||
#ifndef READER_H_
|
#ifndef READER_H_
|
||||||
# define READER_H_
|
# define READER_H_
|
||||||
|
|
||||||
|
# include "location.h"
|
||||||
|
|
||||||
typedef struct symbol_list
|
typedef struct symbol_list
|
||||||
{
|
{
|
||||||
struct symbol_list *next;
|
struct symbol_list *next;
|
||||||
@@ -36,40 +38,6 @@ typedef struct symbol_list
|
|||||||
|
|
||||||
# include "parse-gram.h"
|
# include "parse-gram.h"
|
||||||
|
|
||||||
typedef int location_t;
|
|
||||||
|
|
||||||
/* Initialize LOC. */
|
|
||||||
# define LOCATION_RESET(Loc) \
|
|
||||||
(Loc).first_column = (Loc).first_line = 1; \
|
|
||||||
(Loc).last_column = (Loc).last_line = 1;
|
|
||||||
|
|
||||||
/* Advance of NUM columns. */
|
|
||||||
# define LOCATION_COLUMNS(Loc, Num) \
|
|
||||||
(Loc).last_column += Num;
|
|
||||||
|
|
||||||
/* Advance of NUM lines. */
|
|
||||||
# define LOCATION_LINES(Loc, Num) \
|
|
||||||
(Loc).last_column = 1; \
|
|
||||||
(Loc).last_line += Num;
|
|
||||||
|
|
||||||
/* Restart: move the first cursor to the last position. */
|
|
||||||
# define LOCATION_STEP(Loc) \
|
|
||||||
(Loc).first_column = (Loc).last_column; \
|
|
||||||
(Loc).first_line = (Loc).last_line;
|
|
||||||
|
|
||||||
/* Output LOC on the stream OUT. */
|
|
||||||
# define LOCATION_PRINT(Out, Loc) \
|
|
||||||
fprintf (stderr, "%s:", infile); \
|
|
||||||
if ((Loc).first_line != (Loc).last_line) \
|
|
||||||
fprintf (Out, "%d.%d-%d.%d", \
|
|
||||||
(Loc).first_line, (Loc).first_column, \
|
|
||||||
(Loc).last_line, (Loc).last_column - 1); \
|
|
||||||
else if ((Loc).first_column < (Loc).last_column - 1) \
|
|
||||||
fprintf (Out, "%d.%d-%d", (Loc).first_line, \
|
|
||||||
(Loc).first_column, (Loc).last_column - 1); \
|
|
||||||
else \
|
|
||||||
fprintf (Out, "%d.%d", (Loc).first_line, (Loc).first_column)
|
|
||||||
|
|
||||||
typedef struct gram_control_s
|
typedef struct gram_control_s
|
||||||
{
|
{
|
||||||
int errcode;
|
int errcode;
|
||||||
@@ -83,7 +51,7 @@ void scanner_initialize PARAMS ((void));
|
|||||||
void scanner_free PARAMS ((void));
|
void scanner_free PARAMS ((void));
|
||||||
|
|
||||||
# define YY_DECL \
|
# define YY_DECL \
|
||||||
int gram_lex (yystype *yylval, yyltype *yylloc, \
|
int gram_lex (yystype *yylval, location_t *yylloc, \
|
||||||
gram_control_t *yycontrol)
|
gram_control_t *yycontrol)
|
||||||
YY_DECL;
|
YY_DECL;
|
||||||
|
|
||||||
@@ -91,7 +59,7 @@ YY_DECL;
|
|||||||
/* From the parser. */
|
/* From the parser. */
|
||||||
extern int gram_debug;
|
extern int gram_debug;
|
||||||
void gram_error (gram_control_t *control,
|
void gram_error (gram_control_t *control,
|
||||||
yyltype *loc, const char *msg);
|
location_t *loc, const char *msg);
|
||||||
int gram_parse (void *control);
|
int gram_parse (void *control);
|
||||||
|
|
||||||
char *get_type_name PARAMS ((int n, symbol_list *rule));
|
char *get_type_name PARAMS ((int n, symbol_list *rule));
|
||||||
|
|||||||
Reference in New Issue
Block a user