* lib/readpipe.c: New, from wdiff.
* src/Makefile.am (DEFS): Define PKGDATADIR, not BISON_SIMPLE and
BISON_HAIRY.
* src/system.h (BISON_HAIRY, BISON_SIMPLE): Remove the DOS and VMS
specific values. Now it is m4 that performs the lookup.
* src/parse-skel.y: Remove.
* src/muscle_tab.c, src/muscle_tab.h (muscles_m4_output): New.
* src/output.c (actions_output, guards_output)
(token_definitions_output): No longer keeps track of the output
line number, hence remove the second argument.
(guards_output): Check against the guard member of a rule, not the
action member.
Adjust callers.
(output_skeleton): Don't look for the skeleton location, let m4 do
that.
Create `/tmp/muscles.m4'. This is temporary, a proper temporary
file will be used.
Invoke `m4' on m4sugar.m4, muscles.m4, and the skeleton.
(prepare): Given that for the time being changesyntax is not
usable in M4, rename the muscles using `-' to `_'.
Define `defines_flag', `output_parser_name' and `output_header_name'.
* src/output.h (actions_output, guards_output)
(token_definitions_output): Adjust prototypes.
* src/scan-skel.l: Instead of scanning the skeletons, it now
processes the output of m4: `__oline__' and `#output'.
* data/bison.simple: Adjust to be used by M4(sugar).
* tests/Makefile.am: Use check_SCRIPTS to make sure `bison' is up
to date.
* tests/bison.in: Use the secrete envvar `BISON_PKGDATADIR'
instead of the dead `BISON_SIMPLE' and `BISON_HAIRY'.
* data/m4sugar/m4sugar.m4, data/m4sugar/version.m4: New,
shamelessly stolen from CVS Autoconf.
+2002-02-05 Akim Demaille <akim@epita.fr>
+
+ Give a try to M4 as a back end.
+
+ * lib/readpipe.c: New, from wdiff.
+ * src/Makefile.am (DEFS): Define PKGDATADIR, not BISON_SIMPLE and
+ BISON_HAIRY.
+ * src/system.h (BISON_HAIRY, BISON_SIMPLE): Remove the DOS and VMS
+ specific values. Now it is m4 that performs the lookup.
+ * src/parse-skel.y: Remove.
+ * src/muscle_tab.c, src/muscle_tab.h (muscles_m4_output): New.
+ * src/output.c (actions_output, guards_output)
+ (token_definitions_output): No longer keeps track of the output
+ line number, hence remove the second argument.
+ (guards_output): Check against the guard member of a rule, not the
+ action member.
+ Adjust callers.
+ (output_skeleton): Don't look for the skeleton location, let m4 do
+ that.
+ Create `/tmp/muscles.m4'. This is temporary, a proper temporary
+ file will be used.
+ Invoke `m4' on m4sugar.m4, muscles.m4, and the skeleton.
+ (prepare): Given that for the time being changesyntax is not
+ usable in M4, rename the muscles using `-' to `_'.
+ Define `defines_flag', `output_parser_name' and `output_header_name'.
+ * src/output.h (actions_output, guards_output)
+ (token_definitions_output): Adjust prototypes.
+ * src/scan-skel.l: Instead of scanning the skeletons, it now
+ processes the output of m4: `__oline__' and `#output'.
+ * data/bison.simple: Adjust to be used by M4(sugar).
+ * tests/Makefile.am: Use check_SCRIPTS to make sure `bison' is up
+ to date.
+ * tests/bison.in: Use the secrete envvar `BISON_PKGDATADIR'
+ instead of the dead `BISON_SIMPLE' and `BISON_HAIRY'.
+ * data/m4sugar/m4sugar.m4, data/m4sugar/version.m4: New,
+ shamelessly stolen from CVS Autoconf.
+
+
2002-02-05 Akim Demaille <akim@epita.fr>
* lib/hash.c, lib/hash.h: Replace with Fileutils 4.1's version.
## 02111-1307 USA
dist_pkgdata_DATA = bison.simple bison.hairy bison.c++
+
+m4sugardir = $(pkgdatadir)/m4sugar
+dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/version.m4
-%%{section} %%{output-prefix} %%{output-infix} %%".c"
-/* -*- C -*- */
+m4_divert(-1)
-/* A Bison parser, made from %%{filename}
- by GNU bison %%{version}. */
+# m4_define_default(MACRO, VALUE)
+# -------------------------------
+# Define MACRO to VALUE, unless already defined.
+m4_define([m4_define_default],
+[m4_ifdef([$1], [], [m4_define($@)])])
-/* Skeleton output parser for bison,
+m4_define_default([b4_input_suffix], [.y])
+m4_define_default([b4_output_parser_suffix],
+[m4_translit(b4_input_suffix, [yY], [cC])])
+
+m4_define_default([b4_output_parser_name],
+[b4_output_prefix[]b4_output_infix[]b4_output_parser_suffix[]])
+
+
+m4_define_default([b4_output_header_suffix],
+[m4_translit(b4_input_suffix, [yY], [hH])])
+
+m4_define_default([b4_output_header_name],
+[b4_output_prefix[]b4_output_infix[]b4_output_header_suffix[]])
+
+m4_define_default([b4_header_guard],
+ [m4_bpatsubst(m4_toupper([BISON_]b4_output_header_name),
+ [[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]], [_])])
+
+m4_divert(0)dnl
+#output "b4_output_parser_name"
+/* A Bison parser, made from b4_filename
+ by GNU bison b4_version. */
+
+/* Skeleton output parser for Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
Foundation, Inc.
#define YYBISON 1
/* Pure parsers. */
-#define YYPURE %%{pure}
+#define YYPURE b4_pure
/* Using locations. */
-#define YYLSP_NEEDED %%{locations-flag}
+#define YYLSP_NEEDED b4_locations_flag
-/* If NAME_PREFIX is specified substitute the variables and functions
+m4_if(b4_prefix[], [yy], [],
+[/* If NAME_PREFIX is specified substitute the variables and functions
names. */
-#define yyparse %%{prefix}parse
-#define yylex %%{prefix}lex
-#define yyerror %%{prefix}error
-#define yylval %%{prefix}lval
-#define yychar %%{prefix}char
-#define yydebug %%{prefix}debug
-#define yynerrs %%{prefix}nerrs
+#define yyparse b4_prefix[]parse
+#define yylex b4_prefix[]lex
+#define yyerror b4_prefix[]error
+#define yylval b4_prefix[]lval
+#define yychar b4_prefix[]char
+#define yydebug b4_prefix[]debug
+#define yynerrs b4_prefix[]nerrs
#if YYLSP_NEEDED
-# define yylloc %%{prefix}lloc
+# define yylloc b4_prefix[]lloc
#endif
-
+])
/* Copy the user declarations. */
-%%{prologue}
+b4_prologue
/* Enabling traces. */
#ifndef YYDEBUG
-# define YYDEBUG %%{debug}
+# define YYDEBUG b4_debug
#endif
/* Enabling verbose error messages. */
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
-# define YYERROR_VERBOSE %%{error-verbose}
+# define YYERROR_VERBOSE b4_error_verbose
#endif
#ifndef YYSTYPE
-typedef %%{stype} yystype;
+typedef b4_stype yystype;
# define YYSTYPE yystype
#endif
int last_line;
int last_column;
} yyltype;
-# define YYLTYPE %%{ltype}
+# define YYLTYPE b4_ltype
#endif
-/* Line %%{skeleton-line} of %%{skeleton}. */
-#line %%{line} "%%{parser-file-name}"
+/* Line __line__ of __file__. */
+#line __oline__ "b4_output_parser_name"
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
/* Tokens. */
-%%{tokendef}
+b4_tokendef
/* YYFINAL -- State number of the termination state. */
-#define YYFINAL %%{final}
-#define YYFLAG %%{flag}
-#define YYLAST %%{last}
+#define YYFINAL b4_final
+#define YYFLAG b4_flag
+#define YYLAST b4_last
/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS %%{ntokens}
+#define YYNTOKENS b4_ntokens
/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS %%{nnts}
+#define YYNNTS b4_nnts
/* YYNRULES -- Number of rules. */
-#define YYNRULES %%{nrules}
+#define YYNRULES b4_nrules
/* YYNRULES -- Number of states. */
-#define YYNSTATES %%{nstates}
-#define YYMAXUTOK %%{maxtok}
+#define YYNSTATES b4_nstates
+#define YYMAXUTOK b4_maxtok
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
-#define YYTRANSLATE(x) ((unsigned)(x) <= %%{maxtok} ? yytranslate[x] : %%{nsym})
+#define YYTRANSLATE(x) ((unsigned)(x) <= b4_maxtok ? yytranslate[[x]] : b4_nsym)
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
-static const char yytranslate[] =
+/* YYTRANSLATE[[YYLEX]] -- Bison symbol number corresponding to YYLEX. */
+static const char yytranslate[[]] =
{
- %%{translate}
+ b4_translate
};
#if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+/* YYPRHS[[YYN]] -- Index of the first RHS symbol of rule number YYN in
YYRHS. */
-static const short yyprhs[] =
+static const short yyprhs[[]] =
{
- %%{prhs}
+ b4_prhs
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const short yyrhs[] =
+static const short yyrhs[[]] =
{
- %%{rhs}
+ b4_rhs
};
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const short yyrline[] =
+/* YYRLINE[[YYN]] -- source line where rule number YYN was defined. */
+static const short yyrline[[]] =
{
- %%{rline}
+ b4_rline
};
#endif
#if (YYDEBUG) || YYERROR_VERBOSE
-/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+/* YYTNME[[SYMBOL-NUM]] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
+static const char *const yytname[[]] =
{
- %%{tname}
+ b4_tname
};
#endif
-/* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
-static const short yytoknum[] =
+/* YYTOKNUM[[YYN]] -- Index in YYTNAME corresponding to YYLEX. */
+static const short yytoknum[[]] =
{
- %%{toknum}
+ b4_toknum
};
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const short yyr1[] =
+/* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives. */
+static const short yyr1[[]] =
{
- %%{r1}
+ b4_r1
};
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const short yyr2[] =
+/* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN. */
+static const short yyr2[[]] =
{
- %%{r2}
+ b4_r2
};
-/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
+/* YYDEFACT[[S]] -- default rule to reduce with in state S when YYTABLE
doesn't specify something else to do. Zero means the default is an
error. */
-static const short yydefact[] =
+static const short yydefact[[]] =
{
- %%{defact}
+ b4_defact
};
-/* YYPGOTO[NTERM-NUM]. */
-static const short yydefgoto[] =
+/* YYPGOTO[[NTERM-NUM]]. */
+static const short yydefgoto[[]] =
{
- %%{defgoto}
+ b4_defgoto
};
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+/* YYPACT[[STATE-NUM]] -- Index in YYTABLE of the portion describing
STATE-NUM. */
-static const short yypact[] =
+static const short yypact[[]] =
{
- %%{pact}
+ b4_pact
};
-/* YYPGOTO[NTERM-NUM]. */
-static const short yypgoto[] =
+/* YYPGOTO[[NTERM-NUM]]. */
+static const short yypgoto[[]] =
{
- %%{pgoto}
+ b4_pgoto
};
-/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+/* YYTABLE[[YYPACT[STATE-NUM]]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If zero, do what YYDEFACT says. */
-static const short yytable[] =
+static const short yytable[[]] =
{
- %%{table}
+ b4_table
};
-static const short yycheck[] =
+static const short yycheck[[]] =
{
- %%{check}
+ b4_check
};
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
- Current.last_line = Rhs[N].last_line; \
- Current.last_column = Rhs[N].last_column;
+ Current.last_line = Rhs[[N]].last_line; \
+ Current.last_column = Rhs[[N]].last_column;
#endif
/* YYLEX -- calling `yylex' with the right arguments. */
if (yydebug) \
YYFPRINTF Args; \
} while (0)
-/* Nonzero means print parse trace. [The following comment makes no
- sense to me. Could someone clarify it? --akim] Since this is
- uninitialized, it does not stop multiple parsers from coexisting.
- */
+/* Nonzero means print parse trace. Since this is uninitialized, it
+ does not stop multiple parsers from coexisting. */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
-# define YYINITDEPTH %%{initdepth}
+# define YYINITDEPTH b4_initdepth
#endif
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
#endif
#ifndef YYMAXDEPTH
-# define YYMAXDEPTH %%{maxdepth}
+# define YYMAXDEPTH b4_maxdepth
#endif
\f
int
yyparse (YYPARSE_PARAM_ARG)
YYPARSE_PARAM_DECL
-{
+{[
/* If reentrant, generate the variables here. */
#if YYPURE
YY_DECL_VARIABLES
}
#endif
switch (yyn)
- {
- %%{actions}
+ ]{
+ b4_actions
}
-/* Line %%{skeleton-line} of %%{skeleton}. */
-#line %%{line} "%%{parser-file-name}"
+/* Line __line__ of __file__. */
+#line __oline__ "b4_output_parser_name"
\f
- yyvsp -= yylen;
+[ yyvsp -= yylen;
yyssp -= yylen;
#if YYLSP_NEEDED
yylsp -= yylen;
YYSTACK_FREE (yyss);
#endif
return yyresult;
-}
+]}
+
+b4_epilogue
+m4_if(b4_defines_flag, 0, [],
+[#output "b4_output_header_name"
+#ifndef b4_header_guard
+# define b4_header_guard
+
+b4_tokendef
+
+#ifndef YYSTYPE
+typedef b4_stype
+yystype;
+# define YYSTYPE yystype
+#endif
+
+m4_if(b4_pure, [0],
+[extern YYSTYPE b4_prefix[]lval;])
+
+m4_if(b4_locations_flag, [0], [],
+[#ifndef YYLTYPE
+typedef struct yyltype
+{
+ int first_line;
+ int first_column;
+ int last_line;
+ int last_column;
+} yyltype;
+# define YYLTYPE yyltype
+#endif
-%%{epilogue}
+m4_if(b4_pure, [0],
+[extern YYLTYPE b4_prefix[]lloc;])
+])
+#endif /* not b4_header_guard */
+])
-## Copyright 2001, 2002 Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
getopt.h getopt.c getopt1.c \
hash.h hash.c \
quote.h quote.c quotearg.h quotearg.c \
- xalloc.h xmalloc.c xstrdup.c xstrndup.c
+ xalloc.h xmalloc.c xstrdup.c xstrndup.c \
+ readpipe.c
libbison_a_LIBADD = @LIBOBJS@ @ALLOCA@
libbison_a_DEPENDENCIES = $(libbison_a_LIBADD)
-## Copyright 2001 Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
AUTOMAKE_OPTIONS = ../lib/ansi2knr
DEFS = @DEFS@ \
- -DBISON_SIMPLE=\"$(pkgdatadir)/bison.simple\" \
- -DBISON_HAIRY=\"$(pkgdatadir)/bison.hairy\" \
+ -DPKGDATADIR=\"$(pkgdatadir)\" \
-DLOCALEDIR=\"$(datadir)/locale\"
CFLAGS = @CFLAGS@ $(WARNING_CFLAGS) $(WERROR_CFLAGS)
muscle_tab.h muscle_tab.c \
options.h options.c \
print.c reader.c reduce.c symtab.c warshall.c vcg.c \
- skeleton.h parse-skel.h parse-skel.y scan-skel.l
+ scan-skel.l
-BUILT_SOURCES = parse-skel.c scan-skel.c
+BUILT_SOURCES = scan-skel.c
EXTRA_bison_SOURCES = vmsgetargs.c
muscle_entry_t *result = hash_lookup (muscle_table, &pair);
return result ? result->value : NULL;
}
+
+
+/* Output the definition of all the current muscles into a list of
+ m4_defines. */
+
+static void
+muscle_m4_output (muscle_entry_t *entry, FILE *out)
+{
+ fprintf (out, "m4_define([b4_%s],\n", entry->key);
+ fprintf (out, " [[%s]])\n\n\n", entry->value);
+}
+
+
+/* Output the definition of all the current muscles into a list of
+ m4_defines. */
+
+void
+muscles_m4_output (FILE *out)
+{
+ hash_do_for_each (muscle_table,
+ (Hash_processor) muscle_m4_output,
+ out);
+}
/* Definitions for macrotab.c and callers, part of bison,
- Copyright 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
}
+
+void muscles_m4_output PARAMS ((FILE *out));
+
#endif /* not MUSCLE_TAB_H_ */
#include "system.h"
#include "quotearg.h"
+#include "error.h"
#include "getargs.h"
#include "files.h"
#include "gram.h"
#include "symtab.h"
#include "conflicts.h"
#include "muscle_tab.h"
-#include "skeleton.h"
+
+/* From lib/readpipe.h. */
+FILE *readpipe PARAMS ((const char *, ...));
+
+/* From src/scan-skel.l. */
+int skel_lex PARAMS ((void));
+extern FILE *skel_in;
static int nvectors;
static int nentries;
`-----------------------------*/
void
-actions_output (FILE *out, size_t *line)
+actions_output (FILE *out)
{
int rule;
for (rule = 1; rule < nrules + 1; ++rule)
fprintf (out, "{ %s%s }\n break;\n\n",
rules[rule].action,
yacc_flag ? ";" : "");
-
- /* We always output 4 '\n' per action. */
- *line += 4;
- /* Plus one if !no_lines_flag. */
- if (!no_lines_flag)
- ++*line;
- /* Get the number of lines written by the user. */
- *line += get_lines_number (rules[rule].action);
}
}
`----------------------------*/
void
-guards_output (FILE *out, size_t *line)
+guards_output (FILE *out)
{
int rule;
for (rule = 1; rule < nrules + 1; ++rule)
- if (rules[rule].action)
+ if (rules[rule].guard)
{
fprintf (out, " case %d:\n", rule);
muscle_find ("filename")));
fprintf (out, "{ %s; }\n break;\n\n",
rules[rule].guard);
-
- /* We always output 4 '\n' per action. */
- *line += 4;
- /* Plus one if !no_lines_flag. */
- if (!no_lines_flag)
- ++*line;
- /* Get the number of lines written by the user. */
- *line += get_lines_number (rules[rule].guard);
}
}
`---------------------------------------*/
void
-token_definitions_output (FILE *out, size_t *line)
+token_definitions_output (FILE *out)
{
int i;
for (i = 0; i < ntokens; ++i)
fprintf (out, "# define %s\t%d\n",
symbol->tag, number);
- ++*line;
if (semantic_parser)
- {
- /* FIXME: This is probably wrong, and should be just as
- above. --akim. */
- fprintf (out, "# define T%s\t%d\n", symbol->tag, symbol->value);
- ++*line;
- }
+ /* FIXME: This is probably wrong, and should be just as
+ above. --akim. */
+ fprintf (out, "# define T%s\t%d\n", symbol->tag, symbol->value);
}
}
if (!skeleton)
{
if (semantic_parser)
- skeleton = skeleton_find ("BISON_HAIRY", BISON_HAIRY);
+ skeleton = "bison.hairy";
else
- skeleton = skeleton_find ("BISON_SIMPLE", BISON_SIMPLE);
+ skeleton = "bison.simple";
}
/* Parse the skeleton file and output the needed parsers. */
muscle_insert ("skeleton", skeleton);
- process_skeleton (skeleton);
+
+ /* Store the definition of all the muscles. */
+ {
+ FILE *muscles_m4 = xfopen ("/tmp/muscles.m4", "w");
+ /* There are no comments, especially not `#': we do want M4 expansion
+ after `#': think of CPP macros! */
+ fprintf (muscles_m4, "m4_changecom()\n");
+ fprintf (muscles_m4, "m4_init()\n");
+
+ fprintf (muscles_m4, "m4_define([b4_actions], \n[[");
+ actions_output (muscles_m4);
+ fprintf (muscles_m4, "]])\n\n");
+
+ fprintf (muscles_m4, "m4_define([b4_guards], \n[[");
+ guards_output (muscles_m4);
+ fprintf (muscles_m4, "]])\n\n");
+
+ fprintf (muscles_m4, "m4_define([b4_tokendef], \n[[");
+ token_definitions_output (muscles_m4);
+ fprintf (muscles_m4, "]])\n\n");
+
+ muscles_m4_output (muscles_m4);
+
+ fprintf (muscles_m4, "m4_wrap([m4_divert_pop(0)])\n");
+ fprintf (muscles_m4, "m4_divert_push(0)dnl\n");
+ xfclose (muscles_m4);
+ }
+
+ /* Invoke m4 on the definition of the muscles, and the skeleton. */
+ {
+ const char *bison_pkgdatadir = getenv ("BISON_PKGDATADIR");
+ if (!bison_pkgdatadir)
+ bison_pkgdatadir = PKGDATADIR;
+ skel_in = readpipe ("m4",
+ "-I",
+ bison_pkgdatadir,
+ "m4sugar/m4sugar.m4",
+ "/tmp/muscles.m4",
+ skeleton,
+ NULL);
+ if (!skel_in)
+ error (EXIT_FAILURE, errno, "cannot run m4");
+ skel_lex ();
+ }
}
static void
MUSCLE_INSERT_INT ("debug", debug_flag);
MUSCLE_INSERT_INT ("final", final_state);
MUSCLE_INSERT_INT ("maxtok", max_user_token_number);
- MUSCLE_INSERT_INT ("error-verbose", error_verbose);
+ MUSCLE_INSERT_INT ("error_verbose", error_verbose);
MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy");
/* FIXME: This is wrong: the muscles should decide whether they hold
a copy or not, but the situation is too obscure currently. */
- MUSCLE_INSERT_STRING ("output-infix", output_infix ? output_infix : "");
- MUSCLE_INSERT_STRING ("output-prefix", short_base_name);
+ MUSCLE_INSERT_STRING ("output_infix", output_infix ? output_infix : "");
+ MUSCLE_INSERT_STRING ("output_prefix", short_base_name);
+ MUSCLE_INSERT_STRING ("output_parser_name", parser_file_name);
+ MUSCLE_INSERT_STRING ("output_header_name", spec_defines_file);
MUSCLE_INSERT_INT ("nnts", nvars);
MUSCLE_INSERT_INT ("nrules", nrules);
MUSCLE_INSERT_INT ("nstates", nstates);
MUSCLE_INSERT_INT ("ntokens", ntokens);
- MUSCLE_INSERT_INT ("locations-flag", locations_flag);
+ MUSCLE_INSERT_INT ("locations_flag", locations_flag);
+ MUSCLE_INSERT_INT ("defines_flag", defines_flag);
}
/*-------------------------.
static void
header_output (void)
{
- size_t dummy_line;
FILE *out = xfopen (spec_defines_file, "w");
char *macro_name = compute_header_macro ();
fprintf (out, "#ifndef %s\n", macro_name);
fprintf (out, "# define %s\n\n", macro_name);
- token_definitions_output (out, &dummy_line);
+ token_definitions_output (out);
fprintf (out, "\
#ifndef YYSTYPE\n\
typedef %s
output_skeleton ();
/* Output the header if needed. */
- if (defines_flag)
+
+ if (0)
header_output ();
free (rules + 1);
size_t get_lines_number PARAMS ((const char *s));
-void actions_output PARAMS ((FILE *out, size_t *line));
-void guards_output PARAMS ((FILE *out, size_t *line));
-void token_definitions_output PARAMS ((FILE *out, size_t *line));
+void actions_output PARAMS ((FILE *out));
+void guards_output PARAMS ((FILE *out));
+void token_definitions_output PARAMS ((FILE *out));
extern struct obstack muscle_obstack;
- /* -*- C -*- */
-/* Scan Bison Skeletons.
- Copyright (C) 2001 Free Software Foundation, Inc.
+/* Scan Bison Skeletons. -*- C -*-
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
-%option debug nodefault noyywrap nounput
+%option nodefault noyywrap nounput
%option prefix="skel_" outfile="lex.yy.c"
-/* If we enable
-
- %option yylineno
-
- Then we have warning: `yy_flex_realloc' defined but not used.
- Seems like a Flex bug to me: Why the heck yylineno would trigger
- the REJECT exception??? */
-
%{
#include "system.h"
-#include "skeleton.h"
-#include "parse-skel.h"
-%}
-
-%{
-/* Each time we match a string, move the end cursor to its end. */
-#define YY_USER_ACTION yylloc->last_column += yyleng;
+#include "files.h"
+int skel_lex PARAMS ((void));
+static int yylineno = 1;
%}
%%
-%{
- /* At each yylex invocation, mark the current position as the
- start of the next token. */
- LOCATION_STEP (*yylloc);
-%}
-
-"%%{line}" { return LINE; }
-"%%{skeleton-line}" { return SLINE; }
-
-"%%{section}" { return SECTION; }
-
-"%%{guards}" { return GUARDS; }
-"%%{actions}" { return ACTIONS; }
-"%%{tokendef}" { return TOKENS; }
-
- /* Muscle. */
-"%%{"[a-zA-Z][0-9a-zA-Z_-]+"}" {
- yylval->string = xstrndup (yytext + 3, yyleng - 4);
- return MUSCLE;
-}
-
- /* String. */
-"%%\"".*"\"" {
- yylval->string = xstrndup (yytext + 3, yyleng - 4);
- return STRING;
-}
-
- /* End of line. */
-"\n" {
- LOCATION_LINES (*yylloc, yyleng);
- return '\n';
-}
-
- /* White spaces. */
-[\t ]+ {
- yylval->string = yytext;
- return BLANKS;
-}
-
- /* Plain Characters. */
-[^%\n]+ {
- yylval->string = yytext;
- return RAW;
-}
-
- /* Plain Character. */
-. {
- yylval->character = *yytext;
- return CHARACTER;
-}
+ /* This is an approximation, but we don't need more. */
+^"#output \""[^\"]+\"\n {
+ yytext[yyleng - 2] = '\0';
+ skel_out = xfopen (yytext + strlen ("#output \""), "w");
+ yylineno = 1;
+ }
+
+"__oline__" fprintf (yyout, "%d", yylineno);
+[^_\n]+ ECHO;
+\n+ yylineno += yyleng; ECHO;
+. ECHO;
%%
# endif /* ! MSDOS */
#endif /* ! VMS */
-#if defined (VMS) & !defined (__VMS_POSIX)
-# ifndef BISON_SIMPLE
-# define BISON_SIMPLE "GNU_BISON:[000000]BISON.SIMPLE"
-# endif
-# ifndef BISON_HAIRY
-# define BISON_HARIRY "GNU_BISON:[000000]BISON.HAIRY"
-# endif
-#endif
-
-#if defined (_MSC_VER)
-# ifndef BISON_SIMPLE
-# define BISON_SIMPLE "c:/usr/local/lib/bison.simple"
-# endif
-# ifndef BISON_HAIRY
-# define BISON_HAIRY "c:/usr/local/lib/bison.hairy"
-# endif
-#endif
-
-
/* As memcpy, but for shorts. */
#define shortcpy(Dest, Src, Num) \
memcpy (Dest, Src, Num * sizeof (short))
EXTRA_DIST = $(TESTSUITE_AT) testsuite
-DISTCLEANFILES = atconfig bison
+DISTCLEANFILES = atconfig $(check_SCRIPTS)
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
## ------------ ##
check-local: atconfig atlocal $(TESTSUITE)
$(SHELL) $(TESTSUITE)
+check_SCRIPTS = bison
+
# Run the test suite on the *installed* tree.
installcheck-local:
$(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
-#! /bin/sh
+#! @SHELL@
# @configure_input@
# Wrapper around a non installed bison to make it work as an installed one.
# We want to use the files shipped with Bison.
-BISON_SIMPLE='@abs_top_srcdir@/data/bison.simple'
-export BISON_SIMPLE
-BISON_HAIRY='@abs_top_srcdir@/data/bison.hairy'
-export BISON_HAIRY
-
+BISON_PKGDATADIR='@abs_top_srcdir@/data'
+export BISON_PKGDATADIR
exec '@abs_top_builddir@/src/bison' ${1+"$@"}