mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 07:43:03 +00:00
Automaton VCG graph output.
Using option ``-g'' or long option ``--graph'', you can generate a gram_filename.vcg file containing a VCG description of the LALR (1) automaton of your grammar. * src/main.c: Call to print_graph() function. * src/getargs.h: Update. * src/getargs.c (options): Update to catch `-g' and `--graph' options. (graph_flag): New flag. (longopts): Update. (getargs): Add case `g'. * src/files.c (graph_obstack): New obstack struct. (open_files): Initialize new obstack. (output_files): Saves graph_obstack if required. * src/files.h (graph_obstack): New extern declaration. * src/Makefile.am: Add new source files.
This commit is contained in:
19
ChangeLog
19
ChangeLog
@@ -1,3 +1,22 @@
|
|||||||
|
2001-08-06 Marc Autret <autret_@epita.fr>
|
||||||
|
|
||||||
|
Automaton VCG graph output.
|
||||||
|
Using option ``-g'' or long option ``--graph'', you can generate
|
||||||
|
a gram_filename.vcg file containing a VCG description of the LALR (1)
|
||||||
|
automaton of your grammar.
|
||||||
|
|
||||||
|
* src/main.c: Call to print_graph() function.
|
||||||
|
* src/getargs.h: Update.
|
||||||
|
* src/getargs.c (options): Update to catch `-g' and `--graph' options.
|
||||||
|
(graph_flag): New flag.
|
||||||
|
(longopts): Update.
|
||||||
|
(getargs): Add case `g'.
|
||||||
|
* src/files.c (graph_obstack): New obstack struct.
|
||||||
|
(open_files): Initialize new obstack.
|
||||||
|
(output_files): Saves graph_obstack if required.
|
||||||
|
* src/files.h (graph_obstack): New extern declaration.
|
||||||
|
* src/Makefile.am: Add new source files.
|
||||||
|
|
||||||
2001-08-06 Marc Autret <autret_@epita.fr>
|
2001-08-06 Marc Autret <autret_@epita.fr>
|
||||||
|
|
||||||
* src/print_graph.c, src/print_graph.h (graph): New.
|
* src/print_graph.c, src/print_graph.h (graph): New.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ bison_SOURCES = LR0.c closure.c complain.c conflicts.c \
|
|||||||
derives.c \
|
derives.c \
|
||||||
files.c getargs.c gram.c lalr.c lex.c main.c nullable.c \
|
files.c getargs.c gram.c lalr.c lex.c main.c nullable.c \
|
||||||
output.c \
|
output.c \
|
||||||
print.c reader.c reduce.c symtab.c warshall.c
|
print.c reader.c reduce.c symtab.c warshall.c vcg.c print_graph.c
|
||||||
|
|
||||||
EXTRA_bison_SOURCES = vmsgetargs.c
|
EXTRA_bison_SOURCES = vmsgetargs.c
|
||||||
|
|
||||||
@@ -22,7 +22,8 @@ noinst_HEADERS = LR0.h closure.h complain.h conflicts.h \
|
|||||||
derives.h \
|
derives.h \
|
||||||
files.h getargs.h gram.h lalr.h lex.h nullable.h \
|
files.h getargs.h gram.h lalr.h lex.h nullable.h \
|
||||||
output.h state.h \
|
output.h state.h \
|
||||||
print.h reader.h reduce.h symtab.h warshall.h system.h types.h
|
print.h reader.h reduce.h symtab.h warshall.h system.h types.h \
|
||||||
|
vcg.h vcg_defaults.h print_graph.h
|
||||||
|
|
||||||
pkgdata_DATA = bison.simple bison.hairy
|
pkgdata_DATA = bison.simple bison.hairy
|
||||||
|
|
||||||
|
|||||||
@@ -103,12 +103,12 @@ LDADD = @INTLLIBS@ ../lib/libbison.a
|
|||||||
|
|
||||||
bin_PROGRAMS = bison
|
bin_PROGRAMS = bison
|
||||||
|
|
||||||
bison_SOURCES = LR0.c closure.c complain.c conflicts.c derives.c files.c getargs.c gram.c lalr.c lex.c main.c nullable.c output.c print.c reader.c reduce.c symtab.c warshall.c
|
bison_SOURCES = LR0.c closure.c complain.c conflicts.c derives.c files.c getargs.c gram.c lalr.c lex.c main.c nullable.c output.c print.c reader.c reduce.c symtab.c warshall.c vcg.c print_graph.c
|
||||||
|
|
||||||
|
|
||||||
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 lex.h nullable.h output.h state.h print.h reader.h reduce.h symtab.h warshall.h system.h types.h
|
noinst_HEADERS = LR0.h closure.h complain.h conflicts.h derives.h files.h getargs.h gram.h lalr.h lex.h nullable.h output.h state.h print.h reader.h reduce.h symtab.h warshall.h system.h types.h vcg.h vcg_defaults.h print_graph.h
|
||||||
|
|
||||||
|
|
||||||
pkgdata_DATA = bison.simple bison.hairy
|
pkgdata_DATA = bison.simple bison.hairy
|
||||||
@@ -126,7 +126,7 @@ ANSI2KNR = ../lib/ansi2knr
|
|||||||
bison_OBJECTS = LR0$U.o closure$U.o complain$U.o conflicts$U.o \
|
bison_OBJECTS = LR0$U.o closure$U.o complain$U.o conflicts$U.o \
|
||||||
derives$U.o files$U.o getargs$U.o gram$U.o lalr$U.o lex$U.o main$U.o \
|
derives$U.o files$U.o getargs$U.o gram$U.o lalr$U.o lex$U.o main$U.o \
|
||||||
nullable$U.o output$U.o print$U.o reader$U.o reduce$U.o symtab$U.o \
|
nullable$U.o output$U.o print$U.o reader$U.o reduce$U.o symtab$U.o \
|
||||||
warshall$U.o
|
warshall$U.o vcg$U.o print_graph$U.o
|
||||||
bison_LDADD = $(LDADD)
|
bison_LDADD = $(LDADD)
|
||||||
bison_DEPENDENCIES = ../lib/libbison.a
|
bison_DEPENDENCIES = ../lib/libbison.a
|
||||||
bison_LDFLAGS =
|
bison_LDFLAGS =
|
||||||
@@ -148,8 +148,9 @@ GZIP_ENV = --best
|
|||||||
DEP_FILES = .deps/LR0.P .deps/closure.P .deps/complain.P \
|
DEP_FILES = .deps/LR0.P .deps/closure.P .deps/complain.P \
|
||||||
.deps/conflicts.P .deps/derives.P .deps/files.P .deps/getargs.P \
|
.deps/conflicts.P .deps/derives.P .deps/files.P .deps/getargs.P \
|
||||||
.deps/gram.P .deps/lalr.P .deps/lex.P .deps/main.P .deps/nullable.P \
|
.deps/gram.P .deps/lalr.P .deps/lex.P .deps/main.P .deps/nullable.P \
|
||||||
.deps/output.P .deps/print.P .deps/reader.P .deps/reduce.P \
|
.deps/output.P .deps/print.P .deps/print_graph.P .deps/reader.P \
|
||||||
.deps/symtab.P .deps/vmsgetargs.P .deps/warshall.P
|
.deps/reduce.P .deps/symtab.P .deps/vcg.P .deps/vmsgetargs.P \
|
||||||
|
.deps/warshall.P
|
||||||
SOURCES = $(bison_SOURCES) $(EXTRA_bison_SOURCES)
|
SOURCES = $(bison_SOURCES) $(EXTRA_bison_SOURCES)
|
||||||
OBJECTS = $(bison_OBJECTS)
|
OBJECTS = $(bison_OBJECTS)
|
||||||
|
|
||||||
@@ -255,6 +256,8 @@ output_.c: output.c $(ANSI2KNR)
|
|||||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/output.c; then echo $(srcdir)/output.c; else echo output.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > output_.c
|
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/output.c; then echo $(srcdir)/output.c; else echo output.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > output_.c
|
||||||
print_.c: print.c $(ANSI2KNR)
|
print_.c: print.c $(ANSI2KNR)
|
||||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/print.c; then echo $(srcdir)/print.c; else echo print.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > print_.c
|
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/print.c; then echo $(srcdir)/print.c; else echo print.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > print_.c
|
||||||
|
print_graph_.c: print_graph.c $(ANSI2KNR)
|
||||||
|
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/print_graph.c; then echo $(srcdir)/print_graph.c; else echo print_graph.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > print_graph_.c
|
||||||
reader_.c: reader.c $(ANSI2KNR)
|
reader_.c: reader.c $(ANSI2KNR)
|
||||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/reader.c; then echo $(srcdir)/reader.c; else echo reader.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > reader_.c
|
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/reader.c; then echo $(srcdir)/reader.c; else echo reader.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > reader_.c
|
||||||
reduce_.c: reduce.c $(ANSI2KNR)
|
reduce_.c: reduce.c $(ANSI2KNR)
|
||||||
@@ -269,14 +272,17 @@ strspn_.c: strspn.c $(ANSI2KNR)
|
|||||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strspn.c; then echo $(srcdir)/strspn.c; else echo strspn.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strspn_.c
|
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strspn.c; then echo $(srcdir)/strspn.c; else echo strspn.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strspn_.c
|
||||||
symtab_.c: symtab.c $(ANSI2KNR)
|
symtab_.c: symtab.c $(ANSI2KNR)
|
||||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/symtab.c; then echo $(srcdir)/symtab.c; else echo symtab.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > symtab_.c
|
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/symtab.c; then echo $(srcdir)/symtab.c; else echo symtab.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > symtab_.c
|
||||||
|
vcg_.c: vcg.c $(ANSI2KNR)
|
||||||
|
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/vcg.c; then echo $(srcdir)/vcg.c; else echo vcg.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > vcg_.c
|
||||||
vmsgetargs_.c: vmsgetargs.c $(ANSI2KNR)
|
vmsgetargs_.c: vmsgetargs.c $(ANSI2KNR)
|
||||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/vmsgetargs.c; then echo $(srcdir)/vmsgetargs.c; else echo vmsgetargs.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > vmsgetargs_.c
|
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/vmsgetargs.c; then echo $(srcdir)/vmsgetargs.c; else echo vmsgetargs.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > vmsgetargs_.c
|
||||||
warshall_.c: warshall.c $(ANSI2KNR)
|
warshall_.c: warshall.c $(ANSI2KNR)
|
||||||
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/warshall.c; then echo $(srcdir)/warshall.c; else echo warshall.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > warshall_.c
|
$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/warshall.c; then echo $(srcdir)/warshall.c; else echo warshall.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > warshall_.c
|
||||||
LR0_.o alloca_.o closure_.o complain_.o conflicts_.o derives_.o \
|
LR0_.o alloca_.o closure_.o complain_.o conflicts_.o derives_.o \
|
||||||
files_.o getargs_.o gram_.o lalr_.o lex_.o main_.o memchr_.o \
|
files_.o getargs_.o gram_.o lalr_.o lex_.o main_.o memchr_.o \
|
||||||
nullable_.o output_.o print_.o reader_.o reduce_.o stpcpy_.o strndup_.o \
|
nullable_.o output_.o print_.o print_graph_.o reader_.o reduce_.o \
|
||||||
strnlen_.o strspn_.o symtab_.o vmsgetargs_.o warshall_.o : $(ANSI2KNR)
|
stpcpy_.o strndup_.o strnlen_.o strspn_.o symtab_.o vcg_.o \
|
||||||
|
vmsgetargs_.o warshall_.o : $(ANSI2KNR)
|
||||||
|
|
||||||
install-pkgdataDATA: $(pkgdata_DATA)
|
install-pkgdataDATA: $(pkgdata_DATA)
|
||||||
@$(NORMAL_INSTALL)
|
@$(NORMAL_INSTALL)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Open and close files for bison,
|
/* Open and close files for bison,
|
||||||
Copyright 1984, 1986, 1989, 1992, 2000 Free Software Foundation, Inc.
|
Copyright 1984, 1986, 1989, 1992, 2000, 2001 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@ struct obstack table_obstack;
|
|||||||
struct obstack defines_obstack;
|
struct obstack defines_obstack;
|
||||||
struct obstack guard_obstack;
|
struct obstack guard_obstack;
|
||||||
struct obstack output_obstack;
|
struct obstack output_obstack;
|
||||||
|
struct obstack graph_obstack;
|
||||||
|
|
||||||
char *spec_outfile = NULL; /* for -o. */
|
char *spec_outfile = NULL; /* for -o. */
|
||||||
char *spec_file_prefix = NULL; /* for -b. */
|
char *spec_file_prefix = NULL; /* for -b. */
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ extern struct obstack guard_obstack;
|
|||||||
/* The verbose output. */
|
/* The verbose output. */
|
||||||
extern struct obstack output_obstack;
|
extern struct obstack output_obstack;
|
||||||
|
|
||||||
|
/* The VCG graph output. */
|
||||||
|
extern struct obstack graph_obstack;
|
||||||
|
|
||||||
extern char *infile;
|
extern char *infile;
|
||||||
extern char *attrsfile;
|
extern char *attrsfile;
|
||||||
|
|||||||
@@ -34,11 +34,12 @@ int token_table_flag = 0;
|
|||||||
int verbose_flag = 0;
|
int verbose_flag = 0;
|
||||||
int statistics_flag = 0;
|
int statistics_flag = 0;
|
||||||
int yacc_flag = 0; /* for -y */
|
int yacc_flag = 0; /* for -y */
|
||||||
|
int graph_flag = 0;
|
||||||
|
|
||||||
const char *skeleton = NULL;
|
const char *skeleton = NULL;
|
||||||
|
|
||||||
extern char *program_name;
|
extern char *program_name;
|
||||||
const char *shortopts = "yvdhrltknVo:b:p:S:";
|
const char *shortopts = "yvgdhrltknVo:b:p:S:";
|
||||||
static struct option longopts[] =
|
static struct option longopts[] =
|
||||||
{
|
{
|
||||||
/* Operation modes. */
|
/* Operation modes. */
|
||||||
@@ -63,6 +64,7 @@ static struct option longopts[] =
|
|||||||
{"verbose", no_argument, 0, 'v'},
|
{"verbose", no_argument, 0, 'v'},
|
||||||
{"file-prefix", required_argument, 0, 'b'},
|
{"file-prefix", required_argument, 0, 'b'},
|
||||||
{"output-file", required_argument, 0, 'o'},
|
{"output-file", required_argument, 0, 'o'},
|
||||||
|
{"graph", no_argument, 0, 'g'},
|
||||||
|
|
||||||
/* Hidden. */
|
/* Hidden. */
|
||||||
{"statistics", no_argument, &statistics_flag, 1},
|
{"statistics", no_argument, &statistics_flag, 1},
|
||||||
@@ -178,6 +180,10 @@ getargs (int argc, char *argv[])
|
|||||||
version (stdout);
|
version (stdout);
|
||||||
exit (0);
|
exit (0);
|
||||||
|
|
||||||
|
case 'g':
|
||||||
|
graph_flag = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose_flag = 1;
|
verbose_flag = 1;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ extern int no_parser_flag; /* for -n */
|
|||||||
extern int statistics_flag;
|
extern int statistics_flag;
|
||||||
extern int token_table_flag; /* for -k */
|
extern int token_table_flag; /* for -k */
|
||||||
extern int verbose_flag; /* for -v */
|
extern int verbose_flag; /* for -v */
|
||||||
|
extern int graph_flag; /* for -g */
|
||||||
extern int yacc_flag; /* for -y */
|
extern int yacc_flag; /* for -y */
|
||||||
|
|
||||||
void getargs PARAMS ((int argc, char *argv[]));
|
void getargs PARAMS ((int argc, char *argv[]));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Output a VCG description on generated parser, for bison,
|
/* Output a VCG description on generated parser, for Bison,
|
||||||
Copyright 1984, 1986, 1989, 2000, 2001 Free Software Foundation, Inc.
|
Copyright 2001 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|
||||||
@@ -239,4 +239,3 @@ print_graph (void)
|
|||||||
/* Close graph. */
|
/* Close graph. */
|
||||||
close_graph (&graph, &graph_obstack);
|
close_graph (&graph, &graph_obstack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user