summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Estes <wlestes@users.sourceforge.net>2003-03-25 16:39:08 +0000
committerWill Estes <wlestes@users.sourceforge.net>2003-03-25 16:39:08 +0000
commit2ea243b80a5a443c533e5f621b0d5a52790a97dc (patch)
tree143d0b83ae5384eee2a8751331d87a5804e71dfa
parent7b2d2bd3f031a8c85feafb106cf9ddf0efe28698 (diff)
merge millaway's m4 branch work
-rw-r--r--FlexLexer.h6
-rw-r--r--Makefile.am7
-rw-r--r--TODO12
-rw-r--r--buf.c64
-rw-r--r--configure.in1
-rw-r--r--doc/flex.texi119
-rw-r--r--filter.c380
-rw-r--r--flex.skl1701
-rw-r--r--flexdef.h61
-rw-r--r--gen.c56
-rw-r--r--main.c464
-rw-r--r--misc.c57
-rw-r--r--options.c10
-rw-r--r--options.h4
-rw-r--r--regex.c164
-rw-r--r--scan.l83
-rw-r--r--sym.c3
-rw-r--r--tests/test-bison-nr/scanner.l2
-rw-r--r--tests/test-bison-yylloc/scanner.l2
-rw-r--r--tests/test-reject/scanner.l34
-rw-r--r--tests/test-table-opts/scanner.l34
21 files changed, 2181 insertions, 1083 deletions
diff --git a/FlexLexer.h b/FlexLexer.h
index 12e0dc4..3a1025c 100644
--- a/FlexLexer.h
+++ b/FlexLexer.h
@@ -172,9 +172,9 @@ protected:
int yy_did_buffer_switch_on_eof;
- size_t yy_buffer_stack_top; /*<< index of top of stack. */
- size_t yy_buffer_stack_max; /*<< capacity of stack. */
- struct yy_buffer_state ** yy_buffer_stack; /*<< Stack as an array. */
+ size_t yy_buffer_stack_top; /**< index of top of stack. */
+ size_t yy_buffer_stack_max; /**< capacity of stack. */
+ struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
void yyensure_buffer_stack(void);
// The following are not always needed, but may be depending
diff --git a/Makefile.am b/Makefile.am
index abe912e..c85f365 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,7 +65,9 @@ flex_SOURCES = \
scanopt.c \
buf.c \
tables.c \
- tables_shared.c
+ tables_shared.c \
+ filter.c \
+ regex.c
libfl_a_SOURCES = \
libmain.c \
@@ -142,7 +144,7 @@ AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -I@includedir@ -I$(top_srcdir)/intl
LIBS = @LIBINTL@ @LIBS@
skel.c: flex.skl mkskel.sh flexint.h tables_shared.h
- $(m4) -P -DFLEX_MAJOR_VERSION=`echo $(VERSION)|cut -f 1 -d .` -DFLEX_MINOR_VERSION=`echo $(VERSION)|cut -f 2 -d .` -DFLEX_SUBMINOR_VERSION=`echo $(VERSION)|cut -f 3 -d .` $(srcdir)/flex.skl | $(SHELL) $(srcdir)/mkskel.sh >skel.c
+ sed 's/m4_/m4postproc_/g; s/m4preproc_/m4_/g' $(srcdir)/flex.skl | $(m4) -P -DFLEX_MAJOR_VERSION=`echo $(VERSION)|cut -f 1 -d .` -DFLEX_MINOR_VERSION=`echo $(VERSION)|cut -f 2 -d .` -DFLEX_SUBMINOR_VERSION=`echo $(VERSION)|cut -f 3 -d .` | sed 's/m4postproc_/m4_/g' | $(SHELL) $(srcdir)/mkskel.sh >skel.c
# Explicitly describe dependencies.
# You can recreate this with `gcc -I. -MM *.c'
@@ -168,6 +170,7 @@ tables_shared.o: tables_shared.c flexdef.h flexint.h tables.h \
tables_shared.h
tblcmp.o: tblcmp.c flexdef.h flexint.h
yylex.o: yylex.c flexdef.h flexint.h parse.h
+filter.o: filter.c flexdef.h flexint.h
# Create a tags file.
tags:
diff --git a/TODO b/TODO
index d0b4ca2..4b03822 100644
--- a/TODO
+++ b/TODO
@@ -19,6 +19,8 @@
** pretty up the dvi output; overflows, etc.
+** document recent m4 modifications
+
** faq
*** clean up the faqs section. The information is good; the texinfo
@@ -52,7 +54,11 @@
** make test suite more complete
-** add a test for yypush_buffer_state/yypop_buffer_state
+*** add a test for yypush_buffer_state/yypop_buffer_state
+
+*** add a test for traditional funcs and protos
+
+*** add a test for #line directive integrity
* generic coding
@@ -62,6 +68,10 @@
** figure out whether we want to add the capability to have
auto-generated backout rules
+** token-type and token buffer support
+
+** check if we still need to #undef macros at the end of a header
+
* C++
** have a separate skeleton for c++
diff --git a/buf.c b/buf.c
index c4d3fd1..833837e 100644
--- a/buf.c
+++ b/buf.c
@@ -35,9 +35,24 @@
/* global buffers. */
struct Buf userdef_buf; /* for user #definitions triggered by cmd-line. */
-struct Buf defs_buf; /* for #define's autogenerated. */
+struct Buf defs_buf; /* for #define's autogenerated. List of strings. */
struct Buf yydmap_buf; /* string buffer to hold yydmap elements */
+struct Buf m4defs_buf; /**< Holds m4 definitions. List of strings. */
+struct Buf *buf_print_strings(struct Buf * buf, FILE* out)
+{
+ int i;
+
+ if(!buf || !out)
+ return buf;
+
+ for (i=0; i < buf->nelts; i++){
+ const char * s = ((char**)buf->elts)[i];
+ if(s)
+ fprintf(out, "%s", s);
+ }
+ return buf;
+}
/* Append a "%s" formatted string to a string buffer */
struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s)
@@ -51,6 +66,17 @@ struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s)
return buf;
}
+/** Append the contents of @a src to @a dest.
+ * @param @a dest the destination buffer
+ * @param @a dest the source buffer
+ * @return @a dest
+ */
+struct Buf *buf_concat(struct Buf* dest, const struct Buf* src)
+{
+ buf_append(dest, src->elts, src->nelts);
+ return dest;
+}
+
/* Appends n characters in str to buf. */
struct Buf *buf_strnappend (buf, str, n)
@@ -89,6 +115,42 @@ struct Buf *buf_strdefine (buf, str, def)
return buf;
}
+/** Pushes "m4_define( [[def]], [[val]])m4_dnl" to end of buffer.
+ * @param buf A buffer as a list of strings.
+ * @param def The m4 symbol to define.
+ * @param val The definition; may be NULL.
+ * @return buf
+ */
+struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val)
+{
+ const char * fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n";
+ char * str;
+
+ val = val?val:"";
+ str = (char*)flex_alloc(strlen(fmt) + strlen(def) + strlen(val) + 2);
+
+ sprintf(str, fmt, def, val);
+ buf_append(buf, &str, 1);
+ return buf;
+}
+
+/** Pushes "m4_undefine([[def]])m4_dnl" to end of buffer.
+ * @param buf A buffer as a list of strings.
+ * @param def The m4 symbol to undefine.
+ * @return buf
+ */
+struct Buf *buf_m4_undefine (struct Buf *buf, const char* def)
+{
+ const char * fmt = "m4_undefine( [[%s]])m4_dnl\n";
+ char * str;
+
+ str = (char*)flex_alloc(strlen(fmt) + strlen(def) + 2);
+
+ sprintf(str, fmt, def);
+ buf_append(buf, &str, 1);
+ return buf;
+}
+
/* create buf with 0 elements, each of size elem_size. */
void buf_init (buf, elem_size)
struct Buf *buf;
diff --git a/configure.in b/configure.in
index 821596a..2a684b2 100644
--- a/configure.in
+++ b/configure.in
@@ -60,6 +60,7 @@ else
fi
dnl checks for libraries
+AC_CHECK_LIB(m, log)
dnl checks for header files
diff --git a/doc/flex.texi b/doc/flex.texi
index cd3ecad..9824d08 100644
--- a/doc/flex.texi
+++ b/doc/flex.texi
@@ -1391,8 +1391,8 @@ definitions prevent us from using any standard data types smaller than
int (such as short, char, or bool) as function arguments. For this
reason, future versions of @code{flex} may generate standard C99 code
only, leaving K&R-style functions to the historians. Currently, if you
-do @strong{not} want @samp{C99} definitions, then you must define
-@code{YY_TRADITIONAL_FUNC_DEFS}.
+do @strong{not} want @samp{C99} definitions, then you must use
+@code{%option noansi-definitions}.
@cindex stdin, default for yyin
@cindex yyin
@@ -2394,7 +2394,7 @@ specify the following options:
@example
@verbatim
-%option 8-bit reentrant bison-bridge
+%option 8bit reentrant bison-bridge
%option warn nodefault
%option yylineno
%option outfile="scanner.c" header-file="scanner.h"
@@ -2750,6 +2750,24 @@ calls @code{yylex()} again).
@table @samp
+@anchor{option-ansi-definitions}
+@opindex ---option-ansi-definitions
+@opindex ansi-definitions
+@item --ansi-definitions, @code{%option ansi-definitions}
+instruct flex to generate ANSI C99 definitions for functions.
+This option is enabled by default.
+If @code{%option noansi-definitions} is specified, then the obsolete style
+is generated.
+
+@anchor{option-ansi-prototypes}
+@opindex ---option-ansi-prototypes
+@opindex ansi-prototypes
+@item --ansi-prototypes, @code{%option ansi-prototypes}
+instructs flex to generate ANSI C99 prototypes for functions.
+This option is enabled by default.
+If @code{noansi-prototypes} is specified, then
+prototypes will have empty parameter lists.
+
@anchor{option-bison-bridge}
@opindex ---bison-bridge
@opindex bison-bridge
@@ -2761,13 +2779,20 @@ parser. The scanner has minor API changes for
@code{bison}
compatibility. In particular, the declaration of
@code{yylex}
-is modified, and support for
-@code{yylval}
-and
-@code{yylloc}
-is incorporated. @xref{Bison Bridge}.
-
-
+is modified to take an additional parameter,
+@code{yylval}.
+@xref{Bison Bridge}.
+
+@anchor{option-bison-locations}
+@opindex ---bison-locations
+@opindex bison-locations
+@item --bison-locations, @code{%option bison-locations}
+instruct flex that
+@code{GNU bison} @code{%locations} are being used.
+This means @code{yylex} will be passed
+an additional parameter, @code{yylloc}. This option
+implies @code{%option bison-bridge}.
+@xref{Bison Bridge}.
@anchor{option-noline}
@opindex -L
@@ -4323,25 +4348,33 @@ In a reentrant C scanner, support for yylineno is always present
@code{flex} unless @code{%option yylineno} is enabled. This is to allow
the user to maintain the line count independently of @code{flex}.
+@anchor{bison-functions}
The following functions and macros are made available when @code{%option
bison-bridge} (@samp{--bison-bridge}) is specified:
@example
@verbatim
YYSTYPE * yyget_lval ( yyscan_t scanner );
- YYLTYPE *yyget_lloc ( yyscan_t scanner );
void yyset_lval ( YYSTYPE * yylvalp , yyscan_t scanner );
- void yyset_lloc ( YYLTYPE * yyllocp , yyscan_t scanner );
yylval
+@end verbatim
+@end example
+
+The following functions and macros are made available
+when @code{%option bison-locations} (@samp{--bison-locations}) is specified:
+
+@example
+@verbatim
+ YYLTYPE *yyget_lloc ( yyscan_t scanner );
+ void yyset_lloc ( YYLTYPE * yyllocp , yyscan_t scanner );
yylloc
@end verbatim
@end example
-Support for yylloc is dependent upon the presence of the preprocessor
-symbol @code{YYLTYPE}. Support for yylval relies on the type
-@code{YYSTYPE} to be defined. Typically, these definitions are generated
-by @code{bison}, in a .h file, and are included in section 1 of the
-@code{flex} input.
+Support for yylval assumes that @code{YYSTYPE} is a valid type. Support for
+yylloc assumes that @code{YYSLYPE} is a valid type. Typically, these types are
+generated by @code{bison}, and are included in section 1 of the @code{flex}
+input.
@node Lex and Posix, Memory Management, Reentrant, Top
@chapter Incompatibilities with Lex and Posix
@@ -8086,45 +8119,36 @@ half of the @code{flex} and @code{bison} pair. We do not discuss
A compatible @code{bison} scanner is generated by declaring @samp{%option
bison-bridge} or by supplying @samp{--bison-bridge} when invoking @code{flex}
-from the command line. This instructs @code{flex} that the macros
-@code{yylval} and @code{yylloc} may be used. The data types for
-@code{yylval} and @code{yylloc}, (@code{YYSTYPE} and @code{YYLTYPE},
-are typically defined in a header file, included in section 1 of the
-@code{flex} input file. If @code{%option bison-bridge} is
-specified, @code{flex} provides support for the functions
-@code{yyget_lval}, @code{yyset_lval}, @code{yyget_lloc}, and
-@code{yyset_lloc}, defined below, and the corresponding macros
-@code{yylval} and @code{yylloc}, for use within actions.
-
-@deftypefun YYSTYPE* yyget_lval ( yyscan_t scanner )
-@end deftypefun
-@deftypefun YYLTYPE* yyget_lloc ( yyscan_t scanner )
-@end deftypefun
+from the command line. This instructs @code{flex} that the macro
+@code{yylval} may be used. The data type for
+@code{yylval}, @code{YYSTYPE},
+is typically defined in a header file, included in section 1 of the
+@code{flex} input file. For a list of functions and macros
+available, @xref{bison-functions}.
-@deftypefun void yyset_lval ( YYSTYPE* lvalp, yyscan_t scanner )
-@end deftypefun
-@deftypefun void yyset_lloc ( YYLTYPE* llocp, yyscan_t scanner )
-@end deftypefun
-
-Where yyscan_t is defined in the reentrant scanner @footnote{The bison bridge
-works with non-reentrant scanners, too.}. Accordingly, the declaration of
-yylex becomes one of the following:
+The declaration of yylex becomes,
@findex yylex (reentrant version)
@example
@verbatim
int yylex ( YYSTYPE * lvalp, yyscan_t scanner );
+@end verbatim
+@end example
+
+If @code{%option bison-locations} is specified, then the declaration
+becomes,
+
+@findex yylex (reentrant version)
+@example
+@verbatim
int yylex ( YYSTYPE * lvalp, YYLTYPE * llocp, yyscan_t scanner );
@end verbatim
@end example
-Note that the macros @code{yylval} and @code{yylloc} evaluate to
-pointers. Support for @code{yylloc} is optional in @code{bison}, so it
-is optional in @code{flex} as well. This support is automatically
-handled by @code{flex}. Specifically, support for @code{yyloc} is only
-present in a @code{flex} scanner if the preprocessor symbol
-@code{YYLTYPE} is defined. The following is an example of a @code{flex}
-scanner that is compatible with @code{bison}.
+Note that the macros @code{yylval} and @code{yylloc} evaluate to pointers.
+Support for @code{yylloc} is optional in @code{bison}, so it is optional in
+@code{flex} as well. The following is an example of a @code{flex} scanner that
+is compatible with @code{bison}.
@cindex bison, scanner to be called from bison
@example
@@ -8134,7 +8158,7 @@ scanner that is compatible with @code{bison}.
#include "y.tab.h" /* Generated by bison. */
%}
- %option reentrant-bison
+ %option bison-bridge bison-locations
%
[[:digit:]]+ { yylval->num = atoi(yytext); return NUMBER;}
@@ -8159,6 +8183,7 @@ As you can see, there really is no magic here. We just use
#define YYPARSE_PARAM scanner
#define YYLEX_PARAM scanner
%}
+ %locations
%pure_parser
%union {
int num;
diff --git a/filter.c b/filter.c
new file mode 100644
index 0000000..40c8cf2
--- /dev/null
+++ b/filter.c
@@ -0,0 +1,380 @@
+/* filter - postprocessing of flex output through filters */
+
+/* This file is part of flex. */
+
+/* Redistribution and use in source and binary forms, with or without */
+/* modification, are permitted provided that the following conditions */
+/* are met: */
+
+/* 1. Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* 2. Redistributions in binary form must reproduce the above copyright */
+/* notice, this list of conditions and the following disclaimer in the */
+/* documentation and/or other materials provided with the distribution. */
+
+/* Neither the name of the University nor the names of its contributors */
+/* may be used to endorse or promote products derived from this software */
+/* without specific prior written permission. */
+
+/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
+/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
+/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
+/* PURPOSE. */
+
+#include "flexdef.h"
+
+/** global chain. */
+struct filter *output_chain = NULL;
+
+/* Allocate and initialize an external filter.
+ * @param chain the current chain or NULL for new chain
+ * @param cmd the command to execute.
+ * @param ... a NULL terminated list of (const char*) arguments to command,
+ * not including argv[0].
+ * @return newest filter in chain
+ */
+struct filter *filter_create_ext (struct filter *chain, const char *cmd,
+ ...)
+{
+ struct filter *f;
+ int max_args;
+ const char *s;
+ va_list ap;
+
+ /* allocate and initialize new filter */
+ f = (struct filter *) flex_alloc (sizeof (struct filter));
+ memset (f, 0, sizeof (*f));
+ f->filter_func = NULL;
+ f->extra = NULL;
+ f->next = NULL;
+ f->argc = 0;
+
+ if (chain != NULL) {
+ /* append f to end of chain */
+ while (chain->next)
+ chain = chain->next;
+ chain->next = f;
+ }
+
+
+ /* allocate argv, and populate it with the argument list. */
+ max_args = 8;
+ f->argv =
+ (const char **) flex_alloc (sizeof (char *) *
+ (max_args + 1));
+ f->argv[f->argc++] = cmd;
+
+ va_start (ap, cmd);
+ while ((s = va_arg (ap, const char *)) != NULL) {
+ if (f->argc >= max_args) {
+ max_args += 8;
+ f->argv =
+ (const char **) flex_realloc (f->argv,
+ sizeof (char
+ *) *
+ (max_args +
+ 1));
+ }
+ f->argv[f->argc++] = s;
+ }
+ f->argv[f->argc] = NULL;
+
+ va_end (ap);
+ return f;
+}
+
+/* Allocate and initialize an internal filter.
+ * @param chain the current chain or NULL for new chain
+ * @param filter_func The function that will perform the filtering.
+ * filter_func should return 0 if successful, and -1
+ * if an error occurs -- or it can simply exit().
+ * @param extra optional user-defined data to pass to the filter.
+ * @return newest filter in chain
+ */
+struct filter *filter_create_int (struct filter *chain,
+ int (*filter_func) (struct filter *),
+ void *extra)
+{
+ struct filter *f;
+
+ /* allocate and initialize new filter */
+ f = (struct filter *) flex_alloc (sizeof (struct filter));
+ memset (f, 0, sizeof (*f));
+ f->next = NULL;
+ f->argc = 0;
+ f->argv = NULL;
+
+ f->filter_func = filter_func;
+ f->extra = extra;
+
+ if (chain != NULL) {
+ /* append f to end of chain */
+ while (chain->next)
+ chain = chain->next;
+ chain->next = f;
+ }
+
+ return f;
+}
+
+/** Fork and exec entire filter chain.
+ * @param chain The head of the chain.
+ * @return true on success.
+ */
+bool filter_apply_chain (struct filter * chain)
+{
+ int pid, pipes[2];
+
+ /* Tricky recursion, since we want to begin the chain
+ * at the END. Why? Because we need all the forked processes
+ * to be children of the main flex process.
+ */
+ if (chain)
+ filter_apply_chain (chain->next);
+ else
+ return true;
+
+ /* Now we are the right-most unprocessed link in the chain.
+ */
+
+ fflush (stdout);
+ fflush (stderr);
+
+ if (pipe (pipes) == -1)
+ flexerror (_("pipe failed"));
+
+ if ((pid = fork ()) == -1)
+ flexerror (_("fork failed"));
+
+ if (pid == 0) {
+ /* child */
+ close (pipes[1]);
+ if (dup2 (pipes[0], 0) == -1)
+ flexfatal (_("dup2(pipes[0],0)"));
+ close (pipes[0]);
+
+ /* run as a filter, either internally or by exec */
+ if (chain->filter_func) {
+ int r;
+
+ /* setup streams again */
+ if ((stdin = fdopen (0, "r")) == NULL)
+ flexfatal (_("fdopen(0) failed"));
+ if ((stdout = fdopen (1, "w")) == NULL)
+ flexfatal (_("fdopen(1) failed"));
+
+ if ((r = chain->filter_func (chain)) == -1)
+ flexfatal (_("filter_func failed"));
+ exit (0);
+ }
+ else {
+ execvp (chain->argv[0],
+ (char **const) (chain->argv));
+ flexfatal (_("exec failed"));
+ }
+
+ exit (1);
+ }
+
+ /* Parent */
+ close (pipes[0]);
+ if (dup2 (pipes[1], 1) == -1)
+ flexfatal (_("dup2(pipes[1],1)"));
+ close (pipes[1]);
+ if ((stdout = fdopen (1, "w")) == NULL)
+ flexfatal (_("fdopen(1) failed"));
+
+ return true;
+}
+
+/** Truncate the chain to max_len number of filters.
+ * @param chain the current chain.
+ * @param max_len the maximum length of the chain.
+ * @return the resulting length of the chain.
+ */
+int filter_truncate (struct filter *chain, int max_len)
+{
+ int len = 1;
+
+ if (!chain)
+ return 0;
+
+ while (chain->next && len < max_len) {
+ chain = chain->next;
+ ++len;
+ }
+
+ chain->next = NULL;
+ return len;
+}
+
+/** Splits the chain in order to write to a header file.
+ * Similar in spirit to the 'tee' program.
+ * The header file name is in extra.
+ * @return 0 (zero) on success, and -1 on failure.
+ */
+int filter_tee_header (struct filter *chain)
+{
+ /* This function reads from stdin and writes to both the C file and the
+ * header file at the same time.
+ */
+
+ const int readsz = 512;
+ char *buf;
+ int to_cfd = -1;
+ FILE *to_c = NULL, *to_h = NULL;
+ bool write_header;
+
+ write_header = (chain->extra != NULL);
+
+ /* Store a copy of the stdout pipe, which is already piped to C file
+ * through the running chain. Then create a new pipe to the H file as
+ * stdout, and fork the rest of the chain again.
+ */
+
+ if ((to_cfd = dup (1)) == -1)
+ flexfatal (_("dup(1) failed"));
+ to_c = fdopen (to_cfd, "w");
+
+ if (write_header) {
+ if (freopen ((char *) chain->extra, "w", stdout) == NULL)
+ flexfatal (_("freopen(headerfilename) failed"));
+
+ filter_apply_chain (chain->next);
+ to_h = stdout;
+ }
+
+ /* Now to_c is a pipe to the C branch, and to_h is a pipe to the H branch.
+ */
+
+ if (write_header) {
+ fputs ("m4_changecom`'m4_dnl\n", to_h);
+ fputs ("m4_changequote`'m4_dnl\n", to_h);
+ fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_h);
+ fputs ("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n",
+ to_h);
+ fprintf (to_h, "#ifndef %sHEADER_H\n", prefix);
+ fprintf (to_h, "#define %sHEADER_H 1\n", prefix);
+ fprintf (to_h, "#define %sIN_HEADER 1\n\n", prefix);
+ fprintf (to_h,
+ "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n",
+ headerfilename ? headerfilename : "<stdout>");
+
+ }
+
+ fputs ("m4_changecom`'m4_dnl\n", to_c);
+ fputs ("m4_changequote`'m4_dnl\n", to_c);
+ fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_c);
+ fprintf (to_c, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n",
+ outfilename ? outfilename : "<stdout>");
+
+ buf = (char *) flex_alloc (readsz);
+ while (fgets (buf, readsz, stdin)) {
+ fputs (buf, to_c);
+ if (write_header)
+ fputs (buf, to_h);
+ }
+
+ if (write_header) {
+ fprintf (to_h, "\n");
+
+ /* write a fake line number. It will get fixed by the linedir filter. */
+ fprintf (to_h, "#line 4000 \"M4_YY_OUTFILE_NAME\"\n");
+
+ fprintf (to_h, "#undef %sIN_HEADER\n", prefix);
+ fprintf (to_h, "#endif /* %sHEADER_H */\n", prefix);
+ fputs ("m4_undefine( [[M4_YY_IN_HEADER]])m4_dnl\n", to_h);
+
+ fflush (to_h);
+ fclose (to_h);
+ }
+
+ fflush (to_c);
+ fclose (to_c);
+
+
+ while (wait (0) > 0) ;
+
+ exit (0);
+ return 0;
+}
+
+/** Adjust the line numbers in the #line directives of the generated scanner.
+ * After the m4 expansion, the line numbers are incorrect since the m4 macros
+ * can add or remove lines. This only adjusts line numbers for generated code,
+ * not user code. This also happens to be a good place to squeeze multiple
+ * blank lines into a single blank line.
+ */
+int filter_fix_linedirs (struct filter *chain)
+{
+ char *buf;
+ const int readsz = 512;
+ int lineno = 1;
+ bool in_gen = true; /* in generated code */
+ bool last_was_blank = false;
+
+ if (!chain)
+ return 0;
+
+ buf = (char *) flex_alloc (readsz);
+
+ while (fgets (buf, readsz, stdin)) {
+
+ regmatch_t m[10];
+
+ /* Check for #line directive. */
+ if (buf[0] == '#'
+ && regexec (&regex_linedir, buf, 3, m, 0) == 0) {
+
+ int num;
+ char *fname;
+
+ /* extract the line number and filename */
+ num = regmatch_strtol (&m[1], buf, NULL, 0);
+ fname = regmatch_dup (&m[2], buf);
+
+ if (strcmp
+ (fname, outfilename ? outfilename : "<stdout>")
+ == 0
+ || strcmp (fname,
+ headerfilename ? headerfilename :
+ "<stdout>") == 0) {
+ /* Adjust the line directives. */
+ in_gen = true;
+ sprintf (buf, "#line %d \"%s\"\n",
+ lineno + 1, fname);
+ free (fname);
+
+ }
+ else {
+ /* it's a #line directive for code we didn't write */
+ in_gen = false;
+ }
+
+ last_was_blank = false;
+ }
+
+ /* squeeze blank lines from generated code */
+ else if (in_gen
+ && regexec (&regex_blank_line, buf, 0, NULL,
+ 0) == 0) {
+ if (last_was_blank)
+ continue;
+ else
+ last_was_blank = true;
+ }
+
+ else {
+ /* it's a line of normal, non-empty code. */
+ last_was_blank = false;
+ }
+
+ fputs (buf, stdout);
+ lineno++;
+ }
+ fflush (stdout);
+
+ return 0;
+}
+
+/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */
diff --git a/flex.skl b/flex.skl
index 06f7456..068a724 100644
--- a/flex.skl
+++ b/flex.skl
@@ -1,8 +1,36 @@
-m4_changecom
%# -*-C-*- vi: set ft=c:
+%# This file is processed in several stages.
+%# Here are the stages, as best as I can describe:
+%#
+%# 1. flex.skl is processed through GNU m4 during the
+%# pre-compilation stage of flex. Only macros starting
+%# with `m4preproc_' are processed, and quoting is normal.
+%#
+%# 2. The preprocessed skeleton is translated verbatim into a
+%# C array, saved as "skel.c" and compiled into the flex binary.
+%#
+%# 3. At runtime, the skeleton is generated and filtered (again)
+%# through m4. Macros beginning with `m4_' will be processed.
+%# The quoting is "[[" and "]]" so we don't interfere with
+%# user code.
+%#
+%# All generate macros for the m4 stage contain the text "m4" or "M4"
+%# in them. This is to distinguish them from CPP macros.
+%# The exception to this rule is YY_G, which is an m4 macro,
+%# but it needs to be remain short because it is used everywhere.
+%#
/* A lexical scanner generated by flex */
-%# Lines in this skeleton starting with a '%' character are "control lines"
+%# Macros for preproc stage.
+m4preproc_changecom
+
+%# Macros for runtime processing stage.
+m4_changecom
+m4_changequote
+m4_changequote([[, ]])
+
+%#
+%# Lines in this skeleton starting with a "%" character are "control lines"
%# and affect the generation of the scanner. The possible control codes are
%# listed and processed in misc.c.
%#
@@ -34,6 +62,96 @@ m4_changecom
#define FLEX_BETA
#endif
+%# Some negated symbols
+m4_ifdef( [[M4_YY_IN_HEADER]], , [[m4_define([[M4_YY_NOT_IN_HEADER]], [[]])]])
+m4_ifdef( [[M4_YY_REENTRANT]], , [[m4_define([[M4_YY_NOT_REENTRANT]], [[]])]])
+
+%# Prefixes.
+%# The complexity here is necessary so that m4 preserves
+%# the argument lists to each C function.
+
+
+m4_ifdef( [[M4_YY_PREFIX]],, [[m4_define([[M4_YY_PREFIX]], [[yy]])]])
+
+m4preproc_define(`M4_GEN_PREFIX',
+ ``m4_define(yy[[$1]], [[M4_YY_PREFIX[[$1]]m4_ifelse($'`#,0,,[[($'`@)]])]])'')
+
+%if-c++-only
+ /* The c++ scanner is a mess. The FlexLexer.h header file relies on the
+ * following macro.
+ */
+ #define yyFlexLexer M4_YY_PREFIX[[FlexLexer]]
+%endif
+
+%if-c-only
+ M4_GEN_PREFIX(`_create_buffer')
+ M4_GEN_PREFIX(`_delete_buffer')
+ M4_GEN_PREFIX(`_scan_buffer')
+ M4_GEN_PREFIX(`_scan_string')
+ M4_GEN_PREFIX(`_scan_bytes')
+ M4_GEN_PREFIX(`_init_buffer')
+ M4_GEN_PREFIX(`_flush_buffer')
+ M4_GEN_PREFIX(`_load_buffer_state')
+ M4_GEN_PREFIX(`_switch_to_buffer')
+ M4_GEN_PREFIX(`push_buffer_state')
+ M4_GEN_PREFIX(`pop_buffer_state')
+ M4_GEN_PREFIX(`ensure_buffer_stack')
+ M4_GEN_PREFIX(`lex')
+ M4_GEN_PREFIX(`restart')
+ M4_GEN_PREFIX(`lex_init')
+ M4_GEN_PREFIX(`lex_destroy')
+ M4_GEN_PREFIX(`get_debug')
+ M4_GEN_PREFIX(`set_debug')
+ M4_GEN_PREFIX(`get_extra')
+ M4_GEN_PREFIX(`set_extra')
+ M4_GEN_PREFIX(`get_in')
+ M4_GEN_PREFIX(`set_in')
+ M4_GEN_PREFIX(`get_out')
+ M4_GEN_PREFIX(`set_out')
+ M4_GEN_PREFIX(`get_leng')
+ M4_GEN_PREFIX(`get_text')
+ M4_GEN_PREFIX(`get_lineno')
+ M4_GEN_PREFIX(`set_lineno')
+ M4_GEN_PREFIX(`wrap')
+%endif
+
+m4_ifdef( [[M4_YY_BISON_BRIDGE]],
+[[
+ M4_GEN_PREFIX(`get_lval')
+ M4_GEN_PREFIX(`set_lval')
+]])
+
+m4_ifdef( [[M4_YY_BISON_BRIDGE_LOCATIONS]],
+[[
+ M4_GEN_PREFIX(`get_lloc')
+ M4_GEN_PREFIX(`set_lloc')
+]])
+
+
+ M4_GEN_PREFIX(`alloc')
+ M4_GEN_PREFIX(`realloc')
+ M4_GEN_PREFIX(`free')
+
+%if-c-only
+m4_ifdef( [[M4_YY_REENTRANT]],,
+[[
+ M4_GEN_PREFIX(`text')
+ M4_GEN_PREFIX(`leng')
+ M4_GEN_PREFIX(`in')
+ M4_GEN_PREFIX(`out')
+ M4_GEN_PREFIX(`_flex_debug')
+ M4_GEN_PREFIX(`lineno')
+]])
+%endif
+
+
+m4_ifdef( [[M4_YY_TABLES_EXTERNAL]],
+[[
+ M4_GEN_PREFIX(`tables_fload')
+ M4_GEN_PREFIX(`tables_destroy')
+ M4_GEN_PREFIX(`TABLES_NAME')
+]])
+
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
@@ -50,7 +168,7 @@ m4_changecom
/* end standard C headers. */
%if-c-or-c++
-m4_include(`flexint.h')
+m4preproc_include(`flexint.h')
%endif
%if-c++-only
@@ -64,20 +182,11 @@ m4_include(`flexint.h')
#ifdef __cplusplus
-/* C++ compilers don't understand traditional function definitions. */
-#ifdef YY_TRADITIONAL_FUNC_DEFS
-#undef YY_TRADITIONAL_FUNC_DEFS
-#endif
-
/* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST
#else /* ! __cplusplus */
-/* We're not in a C++ compiler, so by default,
- we generate C99 function defs, unless you explicitly ask
- for traditional defs by defining YY_TRADITIONAL_FUNC_DEFS */
-
#if __STDC__
#define YY_USE_CONST
@@ -91,33 +200,40 @@ m4_include(`flexint.h')
#define yyconst
#endif
-/* For compilers that can't handle prototypes.
- * e.g.,
- * The function prototype
- * int foo(int x, char* y);
- *
- * ...should be written as
- * int foo YY_PARAMS((int x, char* y));
- *
- * ...which could possibly generate
- * int foo ();
- */
-#ifdef YY_NO_PROTOS
-#define YY_PARAMS(proto) ()
-#else
-#define YY_PARAMS(proto) proto
-#endif
-
+%# For compilers that can not handle prototypes.
+%# e.g.,
+%# The function prototype
+%# int foo(int x, char* y);
+%#
+%# ...should be written as
+%# int foo M4_YY_PARAMS(int x, char* y);
+%#
+%# ...which could possibly generate
+%# int foo ();
+%#
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_PROTOS]],
+[[
+ m4_define( [[M4_YY_PARAMS]], [[()]])
+]],
+[[
+ m4_define( [[M4_YY_PARAMS]], [[($*)]])
+]])
+%not-for-header
/* Returned upon end-of-file. */
#define YY_NULL 0
+%ok-for-header
+%not-for-header
/* Promotes a possibly negative, possibly signed char to an unsigned
* integer for use as an array index. If the signed char is negative,
* we want to instead treat it as an 8-bit unsigned char, hence the
* double cast.
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+%ok-for-header
+
+
%if-reentrant
@@ -127,26 +243,33 @@ m4_include(`flexint.h')
typedef void* yyscan_t;
#endif
-/* For use wherever a Global is accessed or assigned. */
-#define YY_G(var) (((struct yyguts_t*)yyscanner)->var)
+%# Declare yyguts variable
+m4_define( [[M4_YY_DECL_GUTS_VAR]], [[struct yyguts_t * yyg = (struct yyguts_t*)yyscanner]])
+%# For use wherever a Global is accessed or assigned.
+m4_define( [[YY_G]], [[yyg->$1]])
-/* For use in function prototypes to append the additional argument. */
-#define YY_PROTO_LAST_ARG , yyscan_t yyscanner
-#define YY_PROTO_ONLY_ARG yyscan_t yyscanner
+%# For use in function prototypes to append the additional argument.
+m4_define( [[M4_YY_PROTO_LAST_ARG]], [[, yyscan_t yyscanner]])
+m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[yyscan_t yyscanner]])
-/* For use in function definitions to append the additional argument. */
-#ifdef YY_TRADITIONAL_FUNC_DEFS
-#define YY_DEF_LAST_ARG , yyscanner
-#define YY_DEF_ONLY_ARG yyscanner
-#else
-#define YY_DEF_LAST_ARG , yyscan_t yyscanner
-#define YY_DEF_ONLY_ARG yyscan_t yyscanner
-#endif
-#define YY_DECL_LAST_ARG yyscan_t yyscanner;
+%# For use in function definitions to append the additional argument.
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]],
+[[
+ m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscanner]])
+ m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscanner]])
+]],
+[[
+ m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscan_t yyscanner]])
+ m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscan_t yyscanner]])
+]])
+m4_define( [[M4_YY_DECL_LAST_ARG]], [[yyscan_t yyscanner;]])
+
+%# For use in function calls to pass the additional argument.
+m4_define( [[M4_YY_CALL_LAST_ARG]], [[, yyscanner]])
+m4_define( [[M4_YY_CALL_ONLY_ARG]], [[yyscanner]])
-/* For use in function calls to pass the additional argument. */
-#define YY_CALL_LAST_ARG , yyscanner
-#define YY_CALL_ONLY_ARG yyscanner
+%# For use in function documentation to adjust for additional argument.
+m4_define( [[M4_YY_DOC_PARAM]], [[@param yyscanner The scanner object.]])
/* For convenience, these vars (plus the bison vars far below)
are macros in the reentrant scanner. */
@@ -158,81 +281,116 @@ typedef void* yyscan_t;
#define yylineno YY_G(yylineno_r)
#define yy_flex_debug YY_G(yy_flex_debug_r)
-int yylex_init YY_PARAMS((yyscan_t* scanner));
+int yylex_init M4_YY_PARAMS(yyscan_t* scanner);
%endif
%if-not-reentrant
-/* Define these macros to be no-ops. */
-#define YY_G(var) (var)
-#define YY_PROTO_LAST_ARG
-#define YY_PROTO_ONLY_ARG void
-#define YY_DEF_LAST_ARG
-#ifdef YY_TRADITIONAL_FUNC_DEFS
-#define YY_DEF_ONLY_ARG
-#else
-#define YY_DEF_ONLY_ARG void
-#endif
-#define YY_DECL_LAST_ARG
-#define YY_CALL_LAST_ARG
-#define YY_CALL_ONLY_ARG
-
-%endif
-
-
-/* For compilers that need traditional function definitions.
- * e.g.,
- * The function prototype taking 2 arguments
- * int foo (int x, char* y)
- *
- * ...should be written as
- * int foo YYFARGS2(int,x, char*,y)
- *
- * ...which could possibly generate
- * int foo (x,y,yyscanner)
- * int x;
- * char * y;
- * yyscan_t yyscanner;
- */
-#ifdef YY_TRADITIONAL_FUNC_DEFS
-/* Generate traditional function defs */
-#define YYFARGS0(v) (YY_DEF_ONLY_ARG) YY_DECL_LAST_ARG
-#define YYFARGS1(t1,n1) (n1 YY_DEF_LAST_ARG) t1 n1; YY_DECL_LAST_ARG
-#define YYFARGS2(t1,n1,t2,n2) (n1,n2 YY_DEF_LAST_ARG) t1 n1; t2 n2; YY_DECL_LAST_ARG
-#define YYFARGS3(t1,n1,t2,n2,t3,n3) (n1,n2,n3 YY_DEF_LAST_ARG) t1 n1; t2 n2; t3 n3; YY_DECL_LAST_ARG
-#else
-/* Generate C99 function defs. */
-#define YYFARGS0(v) (YY_DEF_ONLY_ARG)
-#define YYFARGS1(t1,n1) (t1 n1 YY_DEF_LAST_ARG)
-#define YYFARGS2(t1,n1,t2,n2) (t1 n1,t2 n2 YY_DEF_LAST_ARG)
-#define YYFARGS3(t1,n1,t2,n2,t3,n3) (t1 n1,t2 n2,t3 n3 YY_DEF_LAST_ARG)
-#endif
-
+%# Define these macros to be no-ops.
+m4_define( [[M4_YY_DECL_GUTS_VAR]], [[m4_dnl]])
+m4_define( [[YY_G]], [[($1)]])
+m4_define( [[M4_YY_PROTO_LAST_ARG]])
+m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[void]])
+m4_define( [[M4_YY_DEF_LAST_ARG]])
+
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]],
+[[
+ m4_define( [[M4_YY_DEF_ONLY_ARG]])
+]],
+[[
+ m4_define( [[M4_YY_DEF_ONLY_ARG]], [[void]])
+]])
+m4_define([[M4_YY_DECL_LAST_ARG]])
+m4_define([[M4_YY_CALL_LAST_ARG]])
+m4_define([[M4_YY_CALL_ONLY_ARG]])
+m4_define( [[M4_YY_DOC_PARAM]], [[]])
+
+%endif
+
+
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]],
+[[
+%# For compilers that need traditional function definitions.
+%# e.g.,
+%# The function prototype taking 2 arguments
+%# int foo (int x, char* y)
+%#
+%# ...should be written as
+%# int foo YYFARGS2(int,x, char*,y)
+%#
+%# ...which could possibly generate
+%# int foo (x,y,yyscanner)
+%# int x;
+%# char * y;
+%# yyscan_t yyscanner;
+%#
+%# Generate traditional function defs
+ m4_define( [[YYFARGS0]], [[(M4_YY_DEF_ONLY_ARG)
+ M4_YY_DECL_LAST_ARG]])
+ m4_define( [[YYFARGS1]], [[($2 M4_YY_DEF_LAST_ARG)
+ $1 $2;
+ M4_YY_DECL_LAST_ARG]])
+ m4_define( [[YYFARGS2]], [[($2,$4 M4_YY_DEF_LAST_ARG)
+ $1 $2;
+ $3 $4;
+ M4_YY_DECL_LAST_ARG]])
+ m4_define( [[YYFARGS3]], [[($2,$4,$6 M4_YY_DEF_LAST_ARG)
+ $1 $2;
+ $3 $4;
+ $5 $6;
+ M4_YY_DECL_LAST_ARG]])
+]],
+[[
+%# Generate C99 function defs.
+ m4_define( [[YYFARGS0]], [[(M4_YY_DEF_ONLY_ARG)]])
+ m4_define( [[YYFARGS1]], [[($1 $2 M4_YY_DEF_LAST_ARG)]])
+ m4_define( [[YYFARGS2]], [[($1 $2, $3 $4 M4_YY_DEF_LAST_ARG)]])
+ m4_define( [[YYFARGS3]], [[($1 $2, $3 $4, $5 $6 M4_YY_DEF_LAST_ARG)]])
+]])
+
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
#define BEGIN YY_G(yy_start) = 1 + 2 *
+]])
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START ((YY_G(yy_start) - 1) / 2)
#define YYSTATE YY_START
+]])
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+]])
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin YY_CALL_LAST_ARG )
+#define YY_NEW_FILE yyrestart( yyin M4_YY_CALL_LAST_ARG )
+]])
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
#define YY_END_OF_BUFFER_CHAR 0
+]])
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE 16384
#endif
+]])
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
@@ -250,45 +408,40 @@ extern FILE *yyin, *yyout;
%endif
%endif
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
-
-#ifdef YY_USE_LINENO
-/* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
- * access to the local variable yy_act. Since yyless() is a macro, it would break
- * existing scanners that call yyless() from OUTSIDE yylex.
- * One obvious solution it to make yy_act a global. I tried that, and saw
- * a 5% performance hit in a non-yylineno scanner, because yy_act is
- * normally declared as a register variable-- so it's not worth it.
- */
-#define YY_LESS_LINENO(n) \
- do { \
- int yyl;\
- for ( yyl = n; yyl < yyleng; ++yyl )\
- if ( yytext[yyl] == '\n' )\
- --yylineno;\
- }while(0)
-#else
-#define YY_LESS_LINENO(n)
-#endif
-
-/* The funky do-while in the following #define is used to turn the definition
- * int a single C statement (which needs a semi-colon terminator). This
- * avoids problems with code like:
- *
- * if ( condition_holds )
- * yyless( 5 );
- * else
- * do_something_else();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the yyless() call.
- */
-
-/* Return all but the first 'n' matched characters back to the input stream. */
-
+]])
+
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
+ m4_ifdef( [[M4_YY_USE_LINENO]],
+ [[
+ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
+ * access to the local variable yy_act. Since yyless() is a macro, it would break
+ * existing scanners that call yyless() from OUTSIDE yylex.
+ * One obvious solution it to make yy_act a global. I tried that, and saw
+ * a 5% performance hit in a non-yylineno scanner, because yy_act is
+ * normally declared as a register variable-- so it is not worth it.
+ */
+ #define YY_LESS_LINENO(n) \
+ do { \
+ int yyl;\
+ for ( yyl = n; yyl < yyleng; ++yyl )\
+ if ( yytext[yyl] == '\n' )\
+ --yylineno;\
+ }while(0)
+ ]],
+ [[
+ #define YY_LESS_LINENO(n)
+ ]])
+]])
+
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
+/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
do \
{ \
@@ -301,8 +454,12 @@ extern FILE *yyin, *yyout;
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
+]])
-#define unput(c) yyunput( c, YY_G(yytext_ptr) YY_CALL_LAST_ARG )
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
+#define unput(c) yyunput( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG )
+]])
/* The following is because we cannot portably get our hands on size_t
* (without autoconf's help, which isn't available because we want
@@ -365,6 +522,8 @@ struct yy_buffer_state
int yy_fill_buffer;
int yy_buffer_status;
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
/* When an EOF's been seen but there's still some text to process
@@ -378,6 +537,7 @@ struct yy_buffer_state
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
+]])
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
@@ -386,12 +546,15 @@ struct yy_buffer_state
%if-not-reentrant
/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /*<< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /*<< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /*<< Stack as an array. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
%endif
%ok-for-header
%endif
+
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
* "scanner state".
@@ -401,11 +564,15 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /*<< Stack as an array. */
#define YY_CURRENT_BUFFER ( YY_G(yy_buffer_stack) \
? YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] \
: NULL)
+]])
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
#define YY_CURRENT_BUFFER_LVALUE YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)]
+]])
%if-c-only Standard (non-C++) definition
@@ -413,10 +580,7 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /*<< Stack as an array. */
%not-for-header
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
-
static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
-
int yyleng;
/* Points to current character in buffer. */
@@ -431,69 +595,88 @@ static int yy_did_buffer_switch_on_eof;
%ok-for-header
%endif
-void yyrestart YY_PARAMS(( FILE *input_file YY_PROTO_LAST_ARG ));
+void yyrestart M4_YY_PARAMS( FILE *input_file M4_YY_PROTO_LAST_ARG );
+void yy_switch_to_buffer M4_YY_PARAMS( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG );
+YY_BUFFER_STATE yy_create_buffer M4_YY_PARAMS( FILE *file, int size M4_YY_PROTO_LAST_ARG );
+void yy_delete_buffer M4_YY_PARAMS( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG );
+void yy_flush_buffer M4_YY_PARAMS( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG );
+void yypush_buffer_state M4_YY_PARAMS( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG );
+void yypop_buffer_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
+static void yyensure_buffer_stack M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+static void yy_load_buffer_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+static void yy_init_buffer M4_YY_PARAMS( YY_BUFFER_STATE b, FILE *file M4_YY_PROTO_LAST_ARG );
+]])
-void yy_switch_to_buffer YY_PARAMS(( YY_BUFFER_STATE new_buffer YY_PROTO_LAST_ARG ));
-void yy_load_buffer_state YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-YY_BUFFER_STATE yy_create_buffer YY_PARAMS(( FILE *file, int size YY_PROTO_LAST_ARG ));
-void yy_delete_buffer YY_PARAMS(( YY_BUFFER_STATE b YY_PROTO_LAST_ARG ));
-void yy_init_buffer YY_PARAMS(( YY_BUFFER_STATE b, FILE *file YY_PROTO_LAST_ARG ));
-void yy_flush_buffer YY_PARAMS(( YY_BUFFER_STATE b YY_PROTO_LAST_ARG ));
-void yypush_buffer_state YY_PARAMS(( YY_BUFFER_STATE new_buffer YY_PROTO_LAST_ARG ));
-void yypop_buffer_state YY_PARAMS(( YY_PROTO_ONLY_ARG ));
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG)
+]])
-%not-for-header
-static void yyensure_buffer_stack YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-%ok-for-header
-
-#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER YY_CALL_LAST_ARG)
-
-YY_BUFFER_STATE yy_scan_buffer YY_PARAMS(( char *base, yy_size_t size YY_PROTO_LAST_ARG ));
-YY_BUFFER_STATE yy_scan_string YY_PARAMS(( yyconst char *yy_str YY_PROTO_LAST_ARG ));
-YY_BUFFER_STATE yy_scan_bytes YY_PARAMS(( yyconst char *bytes, int len YY_PROTO_LAST_ARG ));
+YY_BUFFER_STATE yy_scan_buffer M4_YY_PARAMS( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG );
+YY_BUFFER_STATE yy_scan_string M4_YY_PARAMS( yyconst char *yy_str M4_YY_PROTO_LAST_ARG );
+YY_BUFFER_STATE yy_scan_bytes M4_YY_PARAMS( yyconst char *bytes, int len M4_YY_PROTO_LAST_ARG );
%endif
-void *yyalloc YY_PARAMS(( yy_size_t YY_PROTO_LAST_ARG ));
-void *yyrealloc YY_PARAMS(( void *, yy_size_t YY_PROTO_LAST_ARG ));
-void yyfree YY_PARAMS(( void * YY_PROTO_LAST_ARG ));
+void *yyalloc M4_YY_PARAMS( yy_size_t M4_YY_PROTO_LAST_ARG );
+void *yyrealloc M4_YY_PARAMS( void *, yy_size_t M4_YY_PROTO_LAST_ARG );
+void yyfree M4_YY_PARAMS( void * M4_YY_PROTO_LAST_ARG );
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
#define yy_new_buffer yy_create_buffer
+]])
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
- yyensure_buffer_stack (YY_CALL_ONLY_ARG); \
+ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \
YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG); \
+ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
+]])
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
- yyensure_buffer_stack (YY_CALL_ONLY_ARG); \
+ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \
YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG); \
+ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
+]])
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+]])
%% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here
%if-c-only Standard (non-C++) definition
-%not-for-header
-static yy_state_type yy_get_previous_state YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-static yy_state_type yy_try_NUL_trans YY_PARAMS(( yy_state_type current_state YY_PROTO_LAST_ARG));
-static int yy_get_next_buffer YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-static void yy_fatal_error YY_PARAMS(( yyconst char msg[] YY_PROTO_LAST_ARG ));
-%ok-for-header
+
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
+static yy_state_type yy_get_previous_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+static yy_state_type yy_try_NUL_trans M4_YY_PARAMS( yy_state_type current_state M4_YY_PROTO_LAST_ARG);
+static int yy_get_next_buffer M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+static void yy_fatal_error M4_YY_PARAMS( yyconst char msg[] M4_YY_PROTO_LAST_ARG );
+]])
+
%endif
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
@@ -504,23 +687,30 @@ static void yy_fatal_error YY_PARAMS(( yyconst char msg[] YY_PROTO_LAST_ARG ));
*yy_cp = '\0'; \
%% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \
YY_G(yy_c_buf_p) = yy_cp;
+]])
-%not-for-header
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
%% [4.0] data tables for the DFA and the user's section 1 definitions go here
-%ok-for-header
+]])
+m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]])
+M4_YY_SC_DEFS
+m4_ifdef( [[M4_YY_IN_HEADER]], [[#endif]])
+
+m4_ifdef( [[M4_YY_NO_UNISTD_H]],,
+[[
/* Special case for "unistd.h", since it is non-ANSI. We include it way
* down here because we want the user's section 1 to have been scanned first.
* The user has a chance to override it with an option.
*/
-#ifndef YY_NO_UNISTD_H
%if-c-only
#include <unistd.h>
%endif
%if-c++-only
#include <unistd.h>
%endif
-#endif /* !YY_NO_UNISTD_H */
+]])
#ifndef YY_EXTRA_TYPE
#define YY_EXTRA_TYPE void *
@@ -529,7 +719,8 @@ static void yy_fatal_error YY_PARAMS(( yyconst char msg[] YY_PROTO_LAST_ARG ));
%if-c-only Reentrant structure and macros (non-C++).
%if-reentrant
-%not-for-header
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
/* Holds the entire state of the reentrant scanner. */
struct yyguts_t
{
@@ -539,9 +730,9 @@ struct yyguts_t
/* The rest are the same as the globals declared in the non-reentrant scanner. */
FILE *yyin_r, *yyout_r;
- size_t yy_buffer_stack_top; /*<< index of top of stack. */
- size_t yy_buffer_stack_max; /*<< capacity of stack. */
- YY_BUFFER_STATE * yy_buffer_stack; /*<< Stack as an array. */
+ size_t yy_buffer_stack_top; /**< index of top of stack. */
+ size_t yy_buffer_stack_max; /**< capacity of stack. */
+ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
char yy_hold_char;
int yy_n_chars;
int yyleng_r;
@@ -558,123 +749,155 @@ struct yyguts_t
int yylineno_r;
int yy_flex_debug_r;
-#ifdef YY_USES_REJECT
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
yy_state_type *yy_state_buf;
yy_state_type *yy_state_ptr;
char *yy_full_match;
int yy_lp;
-#endif
+]])
-#ifdef YY_TEXT_IS_ARRAY
+m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]],
+[[
char yytext_r[YYLMAX];
char *yytext_ptr;
int yy_more_offset;
int yy_prev_more_offset;
-#else
+]],
+[[
char *yytext_r;
int yy_more_flag;
int yy_more_len;
-#endif
+]])
-%if-bison-bridge
+m4_ifdef( [[M4_YY_BISON_BRIDGE]],
+[[
YYSTYPE * yylval_r;
-#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
+]])
+
+m4_ifdef( [[M4_YY_BISON_BRIDGE_LOCATIONS]],
+[[
YYLTYPE * yylloc_r;
-#endif
-%endif
+]])
- };
-%ok-for-header
+ }; /* end struct yyguts_t */
+]])
-%not-for-header
-static int yy_init_globals YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-%ok-for-header
-%not-for-header These go in the .c file only.
-/* This must go here because YYSTYPE and YYLTYPE are included
- * from bison output in section 1.*/
+m4_ifdef( [[M4_YY_IN_HEADER]],
+[[
+static int yy_init_globals M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
%if-reentrant
-%if-bison-bridge
-# define yylval YY_G(yylval_r)
-# if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
-# define yylloc YY_G(yylloc_r)
-# endif
-%endif
-%endif
-%ok-for-header
+m4_ifdef( [[M4_YY_IN_HEADER]],,
+[[
+ m4_ifdef( [[M4_YY_BISON_BRIDGE]],
+ [[
+ /* This must go here because YYSTYPE and YYLTYPE are included
+ * from bison output in section 1.*/
+ # define yylval YY_G(yylval_r)
+ ]])
+
+ m4_ifdef( [[M4_YY_BISON_BRIDGE_LOCATIONS]],
+ [[
+ # define yylloc YY_G(yylloc_r)
+ ]])
+]])
%endif
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-#ifndef YY_NO_DESTROY
-int yylex_destroy YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
-
-#ifndef YY_NO_GET_DEBUG
-int yyget_debug YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
-
-#ifndef YY_NO_SET_DEBUG
-void yyset_debug YY_PARAMS(( int debug_flag YY_PROTO_LAST_ARG ));
-#endif
-
-#ifndef YY_NO_GET_EXTRA
-YY_EXTRA_TYPE yyget_extra YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
-
-#ifndef YY_NO_SET_EXTRA
-void yyset_extra YY_PARAMS(( YY_EXTRA_TYPE user_defined YY_PROTO_LAST_ARG ));
-#endif
-
-#ifndef YY_NO_GET_IN
-FILE *yyget_in YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
-
-#ifndef YY_NO_SET_IN
-void yyset_in YY_PARAMS(( FILE * in_str YY_PROTO_LAST_ARG ));
-#endif
+m4_ifdef( [[M4_YY_NO_DESTROY]],,
+[[
+int yylex_destroy M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_DEBUG]],,
+[[
+int yyget_debug M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_DEBUG]],,
+[[
+void yyset_debug M4_YY_PARAMS( int debug_flag M4_YY_PROTO_LAST_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_EXTRA]],,
+[[
+YY_EXTRA_TYPE yyget_extra M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_EXTRA]],,
+[[
+void yyset_extra M4_YY_PARAMS( YY_EXTRA_TYPE user_defined M4_YY_PROTO_LAST_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_IN]],,
+[[
+FILE *yyget_in M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_IN]],,
+[[
+void yyset_in M4_YY_PARAMS( FILE * in_str M4_YY_PROTO_LAST_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_OUT]],,
+[[
+FILE *yyget_out M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_OUT]],,
+[[
+void yyset_out M4_YY_PARAMS( FILE * out_str M4_YY_PROTO_LAST_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_LENG]],,
+[[
+int yyget_leng M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_TEXT]],,
+[[
+char *yyget_text M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_LINENO]],,
+[[
+int yyget_lineno M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_LINENO]],,
+[[
+void yyset_lineno M4_YY_PARAMS( int line_number M4_YY_PROTO_LAST_ARG );
+]])
-#ifndef YY_NO_GET_OUT
-FILE *yyget_out YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
-
-#ifndef YY_NO_SET_OUT
-void yyset_out YY_PARAMS(( FILE * out_str YY_PROTO_LAST_ARG ));
-#endif
-
-#ifndef YY_NO_GET_LENG
-int yyget_leng YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
-
-#ifndef YY_NO_GET_TEXT
-char *yyget_text YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
+%if-bison-bridge
+m4_ifdef( [[M4_YY_NO_GET_LVAL]],,
+[[
+YYSTYPE * yyget_lval M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
-#ifndef YY_NO_GET_LINENO
-int yyget_lineno YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
+void yyset_lval M4_YY_PARAMS( YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG );
-#ifndef YY_NO_SET_LINENO
-void yyset_lineno YY_PARAMS(( int line_number YY_PROTO_LAST_ARG ));
-#endif
+m4_ifdef( [[M4_YY_BISON_BRIDGE_LOCATIONS]],
+[[
+ m4_ifdef( [[M4_YY_NO_GET_LLOC]],,
+ [[
+ YYLTYPE *yyget_lloc M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+ ]])
-%if-bison-bridge
-#ifndef YY_NO_GET_LVAL
-YYSTYPE * yyget_lval YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
-void yyset_lval YY_PARAMS(( YYSTYPE * yylvalp YY_PROTO_LAST_ARG ));
-#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
-#ifndef YY_NO_GET_LLOC
- YYLTYPE *yyget_lloc YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
-#ifndef YY_NO_SET_LLOC
- void yyset_lloc YY_PARAMS(( YYLTYPE * yyllocp YY_PROTO_LAST_ARG ));
-#endif
-#endif /* YYLTYPE */
+ m4_ifdef( [[M4_YY_NO_SET_LLOC]],,
+ [[
+ void yyset_lloc M4_YY_PARAMS( YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG );
+ ]])
+]])
%endif
+%endif End reentrant structures and macros.
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -682,34 +905,35 @@ void yyset_lval YY_PARAMS(( YYSTYPE * yylvalp YY_PROTO_LAST_ARG ));
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int yywrap YY_PARAMS(( YY_PROTO_ONLY_ARG ));
+extern "C" int yywrap M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
#else
-extern int yywrap YY_PARAMS(( YY_PROTO_ONLY_ARG ));
+extern int yywrap M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
#endif
#endif
%not-for-header
-#ifndef YY_NO_UNPUT
-static void yyunput YY_PARAMS(( int c, char *buf_ptr YY_PROTO_LAST_ARG));
-#endif
+ m4_ifdef( [[M4_YY_NO_UNPUT]],,
+ [[
+ static void yyunput M4_YY_PARAMS( int c, char *buf_ptr M4_YY_PROTO_LAST_ARG);
+ ]])
%ok-for-header
%endif
#ifndef yytext_ptr
-static void yy_flex_strncpy YY_PARAMS(( char *, yyconst char *, int YY_PROTO_LAST_ARG));
+static void yy_flex_strncpy M4_YY_PARAMS( char *, yyconst char *, int M4_YY_PROTO_LAST_ARG);
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen YY_PARAMS(( yyconst char * YY_PROTO_LAST_ARG));
+static int yy_flex_strlen M4_YY_PARAMS( yyconst char * M4_YY_PROTO_LAST_ARG);
#endif
#ifndef YY_NO_INPUT
%if-c-only Standard (non-C++) definition
%not-for-header
#ifdef __cplusplus
-static int yyinput YY_PARAMS(( YY_PROTO_ONLY_ARG ));
+static int yyinput M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
#else
-static int input YY_PARAMS(( YY_PROTO_ONLY_ARG ));
+static int input M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
#endif
%ok-for-header
%endif
@@ -717,30 +941,42 @@ static int input YY_PARAMS(( YY_PROTO_ONLY_ARG ));
%if-c-only
-#if YY_STACK_USED
-%if-not-reentrant
-%not-for-header
-static int yy_start_stack_ptr = 0;
-static int yy_start_stack_depth = 0;
-static int *yy_start_stack = 0;
-%ok-for-header
-%endif
-
-#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PARAMS(( int new_state YY_PROTO_LAST_ARG));
-#endif
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state YY_PARAMS(( YY_PROTO_ONLY_ARG ));
-#endif
-
-#else
-#define YY_NO_PUSH_STATE 1
-#define YY_NO_POP_STATE 1
-#define YY_NO_TOP_STATE 1
-#endif
+%# TODO: This is messy.
+m4_ifdef( [[M4_YY_STACK_USED]],
+[[
+
+m4_ifdef( [[M4_YY_REENTRANT]],,
+[[
+ m4_ifdef( [[M4_YY_IN_HEADER]],,
+ [[
+ static int yy_start_stack_ptr = 0;
+ static int yy_start_stack_depth = 0;
+ static int *yy_start_stack = 0;
+ ]])
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],,
+ [[
+ static void yy_push_state M4_YY_PARAMS( int new_state M4_YY_PROTO_LAST_ARG);
+ ]])
+ m4_ifdef( [[M4_YY_NO_POP_STATE]],,
+ [[
+ static void yy_pop_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+ ]])
+ m4_ifdef( [[M4_YY_NO_TOP_STATE]],,
+ [[
+ static int yy_top_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+ ]])
+]])
+
+]],
+[[
+m4_define( [[M4_YY_NO_PUSH_STATE]])
+m4_define( [[M4_YY_NO_POP_STATE]])
+m4_define( [[M4_YY_NO_TOP_STATE]])
+]])
%endif
/* Amount of stuff to slurp up with each read. */
@@ -748,8 +984,9 @@ static int yy_top_state YY_PARAMS(( YY_PROTO_ONLY_ARG ));
#define YY_READ_BUF_SIZE 8192
#endif
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
/* Copy whatever the last rule matched to the standard output. */
-
#ifndef ECHO
%if-c-only Standard (non-C++) definition
/* This used to be an fputs(), but since the string might contain NUL's,
@@ -761,7 +998,10 @@ static int yy_top_state YY_PARAMS(( YY_PROTO_ONLY_ARG ));
#define ECHO LexerOutput( yytext, yyleng )
%endif
#endif
+]])
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
* is returned in "result".
*/
@@ -775,7 +1015,10 @@ static int yy_top_state YY_PARAMS(( YY_PROTO_ONLY_ARG ));
%endif
#endif
+]])
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
/* No semi-colon after return; correct usage is to write "yyterminate();" -
* we don't want an extra ';' after the "return" because that will cause
* some compilers to complain about unreachable statements.
@@ -783,30 +1026,34 @@ static int yy_top_state YY_PARAMS(( YY_PROTO_ONLY_ARG ));
#ifndef yyterminate
#define yyterminate() return YY_NULL
#endif
+]])
/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
%if-c-only
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg YY_CALL_LAST_ARG)
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG)
%endif
%if-c++-only
#define YY_FATAL_ERROR(msg) LexerError( msg )
%endif
#endif
+]])
%if-tables-serialization structures and prototypes
-m4_include(`tables_shared.h')
+m4preproc_include(`tables_shared.h')
/* Load the DFA tables from the given stream. */
-int yytables_fload YY_PARAMS ((FILE * fp YY_PROTO_LAST_ARG));
+int yytables_fload M4_YY_PARAMS(FILE * fp M4_YY_PROTO_LAST_ARG);
/* Unload the tables from memory. */
-int yytables_destroy YY_PARAMS ((YY_PROTO_ONLY_ARG));
+int yytables_destroy M4_YY_PARAMS(M4_YY_PROTO_ONLY_ARG);
%not-for-header
/** Describes a mapping from a serialized table id to its deserialized state in
@@ -841,74 +1088,99 @@ struct yytbl_reader {
* easily add parameters.
*/
#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
%if-c-only Standard (non-C++) definition
-/* If the bison pure parser is used, then bison will provide
- one or two additional arguments. */
-%if-bison-bridge
-# if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
-# define YY_LEX_PROTO YY_PARAMS((YYSTYPE * yylvalp, YYLTYPE * yyllocp YY_PROTO_LAST_ARG))
-# define YY_LEX_DECLARATION YYFARGS2(YYSTYPE *,yylvalp, YYLTYPE *,yyllocp)
-# else
-# define YY_LEX_PROTO YY_PARAMS((YYSTYPE * yylvalp YY_PROTO_LAST_ARG))
-# define YY_LEX_DECLARATION YYFARGS1(YYSTYPE *,yylvalp)
-# endif
-%endif
+m4_define( [[M4_YY_LEX_PROTO]], [[M4_YY_PARAMS(M4_YY_PROTO_ONLY_ARG)]])
+m4_define( [[M4_YY_LEX_DECLARATION]], [[YYFARGS0(void)]])
-%if-not-bison-bridge
-# define YY_LEX_PROTO YY_PARAMS((YY_PROTO_ONLY_ARG))
-# define YY_LEX_DECLARATION YYFARGS0(void)
-%endif
+m4_ifdef( [[M4_YY_BISON_BRIDGE]],
+[[
+ m4_dnl The bison pure parser is used. Redefine yylex to
+ m4_dnl accept the lval parameter.
+
+ m4_define( [[M4_YY_LEX_PROTO]],
+ [[M4_YY_PARAMS(YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG)]])
+ m4_define( [[M4_YY_LEX_DECLARATION]],
+ [[YYFARGS1(YYSTYPE *,yylval_param)]])
+]])
+m4_ifdef( [[M4_YY_BISON_BRIDGE_LOCATIONS]],
+[[
+ m4_dnl Locations are used. yylex should also accept the ylloc parameter.
-extern int yylex YY_LEX_PROTO;
+ m4_define( [[M4_YY_LEX_PROTO]],
+ [[M4_YY_PARAMS(YYSTYPE * yylval_param, YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG)]])
+ m4_define( [[M4_YY_LEX_DECLARATION]],
+ [[YYFARGS2(YYSTYPE *,yylval_param, YYLTYPE *,yylloc_param)]])
+]])
-#define YY_DECL int yylex YY_LEX_DECLARATION
+extern int yylex M4_YY_LEX_PROTO;
+
+#define YY_DECL int yylex M4_YY_LEX_DECLARATION
%endif
%if-c++-only C++ definition
#define YY_DECL int yyFlexLexer::yylex()
%endif
-#endif
-
+#endif /* !YY_DECL */
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
/* Code executed at the beginning of each rule, after yytext and yyleng
* have been set up.
*/
#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif
+]])
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK break;
#endif
+]])
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
%% [6.0] YY_RULE_SETUP definition goes here
+]])
%not-for-header
+/** The main scanner function which does all the work.
+ */
YY_DECL
- {
+{
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
-%if-bison-bridge
-%if-not-reentrant
- YYSTYPE * yylval;
-# if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- YYLTYPE * yylloc;
-# endif
-%endif
-%endif
+ M4_YY_DECL_GUTS_VAR();
+
+m4_ifdef( [[M4_YY_REENTRANT]],,
+[[
+ m4_ifdef( [[M4_YY_BISON_BRIDGE]],
+ [[
+ YYSTYPE * yylval;
+ ]])
+ m4_ifdef( [[M4_YY_BISON_BRIDGE_LOCATIONS]],
+ [[
+ YYLTYPE * yylloc;
+ ]])
+]])
%% [7.0] user's declarations go here
-%if-bison-bridge
- yylval = yylvalp;
-#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
- yylloc = yyllocp;
-#endif
-%endif
+m4_ifdef( [[M4_YY_BISON_BRIDGE]],
+[[
+ yylval = yylval_param;
+]])
+
+m4_ifdef( [[M4_YY_BISON_BRIDGE_LOCATIONS]],
+[[
+ yylloc = yylloc_param;
+]])
if ( YY_G(yy_init) )
{
@@ -918,10 +1190,11 @@ YY_DECL
YY_USER_INIT;
#endif
-#ifdef YY_USES_REJECT
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
if ( ! YY_G(yy_state_buf) )
- YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_BUF_SIZE + 2 YY_CALL_LAST_ARG);
-#endif
+ YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_BUF_SIZE + 2 M4_YY_CALL_LAST_ARG);
+]])
if ( ! YY_G(yy_start) )
YY_G(yy_start) = 1; /* first start state */
@@ -943,12 +1216,12 @@ YY_DECL
%endif
if ( ! YY_CURRENT_BUFFER ) {
- yyensure_buffer_stack (YY_CALL_ONLY_ARG);
+ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG);
YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG);
+ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG);
}
- yy_load_buffer_state( YY_CALL_ONLY_ARG );
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
}
while ( 1 ) /* loops until end-of-file is reached */
@@ -1019,7 +1292,7 @@ do_action: /* This label is used only to access EOF actions. */
YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
+ yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG );
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
@@ -1030,7 +1303,7 @@ do_action: /* This label is used only to access EOF actions. */
* will run more slowly).
*/
- yy_next_state = yy_try_NUL_trans( yy_current_state YY_CALL_LAST_ARG);
+ yy_next_state = yy_try_NUL_trans( yy_current_state M4_YY_CALL_LAST_ARG);
yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
@@ -1049,13 +1322,13 @@ do_action: /* This label is used only to access EOF actions. */
}
}
- else switch ( yy_get_next_buffer( YY_CALL_ONLY_ARG ) )
+ else switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) )
{
case EOB_ACT_END_OF_FILE:
{
YY_G(yy_did_buffer_switch_on_eof) = 0;
- if ( yywrap( YY_CALL_ONLY_ARG ) )
+ if ( yywrap( M4_YY_CALL_ONLY_ARG ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
@@ -1084,7 +1357,7 @@ do_action: /* This label is used only to access EOF actions. */
YY_G(yy_c_buf_p) =
YY_G(yytext_ptr) + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
+ yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG );
yy_cp = YY_G(yy_c_buf_p);
yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
@@ -1094,7 +1367,7 @@ do_action: /* This label is used only to access EOF actions. */
YY_G(yy_c_buf_p) =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)];
- yy_current_state = yy_get_previous_state( YY_CALL_ONLY_ARG );
+ yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG );
yy_cp = YY_G(yy_c_buf_p);
yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
@@ -1108,13 +1381,13 @@ do_action: /* This label is used only to access EOF actions. */
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
- } /* end of yylex */
+} /* end of yylex */
%ok-for-header
%if-c++-only
%not-for-header
yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout )
- {
+{
yyin = arg_yyin;
yyout = arg_yyout;
yy_c_buf_p = 0;
@@ -1138,38 +1411,40 @@ yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout )
YY_G(yy_buffer_stack_max) = 0;
-#ifdef YY_USES_REJECT
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2];
-#else
+]],
+[[
yy_state_buf = 0;
-#endif
- }
+]])
+}
yyFlexLexer::~yyFlexLexer()
- {
+{
delete [] yy_state_buf;
- yyfree( yy_start_stack YY_CALL_LAST_ARG );
- yy_delete_buffer( YY_CURRENT_BUFFER YY_CALL_LAST_ARG);
- }
+ yyfree( yy_start_stack M4_YY_CALL_LAST_ARG );
+ yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG);
+}
void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out )
- {
+{
if ( new_in )
{
- yy_delete_buffer( YY_CURRENT_BUFFER YY_CALL_LAST_ARG);
- yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE YY_CALL_LAST_ARG) YY_CALL_LAST_ARG);
+ yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG);
+ yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE M4_YY_CALL_LAST_ARG) M4_YY_CALL_LAST_ARG);
}
if ( new_out )
yyout = new_out;
- }
+}
#ifdef YY_INTERACTIVE
int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
#else
int yyFlexLexer::LexerInput( char* buf, int max_size )
#endif
- {
+{
if ( yyin->eof() || yyin->fail() )
return 0;
@@ -1192,15 +1467,17 @@ int yyFlexLexer::LexerInput( char* buf, int max_size )
else
return yyin->gcount();
#endif
- }
+}
void yyFlexLexer::LexerOutput( const char* buf, int size )
- {
+{
(void) yyout->write( buf, size );
- }
+}
%ok-for-header
%endif
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
/* yy_get_next_buffer - try to read in a new buffer
*
* Returns a code representing an action:
@@ -1208,15 +1485,14 @@ void yyFlexLexer::LexerOutput( const char* buf, int size )
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
* EOB_ACT_END_OF_FILE - end of file
*/
-
%if-c-only
-%not-for-header
static int yy_get_next_buffer YYFARGS0(void)
%endif
%if-c++-only
int yyFlexLexer::yy_get_next_buffer()
%endif
- {
+{
+ M4_YY_DECL_GUTS_VAR();
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = YY_G(yytext_ptr);
register int number_to_move, i;
@@ -1266,11 +1542,12 @@ int yyFlexLexer::yy_get_next_buffer()
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
-#ifdef YY_USES_REJECT
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
YY_FATAL_ERROR(
"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-#else
-
+]],
+[[
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
@@ -1289,7 +1566,7 @@ int yyFlexLexer::yy_get_next_buffer()
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
yyrealloc( (void *) b->yy_ch_buf,
- b->yy_buf_size + 2 YY_CALL_LAST_ARG );
+ b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG );
}
else
/* Can't grow it, we don't own it. */
@@ -1303,7 +1580,7 @@ int yyFlexLexer::yy_get_next_buffer()
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
number_to_move - 1;
-#endif
+]])
}
if ( num_to_read > YY_READ_BUF_SIZE )
@@ -1321,7 +1598,7 @@ int yyFlexLexer::yy_get_next_buffer()
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin YY_CALL_LAST_ARG);
+ yyrestart( yyin M4_YY_CALL_LAST_ARG);
}
else
@@ -1342,8 +1619,8 @@ int yyFlexLexer::yy_get_next_buffer()
YY_G(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
return ret_val;
- }
-%ok-for-header
+}
+]])
/* yy_get_previous_state - get the state just before the EOB char was reached */
@@ -1354,9 +1631,10 @@ int yyFlexLexer::yy_get_next_buffer()
%if-c++-only
yy_state_type yyFlexLexer::yy_get_previous_state()
%endif
- {
+{
register yy_state_type yy_current_state;
register char *yy_cp;
+ M4_YY_DECL_GUTS_VAR();
%% [15.0] code to get the start state into yy_current_state goes here
@@ -1366,7 +1644,7 @@ int yyFlexLexer::yy_get_next_buffer()
}
return yy_current_state;
- }
+}
/* yy_try_NUL_trans - try to make a transition on the NUL character
@@ -1380,23 +1658,26 @@ int yyFlexLexer::yy_get_next_buffer()
%if-c++-only
yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
%endif
- {
+{
register int yy_is_jam;
+ M4_YY_DECL_GUTS_VAR();
%% [17.0] code to find the next state, and perhaps do backing up, goes here
return yy_is_jam ? 0 : yy_current_state;
- }
+}
%if-c-only
-#ifndef YY_NO_UNPUT
+m4_ifdef( [[M4_YY_NO_UNPUT]],,
+[[
static void yyunput YYFARGS2( int,c, register char *,yy_bp)
%endif
%if-c++-only
void yyFlexLexer::yyunput( int c, register char* yy_bp)
%endif
- {
+{
register char *yy_cp = YY_G(yy_c_buf_p);
+ M4_YY_DECL_GUTS_VAR();
/* undo effects of setting up yytext */
*yy_cp = YY_G(yy_hold_char);
@@ -1425,16 +1706,18 @@ int yyFlexLexer::yy_get_next_buffer()
*--yy_cp = (char) c;
%% [18.0] update yylineno here
-#ifdef YY_USE_LINENO
+m4_ifdef( [[M4_YY_USE_LINENO]],
+[[
if ( c == '\n' )
--yylineno;
-#endif
+]])
+
YY_G(yytext_ptr) = yy_bp;
YY_G(yy_hold_char) = *yy_cp;
YY_G(yy_c_buf_p) = yy_cp;
- }
+}
%if-c-only
-#endif /* ifndef YY_NO_UNPUT */
+]])
%endif
%if-c-only
@@ -1449,9 +1732,9 @@ int yyFlexLexer::yy_get_next_buffer()
%if-c++-only
int yyFlexLexer::yyinput()
%endif
-
- {
+{
int c;
+ M4_YY_DECL_GUTS_VAR();
*YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
@@ -1470,7 +1753,7 @@ int yyFlexLexer::yy_get_next_buffer()
int offset = YY_G(yy_c_buf_p) - YY_G(yytext_ptr);
++YY_G(yy_c_buf_p);
- switch ( yy_get_next_buffer( YY_CALL_ONLY_ARG ) )
+ switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
@@ -1484,21 +1767,21 @@ int yyFlexLexer::yy_get_next_buffer()
*/
/* Reset buffer status. */
- yyrestart( yyin YY_CALL_LAST_ARG);
+ yyrestart( yyin M4_YY_CALL_LAST_ARG);
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
- if ( yywrap( YY_CALL_ONLY_ARG ) )
+ if ( yywrap( M4_YY_CALL_ONLY_ARG ) )
return EOF;
if ( ! YY_G(yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
#ifdef __cplusplus
- return yyinput(YY_CALL_ONLY_ARG);
+ return yyinput(M4_YY_CALL_ONLY_ARG);
#else
- return input(YY_CALL_ONLY_ARG);
+ return input(M4_YY_CALL_ONLY_ARG);
#endif
}
@@ -1516,41 +1799,54 @@ int yyFlexLexer::yy_get_next_buffer()
%% [19.0] update BOL and yylineno
return c;
- }
+}
%if-c-only
#endif /* ifndef YY_NO_INPUT */
%endif
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ * M4_YY_DOC_PARAM
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
%if-c-only
void yyrestart YYFARGS1( FILE *,input_file)
%endif
%if-c++-only
void yyFlexLexer::yyrestart( std::istream* input_file )
%endif
- {
+{
+ M4_YY_DECL_GUTS_VAR();
+
if ( ! YY_CURRENT_BUFFER ){
- yyensure_buffer_stack (YY_CALL_ONLY_ARG);
+ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG);
YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer( yyin, YY_BUF_SIZE YY_CALL_LAST_ARG);
+ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG);
}
- yy_init_buffer( YY_CURRENT_BUFFER, input_file YY_CALL_LAST_ARG);
- yy_load_buffer_state( YY_CALL_ONLY_ARG );
- }
+ yy_init_buffer( YY_CURRENT_BUFFER, input_file M4_YY_CALL_LAST_ARG);
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
+}
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ * M4_YY_DOC_PARAM
+ */
%if-c-only
void yy_switch_to_buffer YYFARGS1( YY_BUFFER_STATE ,new_buffer)
%endif
%if-c++-only
void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
%endif
- {
+{
+ M4_YY_DECL_GUTS_VAR();
+
/* TODO. We should be able to replace this entire function body
* with
* yypop_buffer_state();
* yypush_buffer_state(new_buffer);
*/
- yyensure_buffer_stack (YY_CALL_ONLY_ARG);
+ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG);
if ( YY_CURRENT_BUFFER == new_buffer )
return;
@@ -1563,7 +1859,7 @@ int yyFlexLexer::yy_get_next_buffer()
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- yy_load_buffer_state( YY_CALL_ONLY_ARG );
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
/* We don't actually know whether we did this switch during
* EOF (yywrap()) processing, but the only time this flag
@@ -1571,32 +1867,40 @@ int yyFlexLexer::yy_get_next_buffer()
* to go ahead and always set it.
*/
YY_G(yy_did_buffer_switch_on_eof) = 1;
- }
+}
%if-c-only
- void yy_load_buffer_state YYFARGS0(void)
+static void yy_load_buffer_state YYFARGS0(void)
%endif
%if-c++-only
void yyFlexLexer::yy_load_buffer_state()
%endif
- {
+{
+ M4_YY_DECL_GUTS_VAR();
YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
YY_G(yy_hold_char) = *YY_G(yy_c_buf_p);
- }
+}
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ * M4_YY_DOC_PARAM
+ * @return the allocated buffer state.
+ */
%if-c-only
YY_BUFFER_STATE yy_create_buffer YYFARGS2( FILE *,file, int ,size)
%endif
%if-c++-only
YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size )
%endif
- {
+{
YY_BUFFER_STATE b;
+ m4_dnl M4_YY_DECL_GUTS_VAR();
- b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
@@ -1605,24 +1909,30 @@ int yyFlexLexer::yy_get_next_buffer()
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) yyalloc( b->yy_buf_size + 2 YY_CALL_LAST_ARG );
+ b->yy_ch_buf = (char *) yyalloc( b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
- yy_init_buffer( b, file YY_CALL_LAST_ARG);
+ yy_init_buffer( b, file M4_YY_CALL_LAST_ARG);
return b;
- }
+}
+/** Destroy the buffer.
+ * @param b a buffer created with yy_create_buffer()
+ * M4_YY_DOC_PARAM
+ */
%if-c-only
void yy_delete_buffer YYFARGS1( YY_BUFFER_STATE ,b)
%endif
%if-c++-only
void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
%endif
- {
+{
+ M4_YY_DECL_GUTS_VAR();
+
if ( ! b )
return;
@@ -1630,64 +1940,80 @@ int yyFlexLexer::yy_get_next_buffer()
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
- yyfree( (void *) b->yy_ch_buf YY_CALL_LAST_ARG );
+ yyfree( (void *) b->yy_ch_buf M4_YY_CALL_LAST_ARG );
- yyfree( (void *) b YY_CALL_LAST_ARG );
- }
+ yyfree( (void *) b M4_YY_CALL_LAST_ARG );
+}
%if-c-only
-#ifndef YY_ALWAYS_INTERACTIVE
-#ifndef YY_NEVER_INTERACTIVE
+m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]],,
+[[
+ m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]],,
+ [[
#ifndef __cplusplus
-extern int isatty YY_PARAMS(( int ));
+extern int isatty M4_YY_PARAMS( int );
#endif /* __cplusplus */
-#endif /* !YY_NEVER_INTERACTIVE */
-#endif /* !YY_ALWAYS_INTERACTIVE */
+ ]])
+]])
+%endif
+
+%if-c++-only
+m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]],,
+[[
+extern "C" int isatty M4_YY_PARAMS( int );
+]])
%endif
%if-c-only
- void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file)
+ static void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file)
%endif
%if-c++-only
-#ifndef YY_NEVER_INTERACTIVE
-extern "C" int isatty YY_PARAMS(( int ));
-#endif
-void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file )
+ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file )
%endif
- {
+{
int oerrno = errno;
+ m4_dnl M4_YY_DECL_GUTS_VAR();
- yy_flush_buffer( b YY_CALL_LAST_ARG);
+ yy_flush_buffer( b M4_YY_CALL_LAST_ARG);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
%if-c-only
-#if YY_ALWAYS_INTERACTIVE
+m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]],
+[[
b->yy_is_interactive = 1;
-#else
-#if YY_NEVER_INTERACTIVE
- b->yy_is_interactive = 0;
-#else
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-#endif
-#endif
+]],
+[[
+ m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]],
+ [[
+ b->yy_is_interactive = 0;
+ ]],
+ [[
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+ ]])
+]])
%endif
%if-c++-only
b->yy_is_interactive = 0;
%endif
errno = oerrno;
- }
+}
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ * M4_YY_DOC_PARAM
+ */
%if-c-only
void yy_flush_buffer YYFARGS1( YY_BUFFER_STATE ,b)
%endif
%if-c++-only
void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
%endif
- {
+{
+ M4_YY_DECL_GUTS_VAR();
if ( ! b )
return;
@@ -1706,13 +2032,15 @@ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file )
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
- yy_load_buffer_state( YY_CALL_ONLY_ARG );
- }
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
+}
%if-c-or-c++
/** Pushes the new state onto the stack. The new state becomes
* the current state. This function will allocate the stack
* if necessary.
+ * @param new_buffer The new state.
+ * M4_YY_DOC_PARAM
*/
%if-c-only
void yypush_buffer_state YYFARGS1(YY_BUFFER_STATE,new_buffer)
@@ -1721,10 +2049,11 @@ void yypush_buffer_state YYFARGS1(YY_BUFFER_STATE,new_buffer)
void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer)
%endif
{
+ M4_YY_DECL_GUTS_VAR();
if (new_buffer == NULL)
return;
- yyensure_buffer_stack(YY_CALL_ONLY_ARG);
+ yyensure_buffer_stack(M4_YY_CALL_ONLY_ARG);
/* This block is copied from yy_switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
@@ -1741,15 +2070,16 @@ void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer)
YY_CURRENT_BUFFER_LVALUE = new_buffer;
/* copied from yy_switch_to_buffer. */
- yy_load_buffer_state( YY_CALL_ONLY_ARG );
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
YY_G(yy_did_buffer_switch_on_eof) = 1;
}
%endif
%if-c-or-c++
-/** Removes and DELETES the top of the stack, if present.
- * The next element becomes the new top, if present.
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ * M4_YY_DOC_PARAM
*/
%if-c-only
void yypop_buffer_state YYFARGS0(void)
@@ -1758,16 +2088,17 @@ void yypop_buffer_state YYFARGS0(void)
void yyFlexLexer::yypop_buffer_state (void)
%endif
{
+ M4_YY_DECL_GUTS_VAR();
if (!YY_CURRENT_BUFFER)
return;
- yy_delete_buffer(YY_CURRENT_BUFFER YY_CALL_LAST_ARG);
+ yy_delete_buffer(YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG);
YY_CURRENT_BUFFER_LVALUE = NULL;
if (YY_G(yy_buffer_stack_top) > 0)
--YY_G(yy_buffer_stack_top);
if (YY_CURRENT_BUFFER) {
- yy_load_buffer_state( YY_CALL_ONLY_ARG );
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
YY_G(yy_did_buffer_switch_on_eof) = 1;
}
}
@@ -1775,7 +2106,7 @@ void yyFlexLexer::yypop_buffer_state (void)
%if-c-or-c++
-/** Allocates the stack if it does not exist.
+/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
%if-c-only
@@ -1786,6 +2117,7 @@ void yyFlexLexer::yyensure_buffer_stack(void)
%endif
{
int num_to_alloc;
+ M4_YY_DECL_GUTS_VAR();
if (!YY_G(yy_buffer_stack)) {
@@ -1796,7 +2128,7 @@ void yyFlexLexer::yyensure_buffer_stack(void)
num_to_alloc = 1;
YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
- YY_CALL_LAST_ARG);
+ M4_YY_CALL_LAST_ARG);
memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
@@ -1814,7 +2146,7 @@ void yyFlexLexer::yyensure_buffer_stack(void)
YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
(YY_G(yy_buffer_stack),
num_to_alloc * sizeof(struct yy_buffer_state*)
- YY_CALL_LAST_ARG);
+ M4_YY_CALL_LAST_ARG);
/* zero only the new slots.*/
memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -1826,11 +2158,19 @@ void yyFlexLexer::yyensure_buffer_stack(void)
-#ifndef YY_NO_SCAN_BUFFER
+m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],,
+[[
%if-c-only
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ * M4_YY_DOC_PARAM
+ * @return the newly allocated buffer state object.
+ */
YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size)
- {
+{
YY_BUFFER_STATE b;
+ m4_dnl M4_YY_DECL_GUTS_VAR();
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
@@ -1838,7 +2178,7 @@ YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size)
/* They forgot to leave room for the EOB's. */
return 0;
- b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) YY_CALL_LAST_ARG );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
@@ -1852,40 +2192,56 @@ YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size)
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- yy_switch_to_buffer( b YY_CALL_LAST_ARG );
+ yy_switch_to_buffer( b M4_YY_CALL_LAST_ARG );
return b;
- }
+}
%endif
-#endif
+]])
-#ifndef YY_NO_SCAN_STRING
+m4_ifdef( [[M4_YY_NO_SCAN_STRING]],,
+[[
%if-c-only
-YY_BUFFER_STATE yy_scan_string YYFARGS1( yyconst char *,yy_str)
- {
- int len;
- for ( len = 0; yy_str[len]; ++len )
- ;
+/** Setup the input buffer state to scan a string. The next call to yylex() will
+ * scan from a @e copy of @a str.
+ * @param str a NUL-terminated string to scan
+ * M4_YY_DOC_PARAM
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * yy_scan_bytes() instead.
+ */
+YY_BUFFER_STATE yy_scan_string YYFARGS1( yyconst char *,str)
+{
+ m4_dnl M4_YY_DECL_GUTS_VAR();
- return yy_scan_bytes( yy_str, len YY_CALL_LAST_ARG);
- }
+ return yy_scan_bytes( str, strlen(str) M4_YY_CALL_LAST_ARG);
+}
%endif
-#endif
+]])
-#ifndef YY_NO_SCAN_BYTES
+m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],,
+[[
%if-c-only
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
+ * scan from a @e copy of @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * M4_YY_DOC_PARAM
+ * @return the newly allocated buffer state object.
+ */
YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,bytes, int ,len)
- {
+{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
int i;
+ m4_dnl M4_YY_DECL_GUTS_VAR();
/* Get memory for full buffer, including space for trailing EOB's. */
n = len + 2;
- buf = (char *) yyalloc( n YY_CALL_LAST_ARG );
+ buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
@@ -1894,7 +2250,7 @@ YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,bytes, int ,len)
buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
- b = yy_scan_buffer( buf, n YY_CALL_LAST_ARG);
+ b = yy_scan_buffer( buf, n M4_YY_CALL_LAST_ARG);
if ( ! b )
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
@@ -1904,19 +2260,21 @@ YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,bytes, int ,len)
b->yy_is_our_buffer = 1;
return b;
- }
+}
%endif
-#endif
+]])
-#ifndef YY_NO_PUSH_STATE
+m4_ifdef( [[M4_YY_NO_PUSH_STATE]],,
+[[
%if-c-only
static void yy_push_state YYFARGS1( int ,new_state)
%endif
%if-c++-only
void yyFlexLexer::yy_push_state( int new_state )
%endif
- {
+{
+ M4_YY_DECL_GUTS_VAR();
if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) )
{
yy_size_t new_size;
@@ -1925,11 +2283,11 @@ YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,bytes, int ,len)
new_size = YY_G(yy_start_stack_depth) * sizeof( int );
if ( ! YY_G(yy_start_stack) )
- YY_G(yy_start_stack) = (int *) yyalloc( new_size YY_CALL_LAST_ARG );
+ YY_G(yy_start_stack) = (int *) yyalloc( new_size M4_YY_CALL_LAST_ARG );
else
YY_G(yy_start_stack) = (int *) yyrealloc(
- (void *) YY_G(yy_start_stack), new_size YY_CALL_LAST_ARG );
+ (void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG );
if ( ! YY_G(yy_start_stack) )
YY_FATAL_ERROR(
@@ -1939,37 +2297,41 @@ YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,bytes, int ,len)
YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START;
BEGIN(new_state);
- }
-#endif
+}
+]])
-#ifndef YY_NO_POP_STATE
+m4_ifdef( [[M4_YY_NO_POP_STATE]],,
+[[
%if-c-only
static void yy_pop_state YYFARGS0(void)
%endif
%if-c++-only
void yyFlexLexer::yy_pop_state()
%endif
- {
+{
+ M4_YY_DECL_GUTS_VAR();
if ( --YY_G(yy_start_stack_ptr) < 0 )
YY_FATAL_ERROR( "start-condition stack underflow" );
BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]);
- }
-#endif
+}
+]])
-#ifndef YY_NO_TOP_STATE
+m4_ifdef( [[M4_YY_NO_TOP_STATE]],,
+[[
%if-c-only
static int yy_top_state YYFARGS0(void)
%endif
%if-c++-only
int yyFlexLexer::yy_top_state()
%endif
- {
+{
+ M4_YY_DECL_GUTS_VAR();
return YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1];
- }
-#endif
+}
+]])
#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
@@ -1977,17 +2339,19 @@ YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,bytes, int ,len)
%if-c-only
static void yy_fatal_error YYFARGS1(yyconst char*, msg)
- {
+{
+ m4_dnl M4_YY_DECL_GUTS_VAR();
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
- }
+}
%endif
%if-c++-only
void yyFlexLexer::LexerError( yyconst char msg[] )
- {
+{
+ M4_YY_DECL_GUTS_VAR();
std::cerr << msg << std::endl;
exit( YY_EXIT_FAILURE );
- }
+}
%endif
/* Redefine yyless() so it works in section 3 code. */
@@ -2013,142 +2377,209 @@ void yyFlexLexer::LexerError( yyconst char msg[] )
%if-c-only
%if-reentrant
-#ifndef YY_NO_GET_EXTRA
+m4_ifdef( [[M4_YY_NO_GET_EXTRA]],,
+[[
+/** Get the user-defined data for this scanner.
+ * M4_YY_DOC_PARAM
+ */
YY_EXTRA_TYPE yyget_extra YYFARGS0(void)
{
+ M4_YY_DECL_GUTS_VAR();
return yyextra;
}
-#endif /* !YY_NO_GET_EXTRA */
+]])
%endif
-#ifndef YY_NO_GET_LINENO
+m4_ifdef( [[M4_YY_NO_GET_LINENO]],,
+[[
+/** Get the current line number.
+ * M4_YY_DOC_PARAM
+ */
int yyget_lineno YYFARGS0(void)
{
+ M4_YY_DECL_GUTS_VAR();
return yylineno;
}
-#endif /* !YY_NO_GET_LINENO */
+]])
-#ifndef YY_NO_GET_IN
+m4_ifdef( [[M4_YY_NO_GET_IN]],,
+[[
+/** Get the input stream.
+ * M4_YY_DOC_PARAM
+ */
FILE *yyget_in YYFARGS0(void)
{
+ M4_YY_DECL_GUTS_VAR();
return yyin;
}
-#endif /* !YY_NO_GET_IN */
+]])
-#ifndef YY_NO_GET_OUT
+m4_ifdef( [[M4_YY_NO_GET_OUT]],,
+[[
+/** Get the output stream.
+ * M4_YY_DOC_PARAM
+ */
FILE *yyget_out YYFARGS0(void)
{
+ M4_YY_DECL_GUTS_VAR();
return yyout;
}
-#endif /* !YY_NO_GET_OUT */
+]])
-#ifndef YY_NO_GET_LENG
+m4_ifdef( [[M4_YY_NO_GET_LENG]],,
+[[
+/** Get the length of the current token.
+ * M4_YY_DOC_PARAM
+ */
int yyget_leng YYFARGS0(void)
{
+ M4_YY_DECL_GUTS_VAR();
return yyleng;
}
-#endif /* !YY_NO_GET_LENG */
+]])
-#ifndef YY_NO_GET_TEXT
+/** Get the current token.
+ * M4_YY_DOC_PARAM
+ */
+m4_ifdef( [[M4_YY_NO_GET_TEXT]],,
+[[
char *yyget_text YYFARGS0(void)
{
+ M4_YY_DECL_GUTS_VAR();
return yytext;
}
-#endif /* !YY_NO_GET_TEXT */
+]])
%if-reentrant
-#ifndef YY_NO_SET_EXTRA
+m4_ifdef( [[M4_YY_NO_SET_EXTRA]],,
+[[
+/** Set the user-defined data. This data is never touched by the scanner.
+ * @param user_defined The data to be associated with this scanner.
+ * M4_YY_DOC_PARAM
+ */
void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined)
{
+ M4_YY_DECL_GUTS_VAR();
yyextra = user_defined ;
}
-#endif /* !YY_NO_SET_EXTRA */
+]])
%endif
-#ifndef YY_NO_SET_LINENO
+m4_ifdef( [[M4_YY_NO_SET_LINENO]],,
+[[
+/** Set the current line number.
+ * @param line_number
+ * M4_YY_DOC_PARAM
+ */
void yyset_lineno YYFARGS1( int ,line_number)
{
+ M4_YY_DECL_GUTS_VAR();
yylineno = line_number;
}
-#endif /* !YY_NO_SET_LINENO */
+]])
-#ifndef YY_NO_SET_IN
+m4_ifdef( [[M4_YY_NO_SET_IN]],,
+[[
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ * M4_YY_DOC_PARAM
+ * @see yy_switch_to_buffer
+ */
void yyset_in YYFARGS1( FILE * ,in_str)
{
+ M4_YY_DECL_GUTS_VAR();
yyin = in_str ;
}
-#endif /* !YY_NO_SET_IN */
+]])
-#ifndef YY_NO_SET_OUT
+m4_ifdef( [[M4_YY_NO_SET_OUT]],,
+[[
void yyset_out YYFARGS1( FILE * ,out_str)
{
+ M4_YY_DECL_GUTS_VAR();
yyout = out_str ;
}
-#endif /* !YY_NO_SET_OUT */
+]])
-#ifndef YY_NO_GET_DEBUG
+m4_ifdef( [[M4_YY_NO_GET_DEBUG]],,
+[[
int yyget_debug YYFARGS0(void)
{
+ M4_YY_DECL_GUTS_VAR();
return yy_flex_debug;
}
-#endif /* !YY_NO_GET_DEBUG */
+]])
-#ifndef YY_NO_SET_DEBUG
+m4_ifdef( [[M4_YY_NO_SET_DEBUG]],,
+[[
void yyset_debug YYFARGS1( int ,bdebug)
{
+ M4_YY_DECL_GUTS_VAR();
yy_flex_debug = bdebug ;
}
-#endif /* !YY_NO_SET_DEBUG */
+]])
%endif
%if-reentrant
/* Accessor methods for yylval and yylloc */
%if-bison-bridge
-#ifndef YY_NO_GET_LVAL
+m4_ifdef( [[M4_YY_NO_GET_LVAL]],,
+[[
YYSTYPE * yyget_lval YYFARGS0(void)
{
+ M4_YY_DECL_GUTS_VAR();
return yylval;
}
-#endif /* !YY_NO_GET_LVAL */
+]])
-#ifndef YY_NO_SET_LVAL
-void yyset_lval YYFARGS1( YYSTYPE * ,yylvalp)
+m4_ifdef( [[M4_YY_NO_SET_LVAL]],,
+[[
+void yyset_lval YYFARGS1( YYSTYPE * ,yylval_param)
{
- yylval = yylvalp;
+ M4_YY_DECL_GUTS_VAR();
+ yylval = yylval_param;
}
-#endif /* !YY_NO_SET_LVAL */
+]])
-#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
-#ifndef YY_NO_GET_LLOC
+m4_ifdef( [[M4_YY_BISON_BRIDGE_LOCATIONS]],
+[[
+ m4_ifdef( [[M4_YY_NO_GET_LLOC]],,
+ [[
YYLTYPE *yyget_lloc YYFARGS0(void)
{
+ M4_YY_DECL_GUTS_VAR();
return yylloc;
}
-#endif /* !YY_NO_GET_LLOC */
+ ]])
-#ifndef YY_NO_SET_LLOC
-void yyset_lloc YYFARGS1( YYLTYPE * ,yyllocp)
+ m4_ifdef( [[M4_YY_NO_SET_LLOC]],,
+ [[
+void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param)
{
- yylloc = yyllocp;
+ M4_YY_DECL_GUTS_VAR();
+ yylloc = yylloc_param;
}
-#endif /* !YY_NO_SET_LLOC */
+ ]])
+]])
-#endif /* YYLTYPE */
%endif
static int yy_init_globals YYFARGS0(void)
- {
+{
+ M4_YY_DECL_GUTS_VAR();
/* Initialization is the same as for the non-reentrant scanner.
This function is called once per scanner lifetime. */
/* We do not touch yylineno unless the option is enabled. */
-#ifdef YY_USE_LINENO
+m4_ifdef( [[M4_YY_USE_LINENO]],
+[[
yylineno = 1;
-#endif
+]])
YY_G(yy_buffer_stack) = 0;
YY_G(yy_buffer_stack_top) = 0;
YY_G(yy_buffer_stack_max) = 0;
@@ -2159,18 +2590,20 @@ static int yy_init_globals YYFARGS0(void)
YY_G(yy_start_stack_depth) = 0;
YY_G(yy_start_stack) = (int *) 0;
-#ifdef YY_USES_REJECT
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
YY_G(yy_state_buf) = 0;
YY_G(yy_state_ptr) = 0;
YY_G(yy_full_match) = 0;
YY_G(yy_lp) = 0;
-#endif
+]])
-#ifdef YY_TEXT_IS_ARRAY
+m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]],
+[[
YY_G(yytext_ptr) = 0;
YY_G(yy_more_offset) = 0;
YY_G(yy_prev_more_offset) = 0;
-#endif
+]])
/* Defined in main.c */
#ifdef YY_STDINIT
@@ -2185,7 +2618,7 @@ static int yy_init_globals YYFARGS0(void)
* yylex_init()
*/
return 0;
- }
+}
/* User-visible API */
@@ -2193,13 +2626,15 @@ static int yy_init_globals YYFARGS0(void)
* the ONLY reentrant function that doesn't take the scanner as the last argument.
* That's why we explicitly handle the declaration, instead of using our macros.
*/
-#ifndef YY_TRADITIONAL_FUNC_DEFS
-int yylex_init(yyscan_t* ptr_yy_globals)
-#else
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]],
+[[
int yylex_init( ptr_yy_globals )
yyscan_t* ptr_yy_globals;
-#endif
- {
+]],
+[[
+int yylex_init(yyscan_t* ptr_yy_globals)
+]])
+{
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
@@ -2215,7 +2650,7 @@ int yylex_init( ptr_yy_globals )
memset(*ptr_yy_globals,0,sizeof(struct yyguts_t));
return yy_init_globals ( *ptr_yy_globals );
- }
+}
%endif
@@ -2223,74 +2658,90 @@ int yylex_init( ptr_yy_globals )
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy YYFARGS0(void)
{
- int i;
+ M4_YY_DECL_GUTS_VAR();
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
- yy_delete_buffer( YY_CURRENT_BUFFER YY_CALL_LAST_ARG );
+ yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG );
YY_CURRENT_BUFFER_LVALUE = NULL;
- yypop_buffer_state(YY_CALL_ONLY_ARG);
+ yypop_buffer_state(M4_YY_CALL_ONLY_ARG);
}
/* Destroy the stack itself. */
- yyfree(YY_G(yy_buffer_stack) YY_CALL_LAST_ARG);
+ yyfree(YY_G(yy_buffer_stack) M4_YY_CALL_LAST_ARG);
YY_G(yy_buffer_stack) = NULL;
-#if defined(YY_STACK_USED) || defined(YY_REENTRANT)
+%# This is the m4 way to say "if (stack_used || is_reentrant){ destroy_stack }"
+m4_ifdef( [[M4_YY_STACK_USED]], [[m4_define([[M4_YY_DESTROY_START_STACK]])]])
+m4_ifdef( [[M4_YY_REENTRANT]], [[m4_define([[M4_YY_DESTROY_START_STACK]])]])
+m4_ifdef( [[M4_YY_DESTROY_START_STACK]],
+[[
/* Destroy the start condition stack. */
- yyfree( YY_G(yy_start_stack) YY_CALL_LAST_ARG );
+ yyfree( YY_G(yy_start_stack) M4_YY_CALL_LAST_ARG );
YY_G(yy_start_stack) = NULL;
-#endif
+]])
-#ifdef YY_USES_REJECT
- yyfree ( YY_G(yy_state_buf) YY_CALL_LAST_ARG);
-#endif
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
+ yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG);
+]])
%if-reentrant
/* Destroy the main struct (reentrant only). */
- yyfree ( yyscanner YY_CALL_LAST_ARG );
+ yyfree ( yyscanner M4_YY_CALL_LAST_ARG );
%endif
return 0;
}
%endif
-/* Internal utility routines. */
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/*
+ * Internal utility routines.
+ */
+]])
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
#ifndef yytext_ptr
static void yy_flex_strncpy YYFARGS3( char*,s1, yyconst char *,s2, int,n)
- {
+{
register int i;
+ M4_YY_DECL_GUTS_VAR();
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
- }
+}
#endif
+]])
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen YYFARGS1( yyconst char *,s)
- {
+{
register int n;
+ M4_YY_DECL_GUTS_VAR();
for ( n = 0; s[n]; ++n )
;
return n;
- }
+}
#endif
+]])
-/* You may override yyalloc by defining YY_NO_FLEX_ALLOC and linking to
- * your own version */
-#ifndef YY_NO_FLEX_ALLOC
+m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],,
+[[
void *yyalloc YYFARGS1( yy_size_t ,size)
- {
+{
return (void *) malloc( size );
- }
-#endif
+}
+]])
-/* You may override yyrealloc by defining YY_NO_FLEX_REALLOC and linking
- * to your own version. */
-#ifndef YY_NO_FLEX_REALLOC
+m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],,
+[[
void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size)
- {
+{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
@@ -2299,20 +2750,19 @@ void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size)
* as though doing an assignment.
*/
return (void *) realloc( (char *) ptr, size );
- }
-#endif
+}
+]])
-/* You may override yyfree by defining YY_NO_FLEX_FREE and linking to
- * your own version.*/
-#ifndef YY_NO_FLEX_FREE
+m4_ifdef( [[M4_YY_NO_FLEX_FREE]],,
+[[
void yyfree YYFARGS1( void *,ptr)
- {
+{
free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
- }
-#endif
+}
+]])
%if-tables-serialization definitions
-m4_include(`tables_shared.c')
+m4preproc_include(`tables_shared.c')
static int yytbl_read8 (void *v, struct yytbl_reader * rd)
{
@@ -2350,7 +2800,7 @@ static int yytbl_read32 (void *v, struct yytbl_reader * rd)
}
/** Read the header */
-static int yytbl_hdr_read YYFARGS2 (struct yytbl_hdr *, th, struct yytbl_reader *, rd)
+static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *, rd)
{
int bytes;
memset (th, 0, sizeof (struct yytbl_hdr));
@@ -2359,7 +2809,7 @@ static int yytbl_hdr_read YYFARGS2 (struct yytbl_hdr *, th, struct yytbl_reader
return -1;
if (th->th_magic != YYTBL_MAGIC){
- yy_fatal_error("bad magic number" /*TODO: not fatal.*/ YY_CALL_LAST_ARG);
+ yy_fatal_error("bad magic number" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
return -1;
}
@@ -2370,18 +2820,18 @@ static int yytbl_hdr_read YYFARGS2 (struct yytbl_hdr *, th, struct yytbl_reader
/* Sanity check on header size. Greater than 1k suggests some funny business. */
if (th->th_hsize < 16 || th->th_hsize > 1024){
- yy_fatal_error("insane header size detected" /*TODO: not fatal.*/ YY_CALL_LAST_ARG);
+ yy_fatal_error("insane header size detected" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
return -1;
}
/* Allocate enough space for the version and name fields */
bytes = th->th_hsize - 14;
- th->th_version = (char *) yyalloc (bytes YY_CALL_LAST_ARG);
+ th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG);
/* we read it all into th_version, and point th_name into that data */
if (fread (th->th_version, 1, bytes, rd->fp) != bytes){
errno = EIO;
- yyfree(th->th_version YY_CALL_LAST_ARG);
+ yyfree(th->th_version M4_YY_CALL_LAST_ARG);
th->th_version = NULL;
return -1;
}
@@ -2396,7 +2846,7 @@ static int yytbl_hdr_read YYFARGS2 (struct yytbl_hdr *, th, struct yytbl_reader
* @param dmap pointer to first element in list
* @return NULL if not found.
*/
-static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2 (struct yytbl_dmap *, dmap,
+static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap,
int, id)
{
while (dmap->dm_id)
@@ -2411,7 +2861,7 @@ static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2 (struct yytbl_dmap *, dmap,
* @param dmap used to performing mapping
* @return 0 on success
*/
-static int yytbl_data_load YYFARGS2 (struct yytbl_dmap *, dmap, struct yytbl_reader*, rd)
+static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_reader*, rd)
{
struct yytbl_data td;
struct yytbl_dmap *transdmap=0;
@@ -2430,10 +2880,10 @@ static int yytbl_data_load YYFARGS2 (struct yytbl_dmap *, dmap, struct yytbl_rea
* inside the loop below. This scanner might not even have a transition
* table, which is ok.
*/
- transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION YY_CALL_LAST_ARG);
+ transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION M4_YY_CALL_LAST_ARG);
- if ((dmap = yytbl_dmap_lookup (dmap, td.td_id YY_CALL_LAST_ARG)) == NULL){
- yy_fatal_error("table id not found in map." /*TODO: not fatal.*/ YY_CALL_LAST_ARG);
+ if ((dmap = yytbl_dmap_lookup (dmap, td.td_id M4_YY_CALL_LAST_ARG)) == NULL){
+ yy_fatal_error("table id not found in map." /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
return -1;
}
@@ -2450,12 +2900,12 @@ static int yytbl_data_load YYFARGS2 (struct yytbl_dmap *, dmap, struct yytbl_rea
else
bytes = td.td_lolen * (td.td_hilen ? td.td_hilen : 1) * dmap->dm_sz;
- if(YY_TABLES_VERIFY)
+ if(M4_YY_TABLES_VERIFY)
/* We point to the array itself */
p = dmap->dm_arr;
else
/* We point to the address of a pointer. */
- *dmap->dm_arr = p = (void *) yyalloc (bytes YY_CALL_LAST_ARG);
+ *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG);
}
/* If it's a struct, we read 2 integers to get one element */
@@ -2498,7 +2948,7 @@ static int yytbl_data_load YYFARGS2 (struct yytbl_dmap *, dmap, struct yytbl_rea
t32 = t8;
break;
default:
- yy_fatal_error("invalid td_flags" /*TODO: not fatal.*/ YY_CALL_LAST_ARG);
+ yy_fatal_error("invalid td_flags" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
return -1;
}
}
@@ -2516,28 +2966,28 @@ static int yytbl_data_load YYFARGS2 (struct yytbl_dmap *, dmap, struct yytbl_rea
switch (dmap->dm_sz) {
case sizeof (int32_t):
- if (YY_TABLES_VERIFY){
+ if (M4_YY_TABLES_VERIFY){
if( ((int32_t *) v)[0] != (int32_t) t32)
- yy_fatal_error("tables verification failed at YYTD_STRUCT int32_t" YY_CALL_LAST_ARG);
+ yy_fatal_error("tables verification failed at YYTD_STRUCT int32_t" M4_YY_CALL_LAST_ARG);
}else
((int32_t *) v)[0] = (int32_t) t32;
break;
case sizeof (int16_t):
- if (YY_TABLES_VERIFY ){
+ if (M4_YY_TABLES_VERIFY ){
if(((int16_t *) v)[0] != (int16_t) t32)
- yy_fatal_error("tables verification failed at YYTD_STRUCT int16_t" YY_CALL_LAST_ARG);
+ yy_fatal_error("tables verification failed at YYTD_STRUCT int16_t" M4_YY_CALL_LAST_ARG);
}else
((int16_t *) v)[0] = (int16_t) t32;
break;
case sizeof(int8_t):
- if (YY_TABLES_VERIFY ){
+ if (M4_YY_TABLES_VERIFY ){
if( ((int8_t *) v)[0] != (int8_t) t32)
- yy_fatal_error("tables verification failed at YYTD_STRUCT int8_t" YY_CALL_LAST_ARG);
+ yy_fatal_error("tables verification failed at YYTD_STRUCT int8_t" M4_YY_CALL_LAST_ARG);
}else
((int8_t *) v)[0] = (int8_t) t32;
break;
default:
- yy_fatal_error("invalid dmap->dm_sz for struct" /*TODO: not fatal.*/ YY_CALL_LAST_ARG);
+ yy_fatal_error("invalid dmap->dm_sz for struct" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
return -1;
}
@@ -2551,18 +3001,18 @@ static int yytbl_data_load YYFARGS2 (struct yytbl_dmap *, dmap, struct yytbl_rea
if (!transdmap){
- yy_fatal_error("transition table not found" /*TODO: not fatal.*/ YY_CALL_LAST_ARG);
+ yy_fatal_error("transition table not found" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
return -1;
}
- if( YY_TABLES_VERIFY)
+ if( M4_YY_TABLES_VERIFY)
v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]);
else
v = &((*((struct yy_trans_info **) (transdmap->dm_arr)))[t32]);
- if(YY_TABLES_VERIFY ){
+ if(M4_YY_TABLES_VERIFY ){
if( ((struct yy_trans_info **) p)[0] != v)
- yy_fatal_error("tables verification failed at YYTD_PTRANS" YY_CALL_LAST_ARG);
+ yy_fatal_error("tables verification failed at YYTD_PTRANS" M4_YY_CALL_LAST_ARG);
}else
((struct yy_trans_info **) p)[0] = v;
@@ -2573,31 +3023,31 @@ static int yytbl_data_load YYFARGS2 (struct yytbl_dmap *, dmap, struct yytbl_rea
/* t32 is a plain int. copy data, then incrememnt p. */
switch (dmap->dm_sz) {
case sizeof (int32_t):
- if(YY_TABLES_VERIFY ){
+ if(M4_YY_TABLES_VERIFY ){
if( ((int32_t *) p)[0] != (int32_t) t32)
- yy_fatal_error("tables verification failed at int32_t" YY_CALL_LAST_ARG);
+ yy_fatal_error("tables verification failed at int32_t" M4_YY_CALL_LAST_ARG);
}else
((int32_t *) p)[0] = (int32_t) t32;
p = ((int32_t *) p) + 1;
break;
case sizeof (int16_t):
- if(YY_TABLES_VERIFY ){
+ if(M4_YY_TABLES_VERIFY ){
if( ((int16_t *) p)[0] != (int16_t) t32)
- yy_fatal_error("tables verification failed at int16_t" YY_CALL_LAST_ARG);
+ yy_fatal_error("tables verification failed at int16_t" M4_YY_CALL_LAST_ARG);
}else
((int16_t *) p)[0] = (int16_t) t32;
p = ((int16_t *) p) + 1;
break;
case sizeof (int8_t):
- if(YY_TABLES_VERIFY ){
+ if(M4_YY_TABLES_VERIFY ){
if( ((int8_t *) p)[0] != (int8_t) t32)
- yy_fatal_error("tables verification failed at int8_t" YY_CALL_LAST_ARG);
+ yy_fatal_error("tables verification failed at int8_t" M4_YY_CALL_LAST_ARG);
}else
((int8_t *) p)[0] = (int8_t) t32;
p = ((int8_t *) p) + 1;
break;
default:
- yy_fatal_error("invalid dmap->dm_sz for plain int" /*TODO: not fatal.*/ YY_CALL_LAST_ARG);
+ yy_fatal_error("invalid dmap->dm_sz for plain int" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
return -1;
}
}
@@ -2622,7 +3072,7 @@ static int yytbl_data_load YYFARGS2 (struct yytbl_dmap *, dmap, struct yytbl_rea
%define-yytables The name for this specific scanner's tables.
/* Find the key and load the DFA tables from the given stream. */
-static int yytbl_fload YYFARGS2 (FILE *, fp, const char *, key)
+static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key)
{
int rv=0;
struct yytbl_hdr th;
@@ -2634,7 +3084,7 @@ static int yytbl_fload YYFARGS2 (FILE *, fp, const char *, key)
/* Keep trying until we find the right set of tables or end of file. */
while (!feof(rd.fp)) {
rd.bread = 0;
- if (yytbl_hdr_read (&th, &rd YY_CALL_LAST_ARG) != 0){
+ if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0){
rv = -1;
goto return_rv;
}
@@ -2646,7 +3096,7 @@ static int yytbl_fload YYFARGS2 (FILE *, fp, const char *, key)
if (strcmp(th.th_name,key) != 0){
/* Skip ahead to next set */
fseek(rd.fp, th.th_ssize - th.th_hsize, SEEK_CUR);
- yyfree(th.th_version YY_CALL_LAST_ARG);
+ yyfree(th.th_version M4_YY_CALL_LAST_ARG);
th.th_version = NULL;
}
else
@@ -2655,7 +3105,7 @@ static int yytbl_fload YYFARGS2 (FILE *, fp, const char *, key)
while (rd.bread < th.th_ssize){
/* Load the data tables */
- if(yytbl_data_load (yydmap,&rd YY_CALL_LAST_ARG) != 0){
+ if(yytbl_data_load (yydmap,&rd M4_YY_CALL_LAST_ARG) != 0){
rv = -1;
goto return_rv;
}
@@ -2663,7 +3113,7 @@ static int yytbl_fload YYFARGS2 (FILE *, fp, const char *, key)
return_rv:
if(th.th_version){
- yyfree(th.th_version YY_CALL_LAST_ARG);
+ yyfree(th.th_version M4_YY_CALL_LAST_ARG);
th.th_version = NULL;
}
@@ -2671,9 +3121,10 @@ return_rv:
}
/** Load the DFA tables for this scanner from the given stream. */
-int yytables_fload YYFARGS1 (FILE *, fp)
+int yytables_fload YYFARGS1(FILE *, fp)
{
- if( yytbl_fload(fp, YYTABLES_NAME YY_CALL_LAST_ARG) != 0)
+
+ if( yytbl_fload(fp, YYTABLES_NAME M4_YY_CALL_LAST_ARG) != 0)
return -1;
return 0;
}
@@ -2683,13 +3134,13 @@ int yytables_destroy YYFARGS0(void)
{
struct yytbl_dmap *dmap=0;
- if(!YY_TABLES_VERIFY){
+ if(!M4_YY_TABLES_VERIFY){
/* Walk the dmap, freeing the pointers */
for(dmap=yydmap; dmap->dm_id; dmap++) {
void * v;
v = dmap->dm_arr;
if(v && *(char**)v){
- yyfree(*(char**)v YY_CALL_LAST_ARG);
+ yyfree(*(char**)v M4_YY_CALL_LAST_ARG);
*(char**)v = NULL;
}
}
@@ -2701,11 +3152,12 @@ int yytables_destroy YYFARGS0(void)
/* end table serialization code definitions */
%endif
-#if YY_MAIN
-int main YY_PARAMS((void));
+
+m4_ifdef([[M4_YY_MAIN]], [[
+int main M4_YY_PARAMS(void);
int main ()
- {
+{
%if-reentrant
yyscan_t lexer;
@@ -2719,6 +3171,19 @@ int main ()
%endif
return 0;
- }
-#endif
+}
+]])
+
%ok-for-header
+#undef YY_NEW_FILE
+#undef YY_FLUSH_BUFFER
+#undef yy_set_bol
+#undef yy_new_buffer
+#undef yy_set_interactive
+#undef yytext_ptr
+#undef YY_DO_BEFORE_ACTION
+
+#ifdef YY_DECL_IS_OURS
+#undef YY_DECL_IS_OURS
+#undef YY_DECL
+#endif
diff --git a/flexdef.h b/flexdef.h
index e83422b..4803d12 100644
--- a/flexdef.h
+++ b/flexdef.h
@@ -42,9 +42,11 @@
#ifdef STDC_HEADERS
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <setjmp.h>
#include <ctype.h>
#include <string.h>
+#include <math.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
@@ -54,6 +56,8 @@
#include <unistd.h>
#endif
+#include <regex.h>
+
/* We use gettext. So, when we write strings which should be translated, we mark them with _() */
#ifdef ENABLE_NLS
#ifdef HAVE_LOCALE_H
@@ -349,6 +353,7 @@
* otherwise, a standard C scanner
* reentrant - if true (-R), generate a reentrant C scanner.
* bison_bridge - if true (--bison-bridge), bison pure calling convention.
+ * bison_bridge_locations - if true (--bison-locations), bison yylloc.
* long_align - if true (-Ca flag), favor long-word alignment.
* use_read - if true (-f, -F, or -Cr) then use read() for scanner input;
* otherwise, use fread().
@@ -375,7 +380,8 @@ extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn,
extern int interactive, caseins, lex_compat, posix_compat, do_yylineno;
extern int useecs, fulltbl, usemecs, fullspd;
extern int gen_line_dirs, performance_report, backing_up_report;
-extern int reentrant, bison_bridge;
+extern int reentrant, bison_bridge, bison_bridge_locations;
+extern bool ansi_func_defs, ansi_func_protos;
extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap;
extern int csize;
extern int yymore_used, reject, real_reject, continued_action, in_rule;
@@ -916,6 +922,7 @@ PROTO ((const char *, const char *, const char *, const char *));
extern void out_str_dec PROTO ((const char *, const char *, int));
extern void outc PROTO ((int));
extern void outn PROTO ((const char *));
+extern void out_m4_define (const char* def, const char* val);
/* Return a printable version of the given character, which might be
* 8-bit.
@@ -1077,12 +1084,16 @@ extern void buf_init PROTO ((struct Buf * buf, size_t elem_size));
extern void buf_destroy PROTO ((struct Buf * buf));
extern struct Buf *buf_append
PROTO ((struct Buf * buf, const void *ptr, int n_elem));
+extern struct Buf *buf_concat PROTO((struct Buf* dest, const struct Buf* src));
extern struct Buf *buf_strappend PROTO ((struct Buf *, const char *str));
extern struct Buf *buf_strnappend
PROTO ((struct Buf *, const char *str, int nchars));
extern struct Buf *buf_strdefine
PROTO ((struct Buf * buf, const char *str, const char *def));
extern struct Buf *buf_prints PROTO((struct Buf *buf, const char *fmt, const char* s));
+extern struct Buf *buf_m4_define PROTO((struct Buf *buf, const char* def, const char* val));
+extern struct Buf *buf_m4_undefine PROTO((struct Buf *buf, const char* def));
+extern struct Buf *buf_print_strings PROTO((struct Buf * buf, FILE* out));
/* a string buffer for #define's generated by user-options on cmd line. */
extern struct Buf userdef_buf;
@@ -1093,9 +1104,12 @@ extern struct Buf defs_buf;
/* a string buffer to hold yydmap elements */
extern struct Buf yydmap_buf;
+/* Holds m4 definitions. */
+extern struct Buf m4defs_buf;
+
/* For blocking out code from the header file. */
-#define OUT_BEGIN_CODE() out_str("#ifndef %sIN_HEADER /* YY-DISCARD-FROM-HEADER */\n",prefix)
-#define OUT_END_CODE() out_str("#endif /* !%sIN_HEADER YY-END-DISCARD-FROM-HEADER */\n",prefix);
+#define OUT_BEGIN_CODE() outn("m4_ifdef( [[M4_YY_IN_HEADER]],,[[")
+#define OUT_END_CODE() outn("]])")
/* For setjmp/longjmp (instead of calling exit(2)). Linkage in main.c */
extern jmp_buf flex_main_jmp_buf;
@@ -1129,4 +1143,45 @@ int reverse_case(int c);
/* return false if [c1-c2] is ambiguous for a caseless scanner. */
bool range_covers_case (int c1, int c2);
+/*
+ * From "filter.c"
+ */
+
+/** A single stdio filter to execute.
+ * The filter may be external, such as "sed", or it
+ * may be internal, as a function call.
+ */
+struct filter {
+ int (*filter_func)(struct filter*); /**< internal filter function */
+ void * extra; /**< extra data passed to filter_func */
+ int argc; /**< arg count */
+ const char ** argv; /**< arg vector, \0-terminated */
+ struct filter * next; /**< next filter or NULL */
+};
+
+/* output filter chain */
+extern struct filter * output_chain;
+extern struct filter *filter_create_ext PROTO((struct filter * chain, const char *cmd, ...));
+struct filter *filter_create_int PROTO((struct filter *chain,
+ int (*filter_func) (struct filter *),
+ void *extra));
+extern bool filter_apply_chain PROTO((struct filter * chain));
+extern int filter_truncate (struct filter * chain, int max_len);
+extern int filter_tee_header PROTO((struct filter *chain));
+extern int filter_fix_linedirs PROTO((struct filter *chain));
+
+
+/*
+ * From "regex.c"
+ */
+
+extern regex_t regex_linedir, regex_blank_line;
+bool flex_init_regex(void);
+void flex_regcomp(regex_t *preg, const char *regex, int cflags);
+char *regmatch_dup (regmatch_t * m, const char *src);
+char *regmatch_cpy (regmatch_t * m, char *dest, const char *src);
+int regmatch_len (regmatch_t * m);
+int regmatch_strtol (regmatch_t * m, const char *src, char **endptr, int base);
+bool regmatch_empty (regmatch_t * m);
+
#endif /* not defined FLEXDEF_H */
diff --git a/gen.c b/gen.c
index eb9acd8..62a453d 100644
--- a/gen.c
+++ b/gen.c
@@ -125,7 +125,7 @@ static void geneoltbl ()
{
int i;
- outn ("#ifdef YY_USE_LINENO");
+ outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[[");
outn ("/* Table of booleans, true if rule could match eol. */");
out_str_dec (get_int32_decl (), "yy_rule_can_match_eol",
num_rules + 1);
@@ -139,7 +139,7 @@ static void geneoltbl ()
}
out (" };\n");
}
- outn ("#endif");
+ outn ("]])");
}
@@ -762,19 +762,19 @@ void gen_next_match ()
* gen_NUL_trans().
*/
char *char_map = useecs ?
- "yy_ec[YY_SC_TO_UI(*yy_cp)]" : "YY_SC_TO_UI(*yy_cp)";
+ "yy_ec[YY_SC_TO_UI(*yy_cp)] " : "YY_SC_TO_UI(*yy_cp)";
char *char_map_2 = useecs ?
- "yy_ec[YY_SC_TO_UI(*++yy_cp)]" : "YY_SC_TO_UI(*++yy_cp)";
+ "yy_ec[YY_SC_TO_UI(*++yy_cp)] " : "YY_SC_TO_UI(*++yy_cp)";
if (fulltbl) {
if (gentables)
indent_put2s
- ("while ( (yy_current_state = yy_nxt[yy_current_state][%s]) > 0 )",
+ ("while ( (yy_current_state = yy_nxt[yy_current_state][ %s ]) > 0 )",
char_map);
else
indent_put2s
- ("while ( (yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %s]) > 0 )",
+ ("while ( (yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %s ]) > 0 )",
char_map);
indent_up ();
@@ -1038,12 +1038,12 @@ void gen_start_state ()
if (reject) {
/* Set up for storing up states. */
- outn ("#ifdef YY_USES_REJECT");
+ outn ("m4_ifdef( [[M4_YY_USES_REJECT]],\n[[");
indent_puts
("YY_G(yy_state_ptr) = YY_G(yy_state_buf);");
indent_puts
("*YY_G(yy_state_ptr)++ = yy_current_state;");
- outn ("#endif");
+ outn ("]])");
}
}
}
@@ -1544,7 +1544,7 @@ void make_tables ()
if (yymore_used) {
indent_puts
- ("yy_flex_strncpy( &yytext[YY_G(yy_more_offset)], YY_G(yytext_ptr), yyleng + 1 YY_CALL_LAST_ARG); \\");
+ ("yy_flex_strncpy( &yytext[YY_G(yy_more_offset)], YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG); \\");
indent_puts ("yyleng += YY_G(yy_more_offset); \\");
indent_puts
("YY_G(yy_prev_more_offset) = YY_G(yy_more_offset); \\");
@@ -1552,7 +1552,7 @@ void make_tables ()
}
else {
indent_puts
- ("yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 YY_CALL_LAST_ARG); \\");
+ ("yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG); \\");
}
}
@@ -1761,7 +1761,7 @@ void make_tables ()
}
if (reject) {
- outn ("#ifdef YY_USES_REJECT");
+ outn ("m4_ifdef( [[M4_YY_USES_REJECT]],\n[[");
/* Declare state buffer variables. */
if (!C_plus_plus && !reentrant) {
outn ("static yy_state_type *yy_state_buf=0, *yy_state_ptr=0;");
@@ -1797,7 +1797,7 @@ void make_tables ()
outn ("goto find_rule; \\");
outn ("}");
- outn ("#endif");
+ outn ("]])\n");
}
else {
@@ -1810,26 +1810,23 @@ void make_tables ()
if (yymore_used) {
if (!C_plus_plus) {
if (yytext_is_array) {
- outn ("#ifndef YY_REENTRANT");
- indent_puts
- ("static int yy_more_offset = 0;");
- indent_puts
- ("static int yy_prev_more_offset = 0;");
- outn ("#endif");
+ if (!reentrant){
+ indent_puts ("static int yy_more_offset = 0;");
+ }else{
+ indent_puts ("static int yy_prev_more_offset = 0;");
+ }
}
else if (!reentrant) {
- outn ("#ifndef YY_REENTRANT");
indent_puts
("static int yy_more_flag = 0;");
indent_puts
("static int yy_more_len = 0;");
- outn ("#endif");
}
}
if (yytext_is_array) {
indent_puts
- ("#define yymore() (YY_G(yy_more_offset) = yy_flex_strlen( yytext YY_CALL_LAST_ARG))");
+ ("#define yymore() (YY_G(yy_more_offset) = yy_flex_strlen( yytext M4_YY_CALL_LAST_ARG))");
indent_puts ("#define YY_NEED_STRLEN");
indent_puts ("#define YY_MORE_ADJ 0");
indent_puts
@@ -1863,16 +1860,15 @@ void make_tables ()
outn ("#ifndef YYLMAX");
outn ("#define YYLMAX 8192");
outn ("#endif\n");
- outn ("#ifndef YY_REENTRANT");
- outn ("char yytext[YYLMAX];");
- outn ("char *yytext_ptr;");
- outn ("#endif");
+ if (!reentrant){
+ outn ("char yytext[YYLMAX];");
+ outn ("char *yytext_ptr;");
+ }
}
else {
- outn ("#ifndef YY_REENTRANT");
- outn ("char *yytext;");
- outn ("#endif");
+ if(! reentrant)
+ outn ("char *yytext;");
}
}
@@ -1978,7 +1974,7 @@ void make_tables ()
gen_find_action ();
skelout (); /* %% [11.0] - break point in skel */
- outn ("#ifdef YY_USE_LINENO");
+ outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[[");
indent_puts
("if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )");
indent_up ();
@@ -1996,7 +1992,7 @@ void make_tables ()
indent_down ();
indent_puts ("}");
indent_down ();
- outn ("#endif");
+ outn ("]])");
skelout (); /* %% [12.0] - break point in skel */
if (ddebug) {
diff --git a/main.c b/main.c
index 9df7269..94a78da 100644
--- a/main.c
+++ b/main.c
@@ -54,7 +54,7 @@ int interactive, caseins, lex_compat, posix_compat, do_yylineno,
int fullspd, gen_line_dirs, performance_report, backing_up_report;
int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap,
csize;
-int reentrant, bison_bridge;
+int reentrant, bison_bridge, bison_bridge_locations;
int yymore_used, reject, real_reject, continued_action, in_rule;
int yymore_really_used, reject_really_used;
int datapos, dataline, linenum, out_linenum;
@@ -105,6 +105,7 @@ int num_input_files;
jmp_buf flex_main_jmp_buf;
bool *rule_has_nl, *ccl_has_nl;
int nlch = '\n';
+bool ansi_func_defs, ansi_func_protos;
bool tablesext, tablesverify, gentables;
char *tablesfilename=0,*tablesname=0;
@@ -129,13 +130,18 @@ static char *tablesfile_template = "lex%s.tbl";
extern unsigned _stklen = 16384;
#endif
+/* From scan.l */
+extern FILE* yyout;
+
static char outfile_path[MAXLINE];
static int outfile_created = 0;
static char *skelname = NULL;
+/* For debugging. The max number of filters to apply to skeleton. */
+static int preproc_level = 1000;
+
int flex_main PROTO ((int argc, char *argv[]));
int main PROTO ((int argc, char *argv[]));
-void fix_line_dirs PROTO ((char *, char *, char *, int));
int flex_main (argc, argv)
int argc;
@@ -151,8 +157,13 @@ int flex_main (argc, argv)
* exit(n);
*/
exit_status = setjmp (flex_main_jmp_buf);
- if (exit_status)
+ if (exit_status){
+ fflush(stdout);
+ fclose(stdout);
+ while (wait(0) > 0){
+ }
return exit_status - 1;
+ }
flexinit (argc, argv);
@@ -222,10 +233,6 @@ void check_options ()
use_read = false;
}
- /* See comments in flexend() for an explanation of this error condition. */
- if (use_stdout && headerfilename)
- flexerror (_
- ("Can't specify header option if writing to stdout."));
#if 0
/* This makes no sense whatsoever. I'm removing it. */
@@ -304,6 +311,12 @@ void check_options ()
}
}
+ if (!ansi_func_defs)
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_ANSI_FUNC_DEFS", NULL);
+
+ if (!ansi_func_protos)
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_ANSI_FUNC_PROTOS", NULL);
+
if (!use_stdout) {
FILE *prev_stdout;
@@ -329,8 +342,21 @@ void check_options ()
outfile_created = 1;
}
+ /* Setup the filter chain. */
+ output_chain = filter_create_int(NULL, filter_tee_header, headerfilename);
+ filter_create_ext(output_chain,"m4","-P",0);
+ filter_create_int(output_chain, filter_fix_linedirs, NULL);
+
+ /* For debugging, only run the requested number of filters. */
+ if (preproc_level > 0) {
+ filter_truncate(output_chain, preproc_level);
+ filter_apply_chain(output_chain);
+ }
+ yyout = stdout;
+
+
/* always generate the tablesverify flag. */
- action_define ("YY_TABLES_VERIFY", tablesverify ? 1 : 0);
+ buf_m4_define (&m4defs_buf, "M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0");
if (tablesext)
gentables = false;
@@ -345,7 +371,7 @@ void check_options ()
char *pname = 0;
int nbytes = 0;
- action_define ("YY_TABLES_EXTERNAL", 1);
+ buf_m4_define (&m4defs_buf, "M4_YY_TABLES_EXTERNAL", NULL);
if (!tablesfilename) {
nbytes = strlen (prefix) +
@@ -376,96 +402,49 @@ void check_options ()
lerrsf (_("can't open skeleton file %s"), skelname);
if (reentrant) {
- outn ("#define YY_REENTRANT 1");
+ buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL);
if (yytext_is_array)
- outn ("#define YY_TEXT_IS_ARRAY");
+ buf_m4_define (&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL);
}
if ( bison_bridge)
- outn ("#define YY_BISON_BRIDGE 1");
+ buf_m4_define (&m4defs_buf, "M4_YY_BISON_BRIDGE", NULL);
- if (strcmp (prefix, "yy")) {
-#define GEN_PREFIX(name) out_str3( "#define yy%s %s%s\n", name, prefix, name )
- if (C_plus_plus)
- GEN_PREFIX ("FlexLexer");
- else {
- outn ("#ifndef YY_REENTRANT");
- GEN_PREFIX ("text");
- GEN_PREFIX ("leng");
- GEN_PREFIX ("in");
- GEN_PREFIX ("out");
- GEN_PREFIX ("_flex_debug");
- outn ("#endif");
- GEN_PREFIX ("_create_buffer");
- GEN_PREFIX ("_delete_buffer");
- GEN_PREFIX ("_scan_buffer");
- GEN_PREFIX ("_scan_string");
- GEN_PREFIX ("_scan_bytes");
- GEN_PREFIX ("_init_buffer");
- GEN_PREFIX ("_flush_buffer");
- GEN_PREFIX ("_load_buffer_state");
- GEN_PREFIX ("_switch_to_buffer");
- GEN_PREFIX ("push_buffer_state");
- GEN_PREFIX ("pop_buffer_state");
- GEN_PREFIX ("ensure_buffer_stack");
- GEN_PREFIX ("lex");
- GEN_PREFIX ("restart");
- GEN_PREFIX ("lex_init");
- GEN_PREFIX ("lex_destroy");
- GEN_PREFIX ("get_debug");
- GEN_PREFIX ("set_debug");
- GEN_PREFIX ("get_extra");
- GEN_PREFIX ("set_extra");
- GEN_PREFIX ("get_in");
- GEN_PREFIX ("set_in");
- GEN_PREFIX ("get_out");
- GEN_PREFIX ("set_out");
- GEN_PREFIX ("get_leng");
- GEN_PREFIX ("get_text");
- GEN_PREFIX ("get_lineno");
- GEN_PREFIX ("set_lineno");
-
- outn ("#ifdef YY_BISON_BRIDGE");
- GEN_PREFIX ("get_lval");
- GEN_PREFIX ("set_lval");
- GEN_PREFIX ("get_lloc");
- GEN_PREFIX ("set_lloc");
- outn ("#endif");
-
- }
+ if ( bison_bridge_locations)
+ buf_m4_define (&m4defs_buf, "M4_YY_BISON_BRIDGE_LOCATIONS", NULL);
- /* The alloc/realloc/free functions are used internally by the
- * generated scanner for both and C++.
- */
- GEN_PREFIX ("alloc");
- GEN_PREFIX ("realloc");
- GEN_PREFIX ("free");
-
- if (!reentrant)
- GEN_PREFIX ("lineno");
-
- if (do_yywrap)
- GEN_PREFIX ("wrap");
-
- if (tablesext){
- GEN_PREFIX ("tables_fload");
- GEN_PREFIX ("tables_destroy");
- GEN_PREFIX ("TABLES_NAME");
- }
-
- outn ("");
- }
+ buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix);
if (did_outfilename)
line_directive_out (stdout, 0);
if (do_yylineno)
- buf_strdefine (&userdef_buf, "YY_USE_LINENO", "1");
+ buf_m4_define (&m4defs_buf, "M4_YY_USE_LINENO", NULL);
/* Create the alignment type. */
buf_strdefine (&userdef_buf, "YY_INT_ALIGNED",
long_align ? "long int" : "short int");
+ /* Define the start condition macros. */
+ {
+ struct Buf tmpbuf;
+ buf_init(&tmpbuf, sizeof(char));
+ for (i = 1; i <= lastsc; i++) {
+ char *str, *fmt = "#define %s %d\n";
+
+ str = (char*)flex_alloc(strlen(fmt) + strlen(scname[i]) + (int)(1 + log(i)/log(10)) + 2);
+ sprintf(str, fmt, scname[i], i - 1);
+ buf_strappend(&tmpbuf, str);
+ free(str);
+ }
+ buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts);
+ buf_destroy(&tmpbuf);
+ }
+
+ /* Dump the m4 definitions. */
+ buf_print_strings(&m4defs_buf, stdout);
+ m4defs_buf.nelts = 0; /* memory leak here. */
+
/* Dump the user defined preproc directives. */
if (userdef_buf.elts)
outn ((char *) (userdef_buf.elts));
@@ -474,61 +453,6 @@ void check_options ()
/* %% [1.0] */
}
-/* Alter #line directives from the generated source, destined
- * for the generated header. We chaneg the line number and filename.
- * linebuf is modified in place.
- */
-void fix_line_dirs (linebuf, outfilename, headerfilename, nlines)
- char *linebuf;
- char *outfilename;
- char *headerfilename;
- int nlines;
-{
- char *pname, *p;
-
- /* Match pattern: ^#line +[:digit:]+ +"outfilename" */
- p = linebuf;
- if (strncmp (p, "#line ", 6))
- return;
- p += 6;
-
- /* match spaces */
- while (*p == ' ')
- p++;
- if (!isdigit (*p))
- return;
-
- /* match numbers */
- while (isdigit (*p))
- p++;
- if (*p != ' ')
- return;
-
- /* match spaces */
- while (*p == ' ')
- p++;
- if (*p != '"')
- return;
- p++;
-
- pname = p;
-
- /* find end of filename. Note: If scanner filename has
- * embedded '"' chars, then the generated #line directive
- * may fail. */
- while (*p != '\0' && *p != '"')
- p++;
- if (*p != '"')
- return;
-
- if (strncmp (pname, outfilename, p - pname) != 0)
- return;
-
- /* We have a match. */
-
- sprintf (linebuf, "#line %d \"%s\"\n", nlines + 2, headerfilename);
-}
-
/* flexend - terminate flex
*
* note
@@ -541,7 +465,6 @@ void flexend (exit_status)
{
static int called_before = -1; /* prevent infinite recursion. */
int tblsiz;
- int i;
if (++called_before)
FLEX_EXIT (exit_status);
@@ -556,61 +479,7 @@ void flexend (exit_status)
skelname);
}
- /* flex generates the header file by rewinding the output FILE
- * pointer. However, since we can't rewind stdout, we must disallow
- * %option header if we are writing to stdout. This is a kludge.
- * This kludge can be rewritten when we get around to buffering
- * Section 1 of the input file, because then we'll have seen all the
- * %options BEFORE we begin generating the scanner. The lack of
- * buffering causes other problems, too. For example, it is the
- * reason we currently can't provide a mechanism to allow the user
- * to inject arbitrary class members into the generated C++ scanner. - JM
- */
- if (headerfilename && exit_status == 0 && outfile_created
- && !ferror (stdout)) {
- /* Copy the file we just wrote to a header file. */
-#define LINE_SZ 512
- FILE *header_out;
- char linebuf[LINE_SZ];
- int nlines = 0;
- int discard = 0;
-
- /* rewind the outfile file. */
- fflush (stdout);
- fseek (stdout, 0L, SEEK_SET);
-
- header_out = fopen (headerfilename, "w");
- if (header_out == NULL)
- lerrsf (_("could not create %s"), headerfilename);
-
- fprintf (header_out, "#ifndef %sHEADER_H\n", prefix);
- fprintf (header_out, "#define %sHEADER_H 1\n", prefix);
- fprintf (header_out, "#define %sIN_HEADER 1\n\n", prefix);
- fflush (header_out);
-
- nlines = 4;
- while (fgets (linebuf, LINE_SZ, stdout)) {
- if (strstr (linebuf, "YY-DISCARD-FROM-HEADER"))
- discard++;
- else if (strstr
- (linebuf, "YY-END-DISCARD-FROM-HEADER")) {
- discard--;
- continue;
- }
-
- if (discard)
- continue;
-
- fix_line_dirs (linebuf, outfilename,
- headerfilename, nlines);
- fputs (linebuf, header_out);
- nlines++;
- }
-
- fprintf (header_out, "#line %d \"%s\"\n", (++nlines) + 1,
- headerfilename);
-
- /* Print the start conditions. */
+#if 0
fprintf (header_out,
"#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n");
fprintf (header_out,
@@ -620,8 +489,7 @@ void flexend (exit_status)
fprintf (header_out,
"#undef INITIAL\n#define INITIAL 0\n");
for (i = 2; i <= lastsc; i++)
- fprintf (header_out, "#define %s %d\n", scname[i],
- i - 1);
+ fprintf (header_out, "#define %s %d\n", scname[i], i - 1);
fprintf (header_out,
"#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n");
@@ -649,19 +517,18 @@ void flexend (exit_status)
"YYLMAX",
"YYSTATE",
"YY_AT_BOL",
- "YY_BISON_BRIDGE",
"YY_BREAK",
"YY_BUFFER_EOF_PENDING",
"YY_BUFFER_NEW",
"YY_BUFFER_NORMAL",
"YY_BUF_SIZE",
- "YY_CALL_LAST_ARG",
- "YY_CALL_ONLY_ARG",
+ "M4_YY_CALL_LAST_ARG",
+ "M4_YY_CALL_ONLY_ARG",
"YY_CURRENT_BUFFER",
"YY_DECL",
- "YY_DECL_LAST_ARG",
- "YY_DEF_LAST_ARG",
- "YY_DEF_ONLY_ARG",
+ "M4_YY_DECL_LAST_ARG",
+ "M4_YY_DEF_LAST_ARG",
+ "M4_YY_DEF_ONLY_ARG",
"YY_DO_BEFORE_ACTION",
"YY_END_OF_BUFFER",
"YY_END_OF_BUFFER_CHAR",
@@ -687,59 +554,27 @@ void flexend (exit_status)
"YY_MORE_ADJ",
"YY_NEED_STRLEN",
"YY_NEW_FILE",
- "YY_NO_FLEX_ALLOC",
- "YY_NO_FLEX_FREE",
- "YY_NO_FLEX_REALLOC",
- "YY_NO_GET_DEBUG",
- "YY_NO_GET_EXTRA",
- "YY_NO_GET_IN",
- "YY_NO_GET_LENG",
- "YY_NO_GET_LINENO",
- "YY_NO_GET_LLOC",
- "YY_NO_GET_LVAL",
- "YY_NO_GET_OUT",
- "YY_NO_GET_TEXT",
- "YY_NO_INPUT",
- "YY_NO_POP_STATE",
- "YY_NO_PUSH_STATE",
- "YY_NO_SCAN_BUFFER",
- "YY_NO_SCAN_BYTES",
- "YY_NO_SCAN_STRING",
- "YY_NO_SET_DEBUG",
- "YY_NO_SET_EXTRA",
- "YY_NO_SET_IN",
- "YY_NO_SET_LINENO",
- "YY_NO_SET_LLOC",
- "YY_NO_SET_LVAL",
- "YY_NO_SET_OUT",
- "YY_NO_TOP_STATE",
- "YY_NO_UNISTD_H",
- "YY_NO_UNPUT",
"YY_NULL",
"YY_NUM_RULES",
"YY_ONLY_ARG",
"YY_PARAMS",
"YY_PROTO",
- "YY_PROTO_LAST_ARG",
- "YY_PROTO_ONLY_ARG void",
+ "M4_YY_PROTO_LAST_ARG",
+ "M4_YY_PROTO_ONLY_ARG void",
"YY_READ_BUF_SIZE",
"YY_REENTRANT",
"YY_RESTORE_YY_MORE_OFFSET",
"YY_RULE_SETUP",
"YY_SC_TO_UI",
"YY_SKIP_YYWRAP",
- "YY_STACK_USED",
"YY_START",
"YY_START_STACK_INCR",
"YY_STATE_EOF",
"YY_STDINIT",
- "YY_TEXT_IS_ARRAY",
"YY_TRAILING_HEAD_MASK",
"YY_TRAILING_MASK",
"YY_USER_ACTION",
- "YY_USES_REJECT",
"YY_USE_CONST",
- "YY_USE_LINENO",
"YY_USE_PROTOS",
"unput",
"yyTABLES_NAME",
@@ -828,7 +663,7 @@ void flexend (exit_status)
headerfilename);
fflush (header_out);
fclose (header_out);
- }
+#endif
if (exit_status != 0 && outfile_created) {
if (ferror (stdout))
@@ -894,6 +729,8 @@ void flexend (exit_status)
fputs ("--reentrant", stderr);
if (bison_bridge)
fputs ("--bison-bridge", stderr);
+ if (bison_bridge_locations)
+ fputs ("--bison-locations", stderr);
if (use_stdout)
putc ('t', stderr);
if (printstats)
@@ -1075,7 +912,7 @@ void flexinit (argc, argv)
yymore_really_used = reject_really_used = unspecified;
interactive = csize = unspecified;
do_yywrap = gen_line_dirs = usemecs = useecs = true;
- reentrant = bison_bridge = false;
+ reentrant = bison_bridge = bison_bridge_locations = false;
performance_report = 0;
did_outfilename = 0;
prefix = "yy";
@@ -1084,6 +921,7 @@ void flexinit (argc, argv)
tablesext = tablesverify = false;
gentables = true;
tablesfilename = tablesname = NULL;
+ ansi_func_defs = ansi_func_protos = true;
sawcmpflag = false;
@@ -1098,6 +936,15 @@ void flexinit (argc, argv)
buf_init (&defs_buf, sizeof (char *)); /* list of strings */
buf_init (&yydmap_buf, sizeof (char)); /* one long string */
+ {
+ const char * m4defs_init_str[] = {"m4_changequote\n",
+ "m4_changequote([[, ]])\n"};
+ buf_init (&m4defs_buf, sizeof (char *));
+ buf_append (&m4defs_buf, &m4defs_init_str, 2);
+ }
+
+ /* initialize regex lib */
+ flex_init_regex();
/* Enable C++ if program name ends with '+'. */
program_name = basename2 (argv[0], 0);
@@ -1222,6 +1069,10 @@ void flexinit (argc, argv)
posix_compat = true;
break;
+ case OPT_PREPROC_LEVEL:
+ preproc_level = strtol(arg,NULL,0);
+ break;
+
case OPT_MAIN:
buf_strdefine (&userdef_buf, "YY_MAIN", "1");
do_yywrap = false;
@@ -1252,6 +1103,10 @@ void flexinit (argc, argv)
bison_bridge = true;
break;
+ case OPT_BISON_BRIDGE_LOCATIONS:
+ bison_bridge = bison_bridge_locations = true;
+ break;
+
case OPT_REENTRANT:
reentrant = true;
break;
@@ -1277,8 +1132,8 @@ void flexinit (argc, argv)
break;
case OPT_NO_UNISTD_H:
- buf_strdefine (&userdef_buf, "YY_NO_UNISTD_H",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_UNISTD_H", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_UNISTD_H",0);
break;
case OPT_TABLES_FILE:
@@ -1327,13 +1182,11 @@ void flexinit (argc, argv)
break;
case OPT_ALWAYS_INTERACTIVE:
- buf_strdefine (&userdef_buf,
- "YY_ALWAYS_INTERACTIVE", "1");
+ buf_m4_define (&m4defs_buf, "M4_YY_ALWAYS_INTERACTIVE", 0);
break;
case OPT_NEVER_INTERACTIVE:
- buf_strdefine (&userdef_buf,
- "YY_NEVER_INTERACTIVE", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NEVER_INTERACTIVE", 0);
break;
case OPT_ARRAY:
@@ -1394,7 +1247,8 @@ void flexinit (argc, argv)
break;
case OPT_STACK:
- buf_strdefine (&userdef_buf, "YY_STACK_USED", "1");
+ //buf_strdefine (&userdef_buf, "YY_STACK_USED", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_STACK_USED",0);
break;
case OPT_STDINIT:
@@ -1441,84 +1295,97 @@ void flexinit (argc, argv)
reject_really_used = false;
break;
+ case OPT_NO_ANSI_FUNC_DEFS:
+ ansi_func_defs = false;
+ break;
+
+ case OPT_NO_ANSI_FUNC_PROTOS:
+ ansi_func_protos = false;
+ break;
+
case OPT_NO_YY_PUSH_STATE:
- buf_strdefine (&userdef_buf, "YY_NO_PUSH_STATE",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_PUSH_STATE", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_PUSH_STATE",0);
break;
case OPT_NO_YY_POP_STATE:
- buf_strdefine (&userdef_buf, "YY_NO_POP_STATE",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_POP_STATE", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_POP_STATE",0);
break;
case OPT_NO_YY_TOP_STATE:
- buf_strdefine (&userdef_buf, "YY_NO_TOP_STATE",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_TOP_STATE", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_TOP_STATE",0);
break;
case OPT_NO_UNPUT:
- buf_strdefine (&userdef_buf, "YY_NO_UNPUT", "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_UNPUT", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_UNPUT",0);
break;
case OPT_NO_YY_SCAN_BUFFER:
- buf_strdefine (&userdef_buf, "YY_NO_SCAN_BUFFER",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_SCAN_BUFFER", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BUFFER",0);
break;
case OPT_NO_YY_SCAN_BYTES:
- buf_strdefine (&userdef_buf, "YY_NO_SCAN_BYTES",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_SCAN_BYTES", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BYTES",0);
break;
case OPT_NO_YY_SCAN_STRING:
- buf_strdefine (&userdef_buf, "YY_NO_SCAN_STRING",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_SCAN_STRING", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_STRING",0);
break;
case OPT_NO_YYGET_EXTRA:
- buf_strdefine (&userdef_buf, "YY_NO_GET_EXTRA",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_GET_EXTRA", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_EXTRA",0);
break;
case OPT_NO_YYSET_EXTRA:
- buf_strdefine (&userdef_buf, "YY_NO_SET_EXTRA",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_SET_EXTRA", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_EXTRA",0);
break;
case OPT_NO_YYGET_LENG:
- buf_strdefine (&userdef_buf, "YY_NO_GET_LENG",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_GET_LENG", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LENG",0);
break;
case OPT_NO_YYGET_TEXT:
- buf_strdefine (&userdef_buf, "YY_NO_GET_TEXT",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_GET_TEXT", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_TEXT",0);
break;
case OPT_NO_YYGET_LINENO:
- buf_strdefine (&userdef_buf, "YY_NO_GET_LINENO",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_GET_LINENO", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LINENO",0);
break;
case OPT_NO_YYSET_LINENO:
- buf_strdefine (&userdef_buf, "YY_NO_SET_LINENO",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_SET_LINENO", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LINENO",0);
break;
case OPT_NO_YYGET_IN:
- buf_strdefine (&userdef_buf, "YY_NO_GET_IN", "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_GET_IN", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_IN",0);
break;
case OPT_NO_YYSET_IN:
- buf_strdefine (&userdef_buf, "YY_NO_SET_IN", "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_SET_IN", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_IN",0);
break;
case OPT_NO_YYGET_OUT:
- buf_strdefine (&userdef_buf, "YY_NO_GET_OUT", "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_GET_OUT", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_OUT",0);
break;
case OPT_NO_YYSET_OUT:
- buf_strdefine (&userdef_buf, "YY_NO_SET_OUT", "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_SET_OUT", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_OUT",0);
break;
case OPT_NO_YYGET_LVAL:
- buf_strdefine (&userdef_buf, "YY_NO_GET_LVAL",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_GET_LVAL", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LVAL",0);
break;
case OPT_NO_YYSET_LVAL:
- buf_strdefine (&userdef_buf, "YY_NO_SET_LVAL",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_SET_LVAL", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LVAL",0);
break;
case OPT_NO_YYGET_LLOC:
- buf_strdefine (&userdef_buf, "YY_NO_GET_LLOC",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_GET_LLOC", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LLOC",0);
break;
case OPT_NO_YYSET_LLOC:
- buf_strdefine (&userdef_buf, "YY_NO_SET_LLOC",
- "1");
+ //buf_strdefine (&userdef_buf, "YY_NO_SET_LLOC", "1");
+ buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0);
break;
} /* switch */
@@ -1668,8 +1535,10 @@ void readin ()
("variable trailing context rules cannot be used with -f or -F"));
}
- if (reject)
- outn ("\n#define YY_USES_REJECT");
+ if (reject){
+ out_m4_define( "M4_YY_USES_REJECT", NULL);
+ //outn ("\n#define YY_USES_REJECT");
+ }
if (!do_yywrap) {
outn ("\n#define yywrap(n) 1");
@@ -1697,15 +1566,16 @@ void readin ()
OUT_BEGIN_CODE ();
/* In reentrant scanner, stdinit is handled in flex.skl. */
if (do_stdinit) {
- outn ("#ifdef YY_REENTRANT");
- outn ("#ifdef VMS");
- outn ("#ifdef __VMS_POSIX");
- outn ("#define YY_STDINIT");
- outn ("#endif");
- outn ("#else");
- outn ("#define YY_STDINIT");
- outn ("#endif");
- outn ("#else /* end YY_REENTRANT */");
+ if (reentrant){
+ outn ("#ifdef VMS");
+ outn ("#ifdef __VMS_POSIX");
+ outn ("#define YY_STDINIT");
+ outn ("#endif");
+ outn ("#else");
+ outn ("#define YY_STDINIT");
+ outn ("#endif");
+ }
+
outn ("#ifdef VMS");
outn ("#ifndef __VMS_POSIX");
outn (yy_nostdinit);
@@ -1719,9 +1589,8 @@ void readin ()
}
else {
- outn ("#ifndef YY_REENTRANT");
- outn (yy_nostdinit);
- outn ("#endif");
+ if(!reentrant)
+ outn (yy_nostdinit);
}
OUT_END_CODE ();
}
@@ -1931,7 +1800,10 @@ void usage ()
" -P, --prefix=STRING use STRING as prefix instead of \"yy\"\n"
" -R, --reentrant generate a reentrant C scanner\n"
" --bison-bridge scanner for bison pure parser.\n"
+ " --bison-locations include yylloc support.\n"
" --stdinit initialize yyin/yyout to stdin/stdout\n"
+ " --noansi-definitions old-style function definitions\n"
+ " --noansi-prototypes empty parameter list in prototypes\n"
" --nounistd do not include <unistd.h>\n"
" --noFUNCTION do not generate a particular FUNCTION\n"
"\n" "Miscellaneous:\n"
diff --git a/misc.c b/misc.c
index 0ef04be..153e4b8 100644
--- a/misc.c
+++ b/misc.c
@@ -111,6 +111,27 @@ void action_define (defname, value)
}
+/** Append "m4_define([[defname]],[[value]])m4_dnl\n" to the running buffer.
+ * @param defname The macro name.
+ * @param value The macro value, can be NULL, which is the same as the empty string.
+ */
+void action_m4_define (const char *defname, const char * value)
+{
+ char buf[MAXLINE];
+
+ flexfatal ("DO NOT USE THIS FUNCTION!");
+
+ if ((int) strlen (defname) > MAXLINE / 2) {
+ format_pinpoint_message (_
+ ("name \"%s\" ridiculously long"),
+ defname);
+ return;
+ }
+
+ sprintf (buf, "m4_define([[%s]],[[%s]])m4_dnl\n", defname, value?value:"");
+ add_action (buf);
+}
+
/* Append "new_text" to the running buffer. */
void add_action (new_text)
char *new_text;
@@ -455,11 +476,11 @@ void line_directive_out (output_file, do_infile)
if (!gen_line_dirs)
return;
- if ((do_infile && !infilename) || (!do_infile && !outfilename))
- /* don't know the filename to use, skip */
- return;
+ s1 = do_infile ? infilename : "M4_YY_OUTFILE_NAME";
- s1 = do_infile ? infilename : outfilename;
+ if (do_infile && !s1)
+ s1 = "<stdin>";
+
s2 = filename;
s3 = &filename[sizeof (filename) - 2];
@@ -704,7 +725,7 @@ void out_dec (fmt, n)
const char *fmt;
int n;
{
- printf (fmt, n);
+ fprintf (stdout, fmt, n);
out_line_count (fmt);
}
@@ -712,7 +733,7 @@ void out_dec2 (fmt, n1, n2)
const char *fmt;
int n1, n2;
{
- printf (fmt, n1, n2);
+ fprintf (stdout, fmt, n1, n2);
out_line_count (fmt);
}
@@ -720,7 +741,7 @@ void out_hex (fmt, x)
const char *fmt;
unsigned int x;
{
- printf (fmt, x);
+ fprintf (stdout, fmt, x);
out_line_count (fmt);
}
@@ -737,7 +758,7 @@ void out_line_count (str)
void out_str (fmt, str)
const char *fmt, str[];
{
- printf (fmt, str);
+ fprintf (stdout,fmt, str);
out_line_count (fmt);
out_line_count (str);
}
@@ -745,7 +766,7 @@ void out_str (fmt, str)
void out_str3 (fmt, s1, s2, s3)
const char *fmt, s1[], s2[], s3[];
{
- printf (fmt, s1, s2, s3);
+ fprintf (stdout,fmt, s1, s2, s3);
out_line_count (fmt);
out_line_count (s1);
out_line_count (s2);
@@ -756,7 +777,7 @@ void out_str_dec (fmt, str, n)
const char *fmt, str[];
int n;
{
- printf (fmt, str, n);
+ fprintf (stdout,fmt, str, n);
out_line_count (fmt);
out_line_count (str);
}
@@ -764,7 +785,7 @@ void out_str_dec (fmt, str, n)
void outc (c)
int c;
{
- putc (c, stdout);
+ fputc (c, stdout);
if (c == '\n')
++out_linenum;
@@ -773,11 +794,23 @@ void outc (c)
void outn (str)
const char *str;
{
- puts (str);
+ fputs (str,stdout);
+ fputc('\n',stdout);
out_line_count (str);
++out_linenum;
}
+/** Print "m4_define( [[def]], [[val]])m4_dnl\n".
+ * @param def The m4 symbol to define.
+ * @param val The definition; may be NULL.
+ * @return buf
+ */
+void out_m4_define (const char* def, const char* val)
+{
+ const char * fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n";
+ fprintf(stdout, fmt, def, val?val:"");
+}
+
/* readable_form - return the the human-readable form of a character
*
diff --git a/options.c b/options.c
index 99cacf9..c673173 100644
--- a/options.c
+++ b/options.c
@@ -68,6 +68,8 @@ optspec_t flexopts[] = {
, /* Generate batch scanner (opposite of -I). */
{"--bison-bridge", OPT_BISON_BRIDGE, 0}
, /* Scanner to be called by a bison pure parser. */
+ {"--bison-locations", OPT_BISON_BRIDGE_LOCATIONS, 0}
+ , /* Scanner to be called by a bison pure parser. */
{"-i", OPT_CASE_INSENSITIVE, 0}
,
{"--case-insensitive", OPT_CASE_INSENSITIVE, 0}
@@ -127,6 +129,8 @@ optspec_t flexopts[] = {
,
{"--posix-compat", OPT_POSIX_COMPAT, 0}
, /* Maximal compatibility with POSIX lex. */
+ {"--preproc=NUM", OPT_PREPROC_LEVEL, 0}
+ ,
{"-L", OPT_NO_LINE, 0}
, /* Suppress #line directives in scanner. */
{"--noline", OPT_NO_LINE, 0}
@@ -165,8 +169,6 @@ optspec_t flexopts[] = {
, /* Generate a reentrant C scanner. */
{"--noreentrant", OPT_NO_REENTRANT, 0}
,
- {"--reentrant-bison", OPT_BISON_BRIDGE, 0}
- , /* Deprecated. Replaced by --bison-bridge */
{"--reject", OPT_REJECT, 0}
,
{"--noreject", OPT_NO_REJECT, 0}
@@ -209,6 +211,10 @@ optspec_t flexopts[] = {
,
{"--nowarn", OPT_NO_WARN, 0}
, /* Suppress warning messages. */
+ {"--noansi-definitions", OPT_NO_ANSI_FUNC_DEFS, 0}
+ ,
+ {"--noansi-prototypes", OPT_NO_ANSI_FUNC_PROTOS, 0}
+ ,
{"--yyclass=NAME", OPT_YYCLASS, 0}
,
{"--yylineno", OPT_YYLINENO, 0}
diff --git a/options.h b/options.h
index 3cdbfe3..1f3925b 100644
--- a/options.h
+++ b/options.h
@@ -48,6 +48,7 @@ enum flexopt_flag_t {
OPT_BACKUP,
OPT_BATCH,
OPT_BISON_BRIDGE,
+ OPT_BISON_BRIDGE_LOCATIONS,
OPT_CASE_INSENSITIVE,
OPT_COMPRESSION,
OPT_CPLUSPLUS,
@@ -66,6 +67,8 @@ enum flexopt_flag_t {
OPT_META_ECS,
OPT_NEVER_INTERACTIVE,
OPT_NO_ALIGN,
+ OPT_NO_ANSI_FUNC_DEFS,
+ OPT_NO_ANSI_FUNC_PROTOS,
OPT_NO_DEBUG,
OPT_NO_DEFAULT,
OPT_NO_ECS,
@@ -105,6 +108,7 @@ enum flexopt_flag_t {
OPT_POINTER,
OPT_PREFIX,
OPT_PREPROCDEFINE,
+ OPT_PREPROC_LEVEL,
OPT_READ,
OPT_REENTRANT,
OPT_REJECT,
diff --git a/regex.c b/regex.c
new file mode 100644
index 0000000..d124b4b
--- /dev/null
+++ b/regex.c
@@ -0,0 +1,164 @@
+/** regex - regular expression functions related to POSIX regex lib. */
+
+/* This file is part of flex. */
+
+/* Redistribution and use in source and binary forms, with or without */
+/* modification, are permitted provided that the following conditions */
+/* are met: */
+
+/* 1. Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* 2. Redistributions in binary form must reproduce the above copyright */
+/* notice, this list of conditions and the following disclaimer in the */
+/* documentation and/or other materials provided with the distribution. */
+
+/* Neither the name of the University nor the names of its contributors */
+/* may be used to endorse or promote products derived from this software */
+/* without specific prior written permission. */
+
+/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
+/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
+/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
+/* PURPOSE. */
+
+#include "flexdef.h"
+
+
+static const char* REGEXP_LINEDIR = "^#line ([[:digit:]]+) \"(.*)\"";
+static const char* REGEXP_BLANK_LINE = "^[[:space:]]*$";
+
+regex_t regex_linedir; /**< matches line directives */
+regex_t regex_blank_line; /**< matches blank lines */
+
+
+/** Initialize the regular expressions.
+ * @return true upon success.
+ */
+bool flex_init_regex(void)
+{
+ flex_regcomp(&regex_linedir, REGEXP_LINEDIR, REG_EXTENDED);
+ flex_regcomp(&regex_blank_line, REGEXP_BLANK_LINE, REG_EXTENDED);
+
+ return true;
+}
+
+/** Compiles a regular expression or dies trying.
+ * @param preg Same as for regcomp().
+ * @param regex Same as for regcomp().
+ * @param cflags Same as for regcomp().
+ */
+void flex_regcomp(regex_t *preg, const char *regex, int cflags)
+{
+ int err;
+
+ memset (preg, 0, sizeof (regex_t));
+
+ if ((err = regcomp (preg, regex, cflags)) != 0) {
+ const int errbuf_sz = 200;
+ char * errbuf=0;
+
+ errbuf = (char*)flex_alloc(errbuf_sz *sizeof(char));
+ regerror (err, preg, errbuf, errbuf_sz);
+ sprintf (errbuf, "regcomp failed: %s\n", errbuf);
+
+ flexfatal (errbuf);
+ free(errbuf);
+ }
+}
+
+/** Extract a copy of the match, or NULL if no match.
+ * @param m A match as returned by regexec().
+ * @param src The source string that was passed to regexec().
+ * @return The allocated string.
+ */
+char *regmatch_dup (regmatch_t * m, const char *src)
+{
+ char *str;
+ int len;
+
+ if (m == NULL || m->rm_so < 0)
+ return NULL;
+ len = m->rm_eo - m->rm_so;
+ str = (char *) flex_alloc ((len + 1) * sizeof (char));
+ strncpy (str, src + m->rm_so, len);
+ str[len] = 0;
+ return str;
+}
+
+/** Copy the match.
+ * @param m A match as returned by regexec().
+ * @param dest The destination buffer.
+ * @param src The source string that was passed to regexec().
+ * @return dest
+ */
+char *regmatch_cpy (regmatch_t * m, char *dest, const char *src)
+{
+ if (m == NULL || m->rm_so < 0) {
+ if (dest)
+ dest[0] = '\0';
+ return dest;
+ }
+
+ snprintf (dest, regmatch_len(m), "%s", src + m->rm_so);
+ return dest;
+}
+
+/** Get the length in characters of the match.
+ * @param m A match as returned by regexec().
+ * @param src The source string that was passed to regexec().
+ * @return The length of the match.
+ */
+int regmatch_len (regmatch_t * m)
+{
+ if (m == NULL || m->rm_so < 0) {
+ return 0;
+ }
+
+ return m->rm_eo - m->rm_so;
+}
+
+
+
+/** Convert a regmatch_t object to an integer using the strtol() function.
+ * @param m A match as returned by regexec().
+ * @param src The source string that was passed to regexec().
+ * @param endptr Same as the second argument to strtol().
+ * @param base Same as the third argument to strtol().
+ * @return The converted integer or error (Return value is the same as for strtol()).
+ */
+int regmatch_strtol (regmatch_t * m, const char *src, char **endptr,
+ int base)
+{
+ int n = 0;
+
+#define bufsz 20
+ char buf[bufsz];
+ char *s;
+
+ if (m == NULL || m->rm_so < 0)
+ return 0;
+
+ if (regmatch_len (m) < bufsz)
+ s = regmatch_cpy (m, buf, src);
+ else
+ s = regmatch_dup (m, src);
+
+ n = strtol (s, endptr, base);
+
+ if (s != buf)
+ free (s);
+
+ return n;
+}
+
+/** Check for empty or non-existent match.
+ * @param m A match as returned by regexec().
+ * @return false if match length is non-zero.
+ * Note that reg_empty returns true even if match did not occur at all.
+ */
+bool regmatch_empty (regmatch_t * m)
+{
+ return (m == NULL || m->rm_so < 0 || m->rm_so == m->rm_eo);
+}
+
+/* vim:set expandtab cindent tabstop=4 softtabstop=4 shiftwidth=4 textwidth=0: */
diff --git a/scan.l b/scan.l
index 079fafb..bb694a3 100644
--- a/scan.l
+++ b/scan.l
@@ -43,6 +43,14 @@ extern bool tablesverify, tablesext;
action_define( def, 1 ); \
}
+#define ACTION_M4_IFDEF(def, should_define) \
+ do{ \
+ if ( should_define ) \
+ buf_m4_define( &m4defs_buf, def, NULL);\
+ else \
+ buf_m4_undefine( &m4defs_buf, def);\
+ } while(0)
+
#define MARK_END_OF_PROLOG mark_prolog();
#define YY_DECL \
@@ -254,13 +262,18 @@ LEXOPT [aceknopr]
align long_align = option_sense;
always-interactive {
- action_define( "YY_ALWAYS_INTERACTIVE", option_sense );
+ ACTION_M4_IFDEF( "M4""_YY_ALWAYS_INTERACTIVE", option_sense );
interactive = option_sense;
}
array yytext_is_array = option_sense;
+ ansi-definitions ansi_func_defs = option_sense;
+ ansi-prototypes ansi_func_protos = option_sense;
backup backing_up_report = option_sense;
batch interactive = ! option_sense;
- bison-bridge bison_bridge = option_sense;
+ bison-bridge bison_bridge = option_sense;
+ bison-locations { if((bison_bridge_locations = option_sense))
+ bison_bridge = true;
+ }
"c++" C_plus_plus = option_sense;
caseful|case-sensitive caseins = ! option_sense;
caseless|case-insensitive caseins = option_sense;
@@ -280,14 +293,14 @@ LEXOPT [aceknopr]
lex-compat lex_compat = option_sense;
posix-compat posix_compat = option_sense;
main {
- action_define( "YY_MAIN", option_sense );
+ ACTION_M4_IFDEF( "M4""_YY_MAIN", option_sense);
/* Override yywrap */
if( option_sense == true )
do_yywrap = false;
}
meta-ecs usemecs = option_sense;
never-interactive {
- action_define( "YY_NEVER_INTERACTIVE", option_sense );
+ ACTION_M4_IFDEF( "M4""_YY_NEVER_INTERACTIVE", option_sense );
interactive = !option_sense;
}
perf-report performance_report += option_sense ? 1 : -1;
@@ -295,45 +308,45 @@ LEXOPT [aceknopr]
read use_read = option_sense;
reentrant reentrant = option_sense;
reject reject_really_used = option_sense;
- stack action_define( "YY_STACK_USED", option_sense );
+ stack ACTION_M4_IFDEF( "M4""_YY_STACK_USED", option_sense );
stdinit do_stdinit = option_sense;
stdout use_stdout = option_sense;
unistd ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense);
- unput ACTION_IFDEF("YY_NO_UNPUT", ! option_sense);
+ unput ACTION_M4_IFDEF("M4""_YY_NO_UNPUT", ! option_sense);
verbose printstats = option_sense;
warn nowarn = ! option_sense;
- yylineno do_yylineno = option_sense; ACTION_IFDEF("YY_USE_LINENO", option_sense);
+ yylineno do_yylineno = option_sense; ACTION_M4_IFDEF("M4""_YY_USE_LINENO", option_sense);
yymore yymore_really_used = option_sense;
yywrap do_yywrap = option_sense;
- yy_push_state ACTION_IFDEF("YY_NO_PUSH_STATE", ! option_sense);
- yy_pop_state ACTION_IFDEF("YY_NO_POP_STATE", ! option_sense);
- yy_top_state ACTION_IFDEF("YY_NO_TOP_STATE", ! option_sense);
-
- yy_scan_buffer ACTION_IFDEF("YY_NO_SCAN_BUFFER", ! option_sense);
- yy_scan_bytes ACTION_IFDEF("YY_NO_SCAN_BYTES", ! option_sense);
- yy_scan_string ACTION_IFDEF("YY_NO_SCAN_STRING", ! option_sense);
-
- yyalloc ACTION_IFDEF("YY_NO_FLEX_ALLOC", ! option_sense);
- yyrealloc ACTION_IFDEF("YY_NO_FLEX_REALLOC", ! option_sense);
- yyfree ACTION_IFDEF("YY_NO_FLEX_FREE", ! option_sense);
-
- yyget_debug ACTION_IFDEF("YY_NO_GET_DEBUG", ! option_sense);
- yyset_debug ACTION_IFDEF("YY_NO_SET_DEBUG", ! option_sense);
- yyget_extra ACTION_IFDEF("YY_NO_GET_EXTRA", ! option_sense);
- yyset_extra ACTION_IFDEF("YY_NO_SET_EXTRA", ! option_sense);
- yyget_leng ACTION_IFDEF("YY_NO_GET_LENG", ! option_sense);
- yyget_text ACTION_IFDEF("YY_NO_GET_TEXT", ! option_sense);
- yyget_lineno ACTION_IFDEF("YY_NO_GET_LINENO", ! option_sense);
- yyset_lineno ACTION_IFDEF("YY_NO_SET_LINENO", ! option_sense);
- yyget_in ACTION_IFDEF("YY_NO_GET_IN", ! option_sense);
- yyset_in ACTION_IFDEF("YY_NO_SET_IN", ! option_sense);
- yyget_out ACTION_IFDEF("YY_NO_GET_OUT", ! option_sense);
- yyset_out ACTION_IFDEF("YY_NO_SET_OUT", ! option_sense);
- yyget_lval ACTION_IFDEF("YY_NO_GET_LVAL", ! option_sense);
- yyset_lval ACTION_IFDEF("YY_NO_SET_LVAL", ! option_sense);
- yyget_lloc ACTION_IFDEF("YY_NO_GET_LLOC", ! option_sense);
- yyset_lloc ACTION_IFDEF("YY_NO_SET_LLOC", ! option_sense);
+ yy_push_state ACTION_M4_IFDEF("M4""_YY_NO_PUSH_STATE", ! option_sense);
+ yy_pop_state ACTION_M4_IFDEF("M4""_YY_NO_POP_STATE", ! option_sense);
+ yy_top_state ACTION_M4_IFDEF("M4""_YY_NO_TOP_STATE", ! option_sense);
+
+ yy_scan_buffer ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BUFFER", ! option_sense);
+ yy_scan_bytes ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BYTES", ! option_sense);
+ yy_scan_string ACTION_M4_IFDEF("M4""_YY_NO_SCAN_STRING", ! option_sense);
+
+ yyalloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_ALLOC", ! option_sense);
+ yyrealloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_REALLOC", ! option_sense);
+ yyfree ACTION_M4_IFDEF("M4""_YY_NO_FLEX_FREE", ! option_sense);
+
+ yyget_debug ACTION_M4_IFDEF("M4""_YY_NO_GET_DEBUG", ! option_sense);
+ yyset_debug ACTION_M4_IFDEF("M4""_YY_NO_SET_DEBUG", ! option_sense);
+ yyget_extra ACTION_M4_IFDEF("M4""_YY_NO_GET_EXTRA", ! option_sense);
+ yyset_extra ACTION_M4_IFDEF("M4""_YY_NO_SET_EXTRA", ! option_sense);
+ yyget_leng ACTION_M4_IFDEF("M4""_YY_NO_GET_LENG", ! option_sense);
+ yyget_text ACTION_M4_IFDEF("M4""_YY_NO_GET_TEXT", ! option_sense);
+ yyget_lineno ACTION_M4_IFDEF("M4""_YY_NO_GET_LINENO", ! option_sense);
+ yyset_lineno ACTION_M4_IFDEF("M4""_YY_NO_SET_LINENO", ! option_sense);
+ yyget_in ACTION_M4_IFDEF("M4""_YY_NO_GET_IN", ! option_sense);
+ yyset_in ACTION_M4_IFDEF("M4""_YY_NO_SET_IN", ! option_sense);
+ yyget_out ACTION_M4_IFDEF("M4""_YY_NO_GET_OUT", ! option_sense);
+ yyset_out ACTION_M4_IFDEF("M4""_YY_NO_SET_OUT", ! option_sense);
+ yyget_lval ACTION_M4_IFDEF("M4""_YY_NO_GET_LVAL", ! option_sense);
+ yyset_lval ACTION_M4_IFDEF("M4""_YY_NO_SET_LVAL", ! option_sense);
+ yyget_lloc ACTION_M4_IFDEF("M4""_YY_NO_GET_LLOC", ! option_sense);
+ yyset_lloc ACTION_M4_IFDEF("M4""_YY_NO_SET_LLOC", ! option_sense);
outfile return OPT_OUTFILE;
prefix return OPT_PREFIX;
diff --git a/sym.c b/sym.c
index 20cecba..7aecae9 100644
--- a/sym.c
+++ b/sym.c
@@ -243,9 +243,6 @@ void scinstal (str, xcluflg)
int xcluflg;
{
- /* Generate start condition definition, for use in BEGIN et al. */
- action_define (str, lastsc);
-
if (++lastsc >= current_max_scs)
scextend ();
diff --git a/tests/test-bison-nr/scanner.l b/tests/test-bison-nr/scanner.l
index db3b683..2510de6 100644
--- a/tests/test-bison-nr/scanner.l
+++ b/tests/test-bison-nr/scanner.l
@@ -32,7 +32,7 @@ static char* STRDUP(char* s1);
%}
%option 8bit outfile="scanner.c" prefix="test"
-%option bison-bridge yylineno
+%option bison-locations yylineno
%option nomain nounput noyy_top_state noyywrap nodefault warn
%option prefix="test" header="scanner.h" yylineno
diff --git a/tests/test-bison-yylloc/scanner.l b/tests/test-bison-yylloc/scanner.l
index 0ae65ed..aaf6fd7 100644
--- a/tests/test-bison-yylloc/scanner.l
+++ b/tests/test-bison-yylloc/scanner.l
@@ -32,7 +32,7 @@ static char* STRDUP(char* s1);
%}
%option 8bit outfile="scanner.c" prefix="test"
-%option reentrant bison-bridge yylineno
+%option reentrant bison-bridge bison-locations yylineno
%option nomain nounput noyy_top_state noyywrap nodefault warn
%option prefix="test" header="scanner.h"
diff --git a/tests/test-reject/scanner.l b/tests/test-reject/scanner.l
index dc439f1..a90a1fa 100644
--- a/tests/test-reject/scanner.l
+++ b/tests/test-reject/scanner.l
@@ -44,31 +44,37 @@ int main ( int argc, char** argv )
{
FILE* fp = NULL;
void *yyscanner=0;
-#ifdef YY_REENTRANT
+ M4_YY_DECL_GUTS_VAR();
+
+m4_ifdef( [[M4_YY_REENTRANT]],
+[[
yylex_init(&yyscanner);
-#endif
-#ifdef YY_TABLES_EXTERNAL
+]])
+
+m4_ifdef( [[M4_YY_TABLES_EXTERNAL]],
+[[
if((fp = fopen(argv[1],"r"))== NULL)
- yy_fatal_error("could not open tables file for reading" YY_CALL_LAST_ARG);
+ yy_fatal_error("could not open tables file for reading" M4_YY_CALL_LAST_ARG);
- if(yytables_fload(fp YY_CALL_LAST_ARG) < 0)
- yy_fatal_error("yytables_fload returned < 0" YY_CALL_LAST_ARG);
- if(YY_TABLES_VERIFY)
+ if(yytables_fload(fp M4_YY_CALL_LAST_ARG) < 0)
+ yy_fatal_error("yytables_fload returned < 0" M4_YY_CALL_LAST_ARG);
+ if(M4_YY_TABLES_VERIFY)
exit(0);
-#endif
+]])
if(argc > 2){
if((fp = fopen(argv[2],"r"))== NULL)
- yy_fatal_error("could not open input file for reading" YY_CALL_LAST_ARG);
+ yy_fatal_error("could not open input file for reading" M4_YY_CALL_LAST_ARG);
yyin = fp;
}
- while(yylex(YY_CALL_ONLY_ARG) != 0)
+ while(yylex(M4_YY_CALL_ONLY_ARG) != 0)
;
-#ifdef YY_TABLES_EXTERNAL
- yytables_destroy(YY_CALL_ONLY_ARG);
-#endif
- yylex_destroy(YY_CALL_ONLY_ARG);
+m4_ifdef( [[M4_YY_TABLES_EXTERNAL]],
+[[
+ yytables_destroy(M4_YY_CALL_ONLY_ARG);
+]])
+ yylex_destroy(M4_YY_CALL_ONLY_ARG);
if(argc < 0) /* silence the compiler */
yyscanner = (void*)fp;
diff --git a/tests/test-table-opts/scanner.l b/tests/test-table-opts/scanner.l
index 1569192..5b3255f 100644
--- a/tests/test-table-opts/scanner.l
+++ b/tests/test-table-opts/scanner.l
@@ -46,31 +46,37 @@ int main ( int argc, char** argv )
{
FILE* fp = NULL;
void *yyscanner=0;
-#ifdef YY_REENTRANT
+ M4_YY_DECL_GUTS_VAR();
+
+m4_ifdef( [[M4_YY_REENTRANT]],
+[[
yylex_init(&yyscanner);
-#endif
-#ifdef YY_TABLES_EXTERNAL
+]])
+
+m4_ifdef( [[M4_YY_TABLES_EXTERNAL]],
+[[
if((fp = fopen(argv[1],"r"))== NULL)
- yy_fatal_error("could not open tables file for reading" YY_CALL_LAST_ARG);
+ yy_fatal_error("could not open tables file for reading" M4_YY_CALL_LAST_ARG);
- if(yytables_fload(fp YY_CALL_LAST_ARG) < 0)
- yy_fatal_error("yytables_fload returned < 0" YY_CALL_LAST_ARG);
- if(YY_TABLES_VERIFY)
+ if(yytables_fload(fp M4_YY_CALL_LAST_ARG) < 0)
+ yy_fatal_error("yytables_fload returned < 0" M4_YY_CALL_LAST_ARG);
+ if(M4_YY_TABLES_VERIFY)
exit(0);
-#endif
+]])
if(argc > 2){
if((fp = fopen(argv[2],"r"))== NULL)
- yy_fatal_error("could not open input file for reading" YY_CALL_LAST_ARG);
+ yy_fatal_error("could not open input file for reading" M4_YY_CALL_LAST_ARG);
yyin = fp;
}
- while(yylex(YY_CALL_ONLY_ARG) != 0)
+ while(yylex(M4_YY_CALL_ONLY_ARG) != 0)
;
-#ifdef YY_TABLES_EXTERNAL
- yytables_destroy(YY_CALL_ONLY_ARG);
-#endif
- yylex_destroy(YY_CALL_ONLY_ARG);
+m4_ifdef( [[YY_TABLES_EXTERNAL]],
+[[
+ yytables_destroy(M4_YY_CALL_ONLY_ARG);
+]])
+ yylex_destroy(M4_YY_CALL_ONLY_ARG);
if(argc < 0) /* silence the compiler */
yyscanner = (void*)fp;