summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/lex/buf.c231
-rw-r--r--usr.bin/lex/filter.c370
-rw-r--r--usr.bin/lex/gen.c2118
-rw-r--r--usr.bin/lex/libmain.c13
-rw-r--r--usr.bin/lex/libyywrap.c5
-rw-r--r--usr.bin/lex/main.c1893
-rw-r--r--usr.bin/lex/misc.c730
-rw-r--r--usr.bin/lex/nfa.c429
8 files changed, 2900 insertions, 2889 deletions
diff --git a/usr.bin/lex/buf.c b/usr.bin/lex/buf.c
index 9fe8aea9f84..4ccb1d4e830 100644
--- a/usr.bin/lex/buf.c
+++ b/usr.bin/lex/buf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.c,v 1.2 2015/11/19 22:16:43 tedu Exp $ */
+/* $OpenBSD: buf.c,v 1.3 2015/11/19 22:52:40 tedu Exp $ */
/* flex - tool to generate fast lexical analyzers */
@@ -32,55 +32,58 @@
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
-
+
+
#include "flexdef.h"
/* Take note: The buffer object is sometimes used as a String buffer (one
* continuous string), and sometimes used as a list of strings, usually line by
* line.
- *
+ *
* The type is specified in buf_init by the elt_size. If the elt_size is
* sizeof(char), then the buffer should be treated as string buffer. If the
* elt_size is sizeof(char*), then the buffer should be treated as a list of
* strings.
*
- * Certain functions are only appropriate for one type or the other.
+ * Certain functions are only appropriate for one type or the other.
*/
/* global buffers. */
struct Buf userdef_buf; /**< for user #definitions triggered by cmd-line. */
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; /**< m4 definitions. List of strings. */
-struct Buf top_buf; /**< contains %top code. String buffer. */
+struct Buf m4defs_buf; /**< m4 definitions. List of strings. */
+struct Buf top_buf; /**< contains %top code. String buffer. */
-struct Buf *buf_print_strings(struct Buf * buf, FILE* out)
+struct Buf *
+buf_print_strings(struct Buf * buf, FILE * out)
{
- int i;
+ int i;
- if(!buf || !out)
- return buf;
+ 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;
+ 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)
+struct Buf *
+buf_prints(struct Buf * buf, const char *fmt, const char *s)
{
- char *t;
- size_t tsz;
+ char *t;
+ size_t tsz;
- t = flex_alloc (tsz = strlen (fmt) + strlen (s) + 1);
+ t = flex_alloc(tsz = strlen(fmt) + strlen(s) + 1);
if (!t)
- flexfatal (_("Allocation of buffer to print string failed"));
- snprintf (t, tsz, fmt, s);
- buf = buf_strappend (buf, t);
- flex_free (t);
+ flexfatal(_("Allocation of buffer to print string failed"));
+ snprintf(t, tsz, fmt, s);
+ buf = buf_strappend(buf, t);
+ flex_free(t);
return buf;
}
@@ -90,27 +93,29 @@ struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s)
* @param lineno line number
* @return buf
*/
-struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
+struct Buf *
+buf_linedir(struct Buf * buf, const char *filename, int lineno)
{
- const char *src;
- char *dst, *t;
- size_t tsz;
-
- t = flex_alloc (tsz = strlen ("#line \"\"\n") + /* constant parts */
- 2 * strlen (filename) + /* filename with possibly all backslashes escaped */
- (int) (1 + log10 (abs (lineno))) + /* line number */
- 1); /* NUL */
- if (!t)
- flexfatal (_("Allocation of buffer for line directive failed"));
- for (dst = t + snprintf (t, tsz, "#line %d \"", lineno), src = filename; *src; *dst++ = *src++)
- if (*src == '\\') /* escape backslashes */
- *dst++ = '\\';
- *dst++ = '"';
- *dst++ = '\n';
- *dst = '\0';
- buf = buf_strappend (buf, t);
- flex_free (t);
- return buf;
+ const char *src;
+ char *dst, *t;
+ size_t tsz;
+
+ t = flex_alloc(tsz = strlen("#line \"\"\n") + /* constant parts */
+ 2 * strlen(filename) + /* filename with possibly all
+ * backslashes escaped */
+ (int) (1 + log10(abs(lineno))) + /* line number */
+ 1); /* NUL */
+ if (!t)
+ flexfatal(_("Allocation of buffer for line directive failed"));
+ for (dst = t + snprintf(t, tsz, "#line %d \"", lineno), src = filename; *src; *dst++ = *src++)
+ if (*src == '\\') /* escape backslashes */
+ *dst++ = '\\';
+ *dst++ = '"';
+ *dst++ = '\n';
+ *dst = '\0';
+ buf = buf_strappend(buf, t);
+ flex_free(t);
+ return buf;
}
@@ -119,20 +124,22 @@ struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
* @param @a dest the source buffer
* @return @a dest
*/
-struct Buf *buf_concat(struct Buf* dest, const struct Buf* src)
+struct Buf *
+buf_concat(struct Buf * dest, const struct Buf * src)
{
- buf_append(dest, src->elts, src->nelts);
- return dest;
+ buf_append(dest, src->elts, src->nelts);
+ return dest;
}
/* Appends n characters in str to buf. */
-struct Buf *buf_strnappend (buf, str, n)
- struct Buf *buf;
- const char *str;
- int n;
+struct Buf *
+buf_strnappend(buf, str, n)
+ struct Buf *buf;
+ const char *str;
+ int n;
{
- buf_append (buf, str, n + 1);
+ buf_append(buf, str, n + 1);
/* "undo" the '\0' character that buf_append() already copied. */
buf->nelts--;
@@ -141,25 +148,27 @@ struct Buf *buf_strnappend (buf, str, n)
}
/* Appends characters in str to buf. */
-struct Buf *buf_strappend (buf, str)
- struct Buf *buf;
- const char *str;
+struct Buf *
+buf_strappend(buf, str)
+ struct Buf *buf;
+ const char *str;
{
- return buf_strnappend (buf, str, strlen (str));
+ return buf_strnappend(buf, str, strlen(str));
}
/* appends "#define str def\n" */
-struct Buf *buf_strdefine (buf, str, def)
- struct Buf *buf;
- const char *str;
- const char *def;
+struct Buf *
+buf_strdefine(buf, str, def)
+ struct Buf *buf;
+ const char *str;
+ const char *def;
{
- buf_strappend (buf, "#define ");
- buf_strappend (buf, " ");
- buf_strappend (buf, str);
- buf_strappend (buf, " ");
- buf_strappend (buf, def);
- buf_strappend (buf, "\n");
+ buf_strappend(buf, "#define ");
+ buf_strappend(buf, " ");
+ buf_strappend(buf, str);
+ buf_strappend(buf, " ");
+ buf_strappend(buf, def);
+ buf_strappend(buf, "\n");
return buf;
}
@@ -169,20 +178,21 @@ struct Buf *buf_strdefine (buf, str, def)
* @param val The definition; may be NULL.
* @return buf
*/
-struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val)
+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;
- size_t strsz;
-
- val = val?val:"";
- str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(def) + strlen(val) + 2);
- if (!str)
- flexfatal (_("Allocation of buffer for m4 def failed"));
-
- snprintf(str, strsz, fmt, def, val);
- buf_append(buf, &str, 1);
- return buf;
+ const char *fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n";
+ char *str;
+ size_t strsz;
+
+ val = val ? val : "";
+ str = (char *) flex_alloc(strsz = strlen(fmt) + strlen(def) + strlen(val) + 2);
+ if (!str)
+ flexfatal(_("Allocation of buffer for m4 def failed"));
+
+ snprintf(str, strsz, fmt, def, val);
+ buf_append(buf, &str, 1);
+ return buf;
}
/** Pushes "m4_undefine([[def]])m4_dnl" to end of buffer.
@@ -190,25 +200,27 @@ struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val)
* @param def The m4 symbol to undefine.
* @return buf
*/
-struct Buf *buf_m4_undefine (struct Buf *buf, const char* def)
+struct Buf *
+buf_m4_undefine(struct Buf * buf, const char *def)
{
- const char * fmt = "m4_undefine( [[%s]])m4_dnl\n";
- char * str;
- size_t strsz;
+ const char *fmt = "m4_undefine( [[%s]])m4_dnl\n";
+ char *str;
+ size_t strsz;
- str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(def) + 2);
- if (!str)
- flexfatal (_("Allocation of buffer for m4 undef failed"));
+ str = (char *) flex_alloc(strsz = strlen(fmt) + strlen(def) + 2);
+ if (!str)
+ flexfatal(_("Allocation of buffer for m4 undef failed"));
- snprintf(str, strsz, fmt, def);
- buf_append(buf, &str, 1);
- return buf;
+ snprintf(str, strsz, 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;
- size_t elem_size;
+void
+buf_init(buf, elem_size)
+ struct Buf *buf;
+ size_t elem_size;
{
buf->elts = (void *) 0;
buf->nelts = 0;
@@ -217,11 +229,12 @@ void buf_init (buf, elem_size)
}
/* frees memory */
-void buf_destroy (buf)
- struct Buf *buf;
+void
+buf_destroy(buf)
+ struct Buf *buf;
{
if (buf && buf->elts)
- flex_free (buf->elts);
+ flex_free(buf->elts);
buf->elts = (void *) 0;
}
@@ -232,12 +245,13 @@ void buf_destroy (buf)
* We grow by mod(512) boundaries.
*/
-struct Buf *buf_append (buf, ptr, n_elem)
- struct Buf *buf;
- const void *ptr;
- int n_elem;
+struct Buf *
+buf_append(buf, ptr, n_elem)
+ struct Buf *buf;
+ const void *ptr;
+ int n_elem;
{
- int n_alloc = 0;
+ int n_alloc = 0;
if (!ptr || n_elem == 0)
return buf;
@@ -252,23 +266,22 @@ struct Buf *buf_append (buf, ptr, n_elem)
if (((n_alloc * buf->elt_size) % 512) != 0
&& buf->elt_size < 512)
n_alloc +=
- (512 -
- ((n_alloc * buf->elt_size) % 512)) /
- buf->elt_size;
+ (512 -
+ ((n_alloc * buf->elt_size) % 512)) /
+ buf->elt_size;
if (!buf->elts)
buf->elts =
- allocate_array (n_alloc, buf->elt_size);
+ allocate_array(n_alloc, buf->elt_size);
else
buf->elts =
- reallocate_array (buf->elts, n_alloc,
- buf->elt_size);
+ reallocate_array(buf->elts, n_alloc,
+ buf->elt_size);
buf->nmax = n_alloc;
}
-
- memcpy ((char *) buf->elts + buf->nelts * buf->elt_size, ptr,
- n_elem * buf->elt_size);
+ memcpy((char *) buf->elts + buf->nelts * buf->elt_size, ptr,
+ n_elem * buf->elt_size);
buf->nelts += n_elem;
return buf;
diff --git a/usr.bin/lex/filter.c b/usr.bin/lex/filter.c
index 2fcbab855e8..77f62f239a1 100644
--- a/usr.bin/lex/filter.c
+++ b/usr.bin/lex/filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: filter.c,v 1.3 2015/11/19 22:25:53 tedu Exp $ */
+/* $OpenBSD: filter.c,v 1.4 2015/11/19 22:52:40 tedu Exp $ */
/* filter - postprocessing of flex output through filters */
@@ -24,10 +24,10 @@
/* PURPOSE. */
#include "flexdef.h"
-static const char * check_4_gnu_m4 =
- "m4_dnl ifdef(`__gnu__', ,"
- "`errprint(Flex requires GNU M4. Set the PATH or set the M4 environment variable to its path name.)"
- " m4exit(2)')\n";
+static const char *check_4_gnu_m4 =
+"m4_dnl ifdef(`__gnu__', ,"
+"`errprint(Flex requires GNU M4. Set the PATH or set the M4 environment variable to its path name.)"
+" m4exit(2)')\n";
/** global chain. */
@@ -40,19 +40,20 @@ struct filter *output_chain = NULL;
* not including argv[0].
* @return newest filter in chain
*/
-struct filter *filter_create_ext (struct filter *chain, const char *cmd,
- ...)
+struct filter *
+filter_create_ext(struct filter * chain, const char *cmd,
+ ...)
{
struct filter *f;
- int max_args;
+ int max_args;
const char *s;
va_list ap;
/* allocate and initialize new filter */
- f = (struct filter *) flex_alloc (sizeof (struct filter));
+ f = (struct filter *) flex_alloc(sizeof(struct filter));
if (!f)
- flexerror (_("flex_alloc failed (f) in filter_create_ext"));
- memset (f, 0, sizeof (*f));
+ flexerror(_("flex_alloc failed (f) in filter_create_ext"));
+ memset(f, 0, sizeof(*f));
f->filter_func = NULL;
f->extra = NULL;
f->next = NULL;
@@ -64,27 +65,25 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd,
chain = chain->next;
chain->next = f;
}
-
-
/* allocate argv, and populate it with the argument list. */
max_args = 8;
- f->argv = flex_alloc (sizeof (char *) * (max_args + 1));
+ f->argv = flex_alloc(sizeof(char *) * (max_args + 1));
if (!f->argv)
- flexerror (_("flex_alloc failed (f->argv) in filter_create_ext"));
+ flexerror(_("flex_alloc failed (f->argv) in filter_create_ext"));
f->argv[f->argc++] = cmd;
- va_start (ap, cmd);
- while ((s = va_arg (ap, const char *)) != NULL) {
+ va_start(ap, cmd);
+ while ((s = va_arg(ap, const char *)) != NULL) {
if (f->argc >= max_args) {
max_args += 8;
- f->argv = flex_realloc (f->argv,
- sizeof (char *) * (max_args + 1));
+ f->argv = flex_realloc(f->argv,
+ sizeof(char *) * (max_args + 1));
}
f->argv[f->argc++] = s;
}
f->argv[f->argc] = NULL;
- va_end (ap);
+ va_end(ap);
return f;
}
@@ -96,17 +95,18 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd,
* @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 *
+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));
+ f = (struct filter *) flex_alloc(sizeof(struct filter));
if (!f)
- flexerror (_("flex_alloc failed in filter_create_int"));
- memset (f, 0, sizeof (*f));
+ flexerror(_("flex_alloc failed in filter_create_int"));
+ memset(f, 0, sizeof(*f));
f->next = NULL;
f->argc = 0;
f->argv = NULL;
@@ -120,7 +120,6 @@ struct filter *filter_create_int (struct filter *chain,
chain = chain->next;
chain->next = f;
}
-
return f;
}
@@ -128,76 +127,79 @@ struct filter *filter_create_int (struct filter *chain,
* @param chain The head of the chain.
* @return true on success.
*/
-bool filter_apply_chain (struct filter * chain)
+bool
+filter_apply_chain(struct filter * chain)
{
- int pid, pipes[2];
- int r;
+ int pid, pipes[2];
+ int r;
const int readsz = 512;
- char *buf;
+ char *buf;
- /* 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.
+ /*
+ * 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);
+ filter_apply_chain(chain->next);
else
return true;
- /* Now we are the right-most unprocessed link in the chain.
+ /*
+ * Now we are the right-most unprocessed link in the chain.
*/
- fflush (stdout);
- fflush (stderr);
+ fflush(stdout);
+ fflush(stderr);
- if (pipe (pipes) == -1)
- flexerror (_("pipe failed"));
+ if (pipe(pipes) == -1)
+ flexerror(_("pipe failed"));
- if ((pid = fork ()) == -1)
- flexerror (_("fork failed"));
+ if ((pid = fork()) == -1)
+ flexerror(_("fork failed"));
if (pid == 0) {
/* child */
- /* We need stdin (the FILE* stdin) to connect to this new pipe.
- * There is no portable way to set stdin to a new file descriptor,
- * as stdin is not an lvalue on some systems (BSD).
- * So we dup the new pipe onto the stdin descriptor and use a no-op fseek
- * to sync the stream. This is a Hail Mary situation. It seems to work.
- */
- close (pipes[1]);
+ /*
+ * We need stdin (the FILE* stdin) to connect to this new
+ * pipe. There is no portable way to set stdin to a new file
+ * descriptor, as stdin is not an lvalue on some systems
+ * (BSD). So we dup the new pipe onto the stdin descriptor
+ * and use a no-op fseek to sync the stream. This is a Hail
+ * Mary situation. It seems to work.
+ */
+ close(pipes[1]);
clearerr(stdin);
- if (dup2 (pipes[0], fileno (stdin)) == -1)
- flexfatal (_("dup2(pipes[0],0)"));
- close (pipes[0]);
- fseek (stdin, 0, SEEK_CUR);
+ if (dup2(pipes[0], fileno(stdin)) == -1)
+ flexfatal(_("dup2(pipes[0],0)"));
+ close(pipes[0]);
+ fseek(stdin, 0, SEEK_CUR);
/* run as a filter, either internally or by exec */
if (chain->filter_func) {
- int r;
-
- if ((r = chain->filter_func (chain)) == -1)
- flexfatal (_("filter_func failed"));
- exit (0);
- }
- else {
- execvp (chain->argv[0],
- (char **const) (chain->argv));
- lerrsf_fatal ( _("exec of %s failed"),
+ int r;
+
+ if ((r = chain->filter_func(chain)) == -1)
+ flexfatal(_("filter_func failed"));
+ exit(0);
+ } else {
+ execvp(chain->argv[0],
+ (char **const) (chain->argv));
+ lerrsf_fatal(_("exec of %s failed"),
chain->argv[0]);
}
- exit (1);
+ exit(1);
}
-
/* Parent */
- close (pipes[0]);
- if (dup2 (pipes[1], fileno (stdout)) == -1)
- flexfatal (_("dup2(pipes[1],1)"));
- close (pipes[1]);
- fseek (stdout, 0, SEEK_CUR);
+ close(pipes[0]);
+ if (dup2(pipes[1], fileno(stdout)) == -1)
+ flexfatal(_("dup2(pipes[1],1)"));
+ close(pipes[1]);
+ fseek(stdout, 0, SEEK_CUR);
return true;
}
@@ -207,9 +209,10 @@ bool filter_apply_chain (struct filter * 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
+filter_truncate(struct filter * chain, int max_len)
{
- int len = 1;
+ int len = 1;
if (!chain)
return 0;
@@ -228,106 +231,111 @@ int filter_truncate (struct filter *chain, int max_len)
* The header file name is in extra.
* @return 0 (zero) on success, and -1 on failure.
*/
-int filter_tee_header (struct filter *chain)
+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.
+ /*
+ * 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;
+ 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
+ /*
+ * 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 ((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"));
+ if (freopen((char *) chain->extra, "w", stdout) == NULL)
+ flexfatal(_("freopen(headerfilename) failed"));
- filter_apply_chain (chain->next);
+ 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.
+ /*
+ * Now to_c is a pipe to the C branch, and to_h is a pipe to the H
+ * branch.
*/
if (write_header) {
- fputs (check_4_gnu_m4, to_h);
- 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_NOOP]])[[]]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(check_4_gnu_m4, to_h);
+ 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_NOOP]])[[]]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 (check_4_gnu_m4, to_c);
- fputs ("m4_changecom`'m4_dnl\n", to_c);
- fputs ("m4_changequote`'m4_dnl\n", to_c);
- fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_c);
- fputs ("m4_define([[M4_YY_NOOP]])[[]]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);
+ fputs(check_4_gnu_m4, to_c);
+ fputs("m4_changecom`'m4_dnl\n", to_c);
+ fputs("m4_changequote`'m4_dnl\n", to_c);
+ fputs("m4_changequote([[,]])[[]]m4_dnl\n", to_c);
+ fputs("m4_define([[M4_YY_NOOP]])[[]]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);
if (!buf)
- flexerror (_("flex_alloc failed in filter_tee_header"));
- while (fgets (buf, readsz, stdin)) {
- fputs (buf, to_c);
+ flexerror(_("flex_alloc failed in filter_tee_header"));
+ while (fgets(buf, readsz, stdin)) {
+ fputs(buf, to_c);
if (write_header)
- fputs (buf, to_h);
+ 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);
- if (ferror (to_h))
- lerrsf (_("error writing output file %s"),
- (char *) chain->extra);
-
- else if (fclose (to_h))
- lerrsf (_("error closing output file %s"),
- (char *) chain->extra);
+ 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);
+ if (ferror(to_h))
+ lerrsf(_("error writing output file %s"),
+ (char *) chain->extra);
+
+ else if (fclose(to_h))
+ lerrsf(_("error closing output file %s"),
+ (char *) chain->extra);
}
+ fflush(to_c);
+ if (ferror(to_c))
+ lerrsf(_("error writing output file %s"),
+ outfilename ? outfilename : "<stdout>");
- fflush (to_c);
- if (ferror (to_c))
- lerrsf (_("error writing output file %s"),
- outfilename ? outfilename : "<stdout>");
-
- else if (fclose (to_c))
- lerrsf (_("error closing output file %s"),
- outfilename ? outfilename : "<stdout>");
+ else if (fclose(to_c))
+ lerrsf(_("error closing output file %s"),
+ outfilename ? outfilename : "<stdout>");
- while (wait (0) > 0) ;
+ while (wait(0) > 0);
- exit (0);
+ exit(0);
return 0;
}
@@ -337,43 +345,44 @@ int filter_tee_header (struct filter *chain)
* 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)
+int
+filter_fix_linedirs(struct filter * chain)
{
- char *buf;
+ char *buf;
const int readsz = 512;
- int lineno = 1;
- bool in_gen = true; /* in generated code */
- bool last_was_blank = false;
+ int lineno = 1;
+ bool in_gen = true; /* in generated code */
+ bool last_was_blank = false;
if (!chain)
return 0;
- buf = (char *) flex_alloc (readsz);
+ buf = (char *) flex_alloc(readsz);
if (!buf)
- flexerror (_("flex_alloc failed in filter_fix_linedirs"));
+ flexerror(_("flex_alloc failed in filter_fix_linedirs"));
- while (fgets (buf, readsz, stdin)) {
+ while (fgets(buf, readsz, stdin)) {
regmatch_t m[10];
/* Check for #line directive. */
if (buf[0] == '#'
- && regexec (&regex_linedir, buf, 3, m, 0) == 0) {
+ && regexec(&regex_linedir, buf, 3, m, 0) == 0) {
- int num;
- char *fname;
+ int num;
+ char *fname;
/* extract the line number and filename */
- num = regmatch_strtol (&m[1], buf, NULL, 0);
- fname = regmatch_dup (&m[2], buf);
+ 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) {
+ if (strcmp(fname,
+ outfilename ? outfilename : "<stdout>") == 0 ||
+ strcmp(fname, headerfilename ? headerfilename :
+ "<stdout>") == 0) {
- char *s1, *s2;
- char filename[MAXLINE];
+ char *s1, *s2;
+ char filename[MAXLINE];
s1 = fname;
s2 = filename;
@@ -393,43 +402,42 @@ int filter_fix_linedirs (struct filter *chain)
/* Adjust the line directives. */
in_gen = true;
- snprintf (buf, readsz, "#line %d \"%s\"\n",
- lineno + 1, filename);
- }
- else {
- /* it's a #line directive for code we didn't write */
+ snprintf(buf, readsz, "#line %d \"%s\"\n",
+ lineno + 1, filename);
+ } else {
+ /*
+ * it's a #line directive for code we didn't
+ * write
+ */
in_gen = false;
}
- free (fname);
+ free(fname);
last_was_blank = false;
}
-
/* squeeze blank lines from generated code */
else if (in_gen &&
- regexec (&regex_blank_line, buf, 0, NULL, 0) == 0) {
+ regexec(&regex_blank_line, buf, 0, NULL, 0) == 0) {
if (last_was_blank)
continue;
else
last_was_blank = true;
- }
-
- else {
+ } else {
/* it's a line of normal, non-empty code. */
last_was_blank = false;
}
- fputs (buf, stdout);
+ fputs(buf, stdout);
lineno++;
}
- fflush (stdout);
- if (ferror (stdout))
- lerrsf (_("error writing output file %s"),
- outfilename ? outfilename : "<stdout>");
-
- else if (fclose (stdout))
- lerrsf (_("error closing output file %s"),
- outfilename ? outfilename : "<stdout>");
+ fflush(stdout);
+ if (ferror(stdout))
+ lerrsf(_("error writing output file %s"),
+ outfilename ? outfilename : "<stdout>");
+
+ else if (fclose(stdout))
+ lerrsf(_("error closing output file %s"),
+ outfilename ? outfilename : "<stdout>");
return 0;
}
diff --git a/usr.bin/lex/gen.c b/usr.bin/lex/gen.c
index e7af1658439..1cb5d0c5c45 100644
--- a/usr.bin/lex/gen.c
+++ b/usr.bin/lex/gen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gen.c,v 1.12 2015/11/19 19:43:40 tedu Exp $ */
+/* $OpenBSD: gen.c,v 1.13 2015/11/19 22:52:40 tedu Exp $ */
/* gen - actual generation (writing) of flex scanners */
@@ -39,10 +39,10 @@
/* declare functions that have forward references */
-void gen_next_state PROTO ((int));
-void genecs PROTO ((void));
-void indent_put2s PROTO ((const char *, const char *));
-void indent_puts PROTO ((const char *));
+void gen_next_state PROTO((int));
+void genecs PROTO((void));
+void indent_put2s PROTO((const char *, const char *));
+void indent_puts PROTO((const char *));
static int indent_level = 0; /* each level is 8 spaces */
@@ -57,41 +57,45 @@ static int indent_level = 0; /* each level is 8 spaces */
* 0 elements of its arrays, too.)
*/
-static const char *get_int16_decl (void)
+static const char *
+get_int16_decl(void)
{
return (gentables)
- ? "static yyconst flex_int16_t %s[%d] =\n { 0,\n"
- : "static yyconst flex_int16_t * %s = 0;\n";
+ ? "static yyconst flex_int16_t %s[%d] =\n { 0,\n"
+ : "static yyconst flex_int16_t * %s = 0;\n";
}
-static const char *get_int32_decl (void)
+static const char *
+get_int32_decl(void)
{
return (gentables)
- ? "static yyconst flex_int32_t %s[%d] =\n { 0,\n"
- : "static yyconst flex_int32_t * %s = 0;\n";
+ ? "static yyconst flex_int32_t %s[%d] =\n { 0,\n"
+ : "static yyconst flex_int32_t * %s = 0;\n";
}
-static const char *get_state_decl (void)
+static const char *
+get_state_decl(void)
{
return (gentables)
- ? "static yyconst yy_state_type %s[%d] =\n { 0,\n"
- : "static yyconst yy_state_type * %s = 0;\n";
+ ? "static yyconst yy_state_type %s[%d] =\n { 0,\n"
+ : "static yyconst yy_state_type * %s = 0;\n";
}
/* Indent to the current level. */
-void do_indent ()
+void
+do_indent()
{
int i = indent_level * 8;
while (i >= 8) {
- outc ('\t');
+ outc('\t');
i -= 8;
}
while (i > 0) {
- outc (' ');
+ outc(' ');
--i;
}
}
@@ -100,98 +104,103 @@ void do_indent ()
/** Make the table for possible eol matches.
* @return the newly allocated rule_can_match_eol table
*/
-static struct yytbl_data *mkeoltbl (void)
+static struct yytbl_data *
+mkeoltbl(void)
{
- int i;
+ int i;
flex_int8_t *tdata = 0;
struct yytbl_data *tbl;
- tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
- yytbl_data_init (tbl, YYTD_ID_RULE_CAN_MATCH_EOL);
+ tbl = (struct yytbl_data *) calloc(1, sizeof(struct yytbl_data));
+ yytbl_data_init(tbl, YYTD_ID_RULE_CAN_MATCH_EOL);
tbl->td_flags = YYTD_DATA8;
tbl->td_lolen = num_rules + 1;
tbl->td_data = tdata =
- (flex_int8_t *) calloc (tbl->td_lolen, sizeof (flex_int8_t));
+ (flex_int8_t *) calloc(tbl->td_lolen, sizeof(flex_int8_t));
for (i = 1; i <= num_rules; i++)
tdata[i] = rule_has_nl[i] ? 1 : 0;
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(%s)},\n",
- "flex_int32_t");
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(%s)},\n",
+ "flex_int32_t");
return tbl;
}
/* Generate the table for possible eol matches. */
-static void geneoltbl ()
+static void
+geneoltbl()
{
- int i;
+ int i;
- 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);
+ 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);
if (gentables) {
for (i = 1; i <= num_rules; i++) {
- out_dec ("%d, ", rule_has_nl[i] ? 1 : 0);
+ out_dec("%d, ", rule_has_nl[i] ? 1 : 0);
/* format nicely, 20 numbers per line. */
if ((i % 20) == 19)
- out ("\n ");
+ out("\n ");
}
- out (" };\n");
+ out(" };\n");
}
- outn ("]])");
+ outn("]])");
}
/* Generate the code to keep backing-up information. */
-void gen_backing_up ()
+void
+gen_backing_up()
{
if (reject || num_backing_up == 0)
return;
if (fullspd)
- indent_puts ("if ( yy_current_state[-1].yy_nxt )");
+ indent_puts("if ( yy_current_state[-1].yy_nxt )");
else
- indent_puts ("if ( yy_accept[yy_current_state] )");
-
- indent_up ();
- indent_puts ("{");
- indent_puts ("YY_G(yy_last_accepting_state) = yy_current_state;");
- indent_puts ("YY_G(yy_last_accepting_cpos) = yy_cp;");
- indent_puts ("}");
- indent_down ();
+ indent_puts("if ( yy_accept[yy_current_state] )");
+
+ indent_up();
+ indent_puts("{");
+ indent_puts("YY_G(yy_last_accepting_state) = yy_current_state;");
+ indent_puts("YY_G(yy_last_accepting_cpos) = yy_cp;");
+ indent_puts("}");
+ indent_down();
}
/* Generate the code to perform the backing up. */
-void gen_bu_action ()
+void
+gen_bu_action()
{
if (reject || num_backing_up == 0)
return;
- set_indent (3);
+ set_indent(3);
- indent_puts ("case 0: /* must back up */");
- indent_puts ("/* undo the effects of YY_DO_BEFORE_ACTION */");
- indent_puts ("*yy_cp = YY_G(yy_hold_char);");
+ indent_puts("case 0: /* must back up */");
+ indent_puts("/* undo the effects of YY_DO_BEFORE_ACTION */");
+ indent_puts("*yy_cp = YY_G(yy_hold_char);");
if (fullspd || fulltbl)
- indent_puts ("yy_cp = YY_G(yy_last_accepting_cpos) + 1;");
+ indent_puts("yy_cp = YY_G(yy_last_accepting_cpos) + 1;");
else
- /* Backing-up info for compressed tables is taken \after/
+ /*
+ * Backing-up info for compressed tables is taken \after/
* yy_cp has been incremented for the next state.
*/
- indent_puts ("yy_cp = YY_G(yy_last_accepting_cpos);");
+ indent_puts("yy_cp = YY_G(yy_last_accepting_cpos);");
- indent_puts ("yy_current_state = YY_G(yy_last_accepting_state);");
- indent_puts ("goto yy_find_action;");
- outc ('\n');
+ indent_puts("yy_current_state = YY_G(yy_last_accepting_state);");
+ indent_puts("goto yy_find_action;");
+ outc('\n');
- set_indent (0);
+ set_indent(0);
}
/** mkctbl - make full speed compressed transition table
@@ -201,39 +210,42 @@ void gen_bu_action ()
* @return the newly allocated trans table
*/
-static struct yytbl_data *mkctbl (void)
+static struct yytbl_data *
+mkctbl(void)
{
int i;
struct yytbl_data *tbl = 0;
flex_int32_t *tdata = 0, curr = 0;
- int end_of_buffer_action = num_rules + 1;
+ int end_of_buffer_action = num_rules + 1;
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(%s)},\n",
- ((tblend + numecs + 1) >= INT16_MAX
- || long_align) ? "flex_int32_t" : "flex_int16_t");
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(%s)},\n",
+ ((tblend + numecs + 1) >= INT16_MAX
+ || long_align) ? "flex_int32_t" : "flex_int16_t");
- tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
- yytbl_data_init (tbl, YYTD_ID_TRANSITION);
+ tbl = (struct yytbl_data *) calloc(1, sizeof(struct yytbl_data));
+ yytbl_data_init(tbl, YYTD_ID_TRANSITION);
tbl->td_flags = YYTD_DATA32 | YYTD_STRUCT;
tbl->td_hilen = 0;
tbl->td_lolen = tblend + numecs + 1; /* number of structs */
tbl->td_data = tdata =
- (flex_int32_t *) calloc (tbl->td_lolen * 2, sizeof (flex_int32_t));
-
- /* We want the transition to be represented as the offset to the
- * next state, not the actual state number, which is what it currently
- * is. The offset is base[nxt[i]] - (base of current state)]. That's
- * just the difference between the starting points of the two involved
- * states (to - from).
- *
+ (flex_int32_t *) calloc(tbl->td_lolen * 2, sizeof(flex_int32_t));
+
+ /*
+ * We want the transition to be represented as the offset to the next
+ * state, not the actual state number, which is what it currently is.
+ * The offset is base[nxt[i]] - (base of current state)]. That's
+ * just the difference between the starting points of the two
+ * involved states (to - from).
+ *
* First, though, we need to find some way to put in our end-of-buffer
* flags and states. We do this by making a state with absolutely no
* transitions. We put it at the end of the table.
*/
- /* We need to have room in nxt/chk for two more slots: One for the
+ /*
+ * We need to have room in nxt/chk for two more slots: One for the
* action and one for the end-of-buffer transition. We now *assume*
* that we're guaranteed the only character we'll try to index this
* nxt/chk pair with is EOB, i.e., 0, so we don't have to make sure
@@ -241,10 +253,10 @@ static struct yytbl_data *mkctbl (void)
*/
while (tblend + 2 >= current_max_xpairs)
- expand_nxt_chk ();
+ expand_nxt_chk();
while (lastdfa + 1 >= current_max_dfas)
- increase_max_dfas ();
+ increase_max_dfas();
base[lastdfa + 1] = tblend + 2;
nxt[tblend + 1] = end_of_buffer_action;
@@ -254,12 +266,13 @@ static struct yytbl_data *mkctbl (void)
/* So that "make test" won't show arb. differences. */
nxt[tblend + 2] = 0;
- /* Make sure every state has an end-of-buffer transition and an
+ /*
+ * Make sure every state has an end-of-buffer transition and an
* action #.
*/
for (i = 0; i <= lastdfa; ++i) {
- int anum = dfaacc[i].dfaacc_state;
- int offset = base[i];
+ int anum = dfaacc[i].dfaacc_state;
+ int offset = base[i];
chk[offset] = EOB_POSITION;
chk[offset - 1] = ACTION_POSITION;
@@ -270,18 +283,13 @@ static struct yytbl_data *mkctbl (void)
if (chk[i] == EOB_POSITION) {
tdata[curr++] = 0;
tdata[curr++] = base[lastdfa + 1] - i;
- }
-
- else if (chk[i] == ACTION_POSITION) {
+ } else if (chk[i] == ACTION_POSITION) {
tdata[curr++] = 0;
tdata[curr++] = nxt[i];
- }
-
- else if (chk[i] > numecs || chk[i] == 0) {
+ } else if (chk[i] > numecs || chk[i] == 0) {
tdata[curr++] = 0;
tdata[curr++] = 0;
- }
- else { /* verify, transition */
+ } else { /* verify, transition */
tdata[curr++] = chk[i];
tdata[curr++] = base[nxt[i]] - (i - chk[i]);
@@ -303,27 +311,28 @@ static struct yytbl_data *mkctbl (void)
/** Make start_state_list table.
* @return the newly allocated start_state_list table
*/
-static struct yytbl_data *mkssltbl (void)
+static struct yytbl_data *
+mkssltbl(void)
{
struct yytbl_data *tbl = 0;
flex_int32_t *tdata = 0;
flex_int32_t i;
- tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
- yytbl_data_init (tbl, YYTD_ID_START_STATE_LIST);
+ tbl = (struct yytbl_data *) calloc(1, sizeof(struct yytbl_data));
+ yytbl_data_init(tbl, YYTD_ID_START_STATE_LIST);
tbl->td_flags = YYTD_DATA32 | YYTD_PTRANS;
tbl->td_hilen = 0;
tbl->td_lolen = lastsc * 2 + 1;
tbl->td_data = tdata =
- (flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t));
+ (flex_int32_t *) calloc(tbl->td_lolen, sizeof(flex_int32_t));
for (i = 0; i <= lastsc * 2; ++i)
tdata[i] = base[i];
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(%s)},\n",
- "struct yy_trans_info*");
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(%s)},\n",
+ "struct yy_trans_info*");
return tbl;
}
@@ -332,29 +341,32 @@ static struct yytbl_data *mkssltbl (void)
/* genctbl - generates full speed compressed transition table */
-void genctbl ()
+void
+genctbl()
{
int i;
- int end_of_buffer_action = num_rules + 1;
+ int end_of_buffer_action = num_rules + 1;
/* Table of verify for transition and offset to next state. */
if (gentables)
- out_dec ("static yyconst struct yy_trans_info yy_transition[%d] =\n {\n", tblend + numecs + 1);
+ out_dec("static yyconst struct yy_trans_info yy_transition[%d] =\n {\n", tblend + numecs + 1);
else
- outn ("static yyconst struct yy_trans_info *yy_transition = 0;");
-
- /* We want the transition to be represented as the offset to the
- * next state, not the actual state number, which is what it currently
- * is. The offset is base[nxt[i]] - (base of current state)]. That's
- * just the difference between the starting points of the two involved
- * states (to - from).
- *
+ outn("static yyconst struct yy_trans_info *yy_transition = 0;");
+
+ /*
+ * We want the transition to be represented as the offset to the next
+ * state, not the actual state number, which is what it currently is.
+ * The offset is base[nxt[i]] - (base of current state)]. That's
+ * just the difference between the starting points of the two
+ * involved states (to - from).
+ *
* First, though, we need to find some way to put in our end-of-buffer
* flags and states. We do this by making a state with absolutely no
* transitions. We put it at the end of the table.
*/
- /* We need to have room in nxt/chk for two more slots: One for the
+ /*
+ * We need to have room in nxt/chk for two more slots: One for the
* action and one for the end-of-buffer transition. We now *assume*
* that we're guaranteed the only character we'll try to index this
* nxt/chk pair with is EOB, i.e., 0, so we don't have to make sure
@@ -362,10 +374,10 @@ void genctbl ()
*/
while (tblend + 2 >= current_max_xpairs)
- expand_nxt_chk ();
+ expand_nxt_chk();
while (lastdfa + 1 >= current_max_dfas)
- increase_max_dfas ();
+ increase_max_dfas();
base[lastdfa + 1] = tblend + 2;
nxt[tblend + 1] = end_of_buffer_action;
@@ -375,12 +387,13 @@ void genctbl ()
/* So that "make test" won't show arb. differences. */
nxt[tblend + 2] = 0;
- /* Make sure every state has an end-of-buffer transition and an
+ /*
+ * Make sure every state has an end-of-buffer transition and an
* action #.
*/
for (i = 0; i <= lastdfa; ++i) {
- int anum = dfaacc[i].dfaacc_state;
- int offset = base[i];
+ int anum = dfaacc[i].dfaacc_state;
+ int offset = base[i];
chk[offset] = EOB_POSITION;
chk[offset - 1] = ACTION_POSITION;
@@ -389,107 +402,108 @@ void genctbl ()
for (i = 0; i <= tblend; ++i) {
if (chk[i] == EOB_POSITION)
- transition_struct_out (0, base[lastdfa + 1] - i);
+ transition_struct_out(0, base[lastdfa + 1] - i);
else if (chk[i] == ACTION_POSITION)
- transition_struct_out (0, nxt[i]);
+ transition_struct_out(0, nxt[i]);
else if (chk[i] > numecs || chk[i] == 0)
- transition_struct_out (0, 0); /* unused slot */
+ transition_struct_out(0, 0); /* unused slot */
else /* verify, transition */
- transition_struct_out (chk[i],
- base[nxt[i]] - (i -
- chk[i]));
+ transition_struct_out(chk[i],
+ base[nxt[i]] - (i -
+ chk[i]));
}
/* Here's the final, end-of-buffer state. */
- transition_struct_out (chk[tblend + 1], nxt[tblend + 1]);
- transition_struct_out (chk[tblend + 2], nxt[tblend + 2]);
+ transition_struct_out(chk[tblend + 1], nxt[tblend + 1]);
+ transition_struct_out(chk[tblend + 2], nxt[tblend + 2]);
if (gentables)
- outn (" };\n");
+ outn(" };\n");
/* Table of pointers to start states. */
if (gentables)
- out_dec ("static yyconst struct yy_trans_info *yy_start_state_list[%d] =\n", lastsc * 2 + 1);
+ out_dec("static yyconst struct yy_trans_info *yy_start_state_list[%d] =\n", lastsc * 2 + 1);
else
- outn ("static yyconst struct yy_trans_info **yy_start_state_list =0;");
+ outn("static yyconst struct yy_trans_info **yy_start_state_list =0;");
if (gentables) {
- outn (" {");
+ outn(" {");
for (i = 0; i <= lastsc * 2; ++i)
- out_dec (" &yy_transition[%d],\n", base[i]);
+ out_dec(" &yy_transition[%d],\n", base[i]);
- dataend ();
+ dataend();
}
-
if (useecs)
- genecs ();
+ genecs();
}
/* mkecstbl - Make equivalence-class tables. */
-struct yytbl_data *mkecstbl (void)
+struct yytbl_data *
+mkecstbl(void)
{
int i;
struct yytbl_data *tbl = 0;
flex_int32_t *tdata = 0;
- tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
- yytbl_data_init (tbl, YYTD_ID_EC);
+ tbl = (struct yytbl_data *) calloc(1, sizeof(struct yytbl_data));
+ yytbl_data_init(tbl, YYTD_ID_EC);
tbl->td_flags |= YYTD_DATA32;
tbl->td_hilen = 0;
tbl->td_lolen = csize;
tbl->td_data = tdata =
- (flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t));
+ (flex_int32_t *) calloc(tbl->td_lolen, sizeof(flex_int32_t));
for (i = 1; i < csize; ++i) {
- ecgroup[i] = ABS (ecgroup[i]);
+ ecgroup[i] = ABS(ecgroup[i]);
tdata[i] = ecgroup[i];
}
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_EC, (void**)&yy_ec, sizeof(%s)},\n",
- "flex_int32_t");
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_EC, (void**)&yy_ec, sizeof(%s)},\n",
+ "flex_int32_t");
return tbl;
}
/* Generate equivalence-class tables. */
-void genecs ()
+void
+genecs()
{
int i, j;
- int numrows;
+ int numrows;
- out_str_dec (get_int32_decl (), "yy_ec", csize);
+ out_str_dec(get_int32_decl(), "yy_ec", csize);
for (i = 1; i < csize; ++i) {
- ecgroup[i] = ABS (ecgroup[i]);
- mkdata (ecgroup[i]);
+ ecgroup[i] = ABS(ecgroup[i]);
+ mkdata(ecgroup[i]);
}
- dataend ();
+ dataend();
if (trace) {
- fputs (_("\n\nEquivalence Classes:\n\n"), stderr);
+ fputs(_("\n\nEquivalence Classes:\n\n"), stderr);
numrows = csize / 8;
for (j = 0; j < numrows; ++j) {
for (i = j; i < csize; i = i + numrows) {
- fprintf (stderr, "%4s = %-2d",
- readable_form (i), ecgroup[i]);
+ fprintf(stderr, "%4s = %-2d",
+ readable_form(i), ecgroup[i]);
- putc (' ', stderr);
+ putc(' ', stderr);
}
- putc ('\n', stderr);
+ putc('\n', stderr);
}
}
}
@@ -497,138 +511,138 @@ void genecs ()
/* Generate the code to find the action number. */
-void gen_find_action ()
+void
+gen_find_action()
{
if (fullspd)
- indent_puts ("yy_act = yy_current_state[-1].yy_nxt;");
+ indent_puts("yy_act = yy_current_state[-1].yy_nxt;");
else if (fulltbl)
- indent_puts ("yy_act = yy_accept[yy_current_state];");
+ indent_puts("yy_act = yy_accept[yy_current_state];");
else if (reject) {
- indent_puts ("yy_current_state = *--YY_G(yy_state_ptr);");
- indent_puts ("YY_G(yy_lp) = yy_accept[yy_current_state];");
+ indent_puts("yy_current_state = *--YY_G(yy_state_ptr);");
+ indent_puts("YY_G(yy_lp) = yy_accept[yy_current_state];");
- outn ("find_rule: /* we branch to this label when backing up */");
+ outn("find_rule: /* we branch to this label when backing up */");
indent_puts
- ("for ( ; ; ) /* until we find what rule we matched */");
+ ("for ( ; ; ) /* until we find what rule we matched */");
- indent_up ();
+ indent_up();
- indent_puts ("{");
+ indent_puts("{");
indent_puts
- ("if ( YY_G(yy_lp) && YY_G(yy_lp) < yy_accept[yy_current_state + 1] )");
- indent_up ();
- indent_puts ("{");
- indent_puts ("yy_act = yy_acclist[YY_G(yy_lp)];");
+ ("if ( YY_G(yy_lp) && YY_G(yy_lp) < yy_accept[yy_current_state + 1] )");
+ indent_up();
+ indent_puts("{");
+ indent_puts("yy_act = yy_acclist[YY_G(yy_lp)];");
if (variable_trailing_context_rules) {
indent_puts
- ("if ( yy_act & YY_TRAILING_HEAD_MASK ||");
- indent_puts (" YY_G(yy_looking_for_trail_begin) )");
- indent_up ();
- indent_puts ("{");
+ ("if ( yy_act & YY_TRAILING_HEAD_MASK ||");
+ indent_puts(" YY_G(yy_looking_for_trail_begin) )");
+ indent_up();
+ indent_puts("{");
indent_puts
- ("if ( yy_act == YY_G(yy_looking_for_trail_begin) )");
- indent_up ();
- indent_puts ("{");
- indent_puts ("YY_G(yy_looking_for_trail_begin) = 0;");
- indent_puts ("yy_act &= ~YY_TRAILING_HEAD_MASK;");
- indent_puts ("break;");
- indent_puts ("}");
- indent_down ();
-
- indent_puts ("}");
- indent_down ();
+ ("if ( yy_act == YY_G(yy_looking_for_trail_begin) )");
+ indent_up();
+ indent_puts("{");
+ indent_puts("YY_G(yy_looking_for_trail_begin) = 0;");
+ indent_puts("yy_act &= ~YY_TRAILING_HEAD_MASK;");
+ indent_puts("break;");
+ indent_puts("}");
+ indent_down();
+
+ indent_puts("}");
+ indent_down();
indent_puts
- ("else if ( yy_act & YY_TRAILING_MASK )");
- indent_up ();
- indent_puts ("{");
+ ("else if ( yy_act & YY_TRAILING_MASK )");
+ indent_up();
+ indent_puts("{");
indent_puts
- ("YY_G(yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK;");
+ ("YY_G(yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK;");
indent_puts
- ("YY_G(yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK;");
+ ("YY_G(yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK;");
if (real_reject) {
- /* Remember matched text in case we back up
+ /*
+ * Remember matched text in case we back up
* due to REJECT.
*/
indent_puts
- ("YY_G(yy_full_match) = yy_cp;");
+ ("YY_G(yy_full_match) = yy_cp;");
indent_puts
- ("YY_G(yy_full_state) = YY_G(yy_state_ptr);");
- indent_puts ("YY_G(yy_full_lp) = YY_G(yy_lp);");
+ ("YY_G(yy_full_state) = YY_G(yy_state_ptr);");
+ indent_puts("YY_G(yy_full_lp) = YY_G(yy_lp);");
}
+ indent_puts("}");
+ indent_down();
- indent_puts ("}");
- indent_down ();
-
- indent_puts ("else");
- indent_up ();
- indent_puts ("{");
- indent_puts ("YY_G(yy_full_match) = yy_cp;");
+ indent_puts("else");
+ indent_up();
+ indent_puts("{");
+ indent_puts("YY_G(yy_full_match) = yy_cp;");
indent_puts
- ("YY_G(yy_full_state) = YY_G(yy_state_ptr);");
- indent_puts ("YY_G(yy_full_lp) = YY_G(yy_lp);");
- indent_puts ("break;");
- indent_puts ("}");
- indent_down ();
-
- indent_puts ("++YY_G(yy_lp);");
- indent_puts ("goto find_rule;");
- }
-
- else {
- /* Remember matched text in case we back up due to
+ ("YY_G(yy_full_state) = YY_G(yy_state_ptr);");
+ indent_puts("YY_G(yy_full_lp) = YY_G(yy_lp);");
+ indent_puts("break;");
+ indent_puts("}");
+ indent_down();
+
+ indent_puts("++YY_G(yy_lp);");
+ indent_puts("goto find_rule;");
+ } else {
+ /*
+ * Remember matched text in case we back up due to
* trailing context plus REJECT.
*/
- indent_up ();
- indent_puts ("{");
- indent_puts ("YY_G(yy_full_match) = yy_cp;");
- indent_puts ("break;");
- indent_puts ("}");
- indent_down ();
+ indent_up();
+ indent_puts("{");
+ indent_puts("YY_G(yy_full_match) = yy_cp;");
+ indent_puts("break;");
+ indent_puts("}");
+ indent_down();
}
- indent_puts ("}");
- indent_down ();
+ indent_puts("}");
+ indent_down();
- indent_puts ("--yy_cp;");
+ indent_puts("--yy_cp;");
- /* We could consolidate the following two lines with those at
+ /*
+ * We could consolidate the following two lines with those at
* the beginning, but at the cost of complaints that we're
* branching inside a loop.
*/
- indent_puts ("yy_current_state = *--YY_G(yy_state_ptr);");
- indent_puts ("YY_G(yy_lp) = yy_accept[yy_current_state];");
+ indent_puts("yy_current_state = *--YY_G(yy_state_ptr);");
+ indent_puts("YY_G(yy_lp) = yy_accept[yy_current_state];");
- indent_puts ("}");
+ indent_puts("}");
- indent_down ();
- }
-
- else { /* compressed */
- indent_puts ("yy_act = yy_accept[yy_current_state];");
+ indent_down();
+ } else { /* compressed */
+ indent_puts("yy_act = yy_accept[yy_current_state];");
if (interactive && !reject) {
- /* Do the guaranteed-needed backing up to figure out
+ /*
+ * Do the guaranteed-needed backing up to figure out
* the match.
*/
- indent_puts ("if ( yy_act == 0 )");
- indent_up ();
- indent_puts ("{ /* have to back up */");
+ indent_puts("if ( yy_act == 0 )");
+ indent_up();
+ indent_puts("{ /* have to back up */");
indent_puts
- ("yy_cp = YY_G(yy_last_accepting_cpos);");
+ ("yy_cp = YY_G(yy_last_accepting_cpos);");
indent_puts
- ("yy_current_state = YY_G(yy_last_accepting_state);");
+ ("yy_current_state = YY_G(yy_last_accepting_state);");
indent_puts
- ("yy_act = yy_accept[yy_current_state];");
- indent_puts ("}");
- indent_down ();
+ ("yy_act = yy_accept[yy_current_state];");
+ indent_puts("}");
+ indent_down();
}
}
}
@@ -637,21 +651,22 @@ void gen_find_action ()
* you should call mkecstbl() after this.
*/
-struct yytbl_data *mkftbl (void)
+struct yytbl_data *
+mkftbl(void)
{
int i;
- int end_of_buffer_action = num_rules + 1;
+ int end_of_buffer_action = num_rules + 1;
struct yytbl_data *tbl;
flex_int32_t *tdata = 0;
- tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data));
- yytbl_data_init (tbl, YYTD_ID_ACCEPT);
+ tbl = (struct yytbl_data *) calloc(1, sizeof(struct yytbl_data));
+ yytbl_data_init(tbl, YYTD_ID_ACCEPT);
tbl->td_flags |= YYTD_DATA32;
tbl->td_hilen = 0; /* it's a one-dimensional array */
tbl->td_lolen = lastdfa + 1;
tbl->td_data = tdata =
- (flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t));
+ (flex_int32_t *) calloc(tbl->td_lolen, sizeof(flex_int32_t));
dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action;
@@ -661,45 +676,47 @@ struct yytbl_data *mkftbl (void)
tdata[i] = anum;
if (trace && anum)
- fprintf (stderr, _("state # %d accepts: [%d]\n"),
- i, anum);
+ fprintf(stderr, _("state # %d accepts: [%d]\n"),
+ i, anum);
}
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n",
- long_align ? "flex_int32_t" : "flex_int16_t");
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n",
+ long_align ? "flex_int32_t" : "flex_int16_t");
return tbl;
}
/* genftbl - generate full transition table */
-void genftbl ()
+void
+genftbl()
{
int i;
- int end_of_buffer_action = num_rules + 1;
+ int end_of_buffer_action = num_rules + 1;
- out_str_dec (long_align ? get_int32_decl () : get_int16_decl (),
- "yy_accept", lastdfa + 1);
+ out_str_dec(long_align ? get_int32_decl() : get_int16_decl(),
+ "yy_accept", lastdfa + 1);
dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action;
for (i = 1; i <= lastdfa; ++i) {
int anum = dfaacc[i].dfaacc_state;
- mkdata (anum);
+ mkdata(anum);
if (trace && anum)
- fprintf (stderr, _("state # %d accepts: [%d]\n"),
- i, anum);
+ fprintf(stderr, _("state # %d accepts: [%d]\n"),
+ i, anum);
}
- dataend ();
+ dataend();
if (useecs)
- genecs ();
+ genecs();
- /* Don't have to dump the actual full table entries - they were
+ /*
+ * Don't have to dump the actual full table entries - they were
* created on-the-fly.
*/
}
@@ -707,150 +724,147 @@ void genftbl ()
/* Generate the code to find the next compressed-table state. */
-void gen_next_compressed_state (char_map)
- char *char_map;
+void
+gen_next_compressed_state(char_map)
+ char *char_map;
{
- indent_put2s ("YY_CHAR yy_c = %s;", char_map);
+ indent_put2s("YY_CHAR yy_c = %s;", char_map);
- /* Save the backing-up info \before/ computing the next state
- * because we always compute one more state than needed - we
- * always proceed until we reach a jam state
+ /*
+ * Save the backing-up info \before/ computing the next state because
+ * we always compute one more state than needed - we always proceed
+ * until we reach a jam state
*/
- gen_backing_up ();
+ gen_backing_up();
indent_puts
- ("while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )");
- indent_up ();
- indent_puts ("{");
- indent_puts ("yy_current_state = (int) yy_def[yy_current_state];");
+ ("while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )");
+ indent_up();
+ indent_puts("{");
+ indent_puts("yy_current_state = (int) yy_def[yy_current_state];");
if (usemecs) {
- /* We've arrange it so that templates are never chained
- * to one another. This means we can afford to make a
- * very simple test to see if we need to convert to
- * yy_c's meta-equivalence class without worrying
- * about erroneously looking up the meta-equivalence
- * class twice
+ /*
+ * We've arrange it so that templates are never chained to
+ * one another. This means we can afford to make a very
+ * simple test to see if we need to convert to yy_c's
+ * meta-equivalence class without worrying about erroneously
+ * looking up the meta-equivalence class twice
*/
- do_indent ();
+ do_indent();
/* lastdfa + 2 is the beginning of the templates */
- out_dec ("if ( yy_current_state >= %d )\n", lastdfa + 2);
+ out_dec("if ( yy_current_state >= %d )\n", lastdfa + 2);
- indent_up ();
- indent_puts ("yy_c = yy_meta[(unsigned int) yy_c];");
- indent_down ();
+ indent_up();
+ indent_puts("yy_c = yy_meta[(unsigned int) yy_c];");
+ indent_down();
}
-
- indent_puts ("}");
- indent_down ();
+ indent_puts("}");
+ indent_down();
indent_puts
- ("yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];");
+ ("yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];");
}
/* Generate the code to find the next match. */
-void gen_next_match ()
+void
+gen_next_match()
{
- /* NOTE - changes in here should be reflected in gen_next_state() and
+ /*
+ * NOTE - changes in here should be reflected in gen_next_state() and
* gen_NUL_trans().
*/
- char *char_map = useecs ?
- "yy_ec[YY_SC_TO_UI(*yy_cp)] " : "YY_SC_TO_UI(*yy_cp)";
+ char *char_map = useecs ?
+ "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)";
+ char *char_map_2 = useecs ?
+ "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 )",
- char_map);
+ ("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 )",
- char_map);
+ ("while ( (yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %s ]) > 0 )",
+ char_map);
- indent_up ();
+ indent_up();
if (num_backing_up > 0) {
- indent_puts ("{");
- gen_backing_up ();
- outc ('\n');
+ indent_puts("{");
+ gen_backing_up();
+ outc('\n');
}
-
- indent_puts ("++yy_cp;");
+ indent_puts("++yy_cp;");
if (num_backing_up > 0)
+ indent_puts("}");
- indent_puts ("}");
-
- indent_down ();
-
- outc ('\n');
- indent_puts ("yy_current_state = -yy_current_state;");
- }
+ indent_down();
- else if (fullspd) {
- indent_puts ("{");
+ outc('\n');
+ indent_puts("yy_current_state = -yy_current_state;");
+ } else if (fullspd) {
+ indent_puts("{");
indent_puts
- ("yyconst struct yy_trans_info *yy_trans_info;\n");
- indent_puts ("YY_CHAR yy_c;\n");
- indent_put2s ("for ( yy_c = %s;", char_map);
+ ("yyconst struct yy_trans_info *yy_trans_info;\n");
+ indent_puts("YY_CHAR yy_c;\n");
+ indent_put2s("for ( yy_c = %s;", char_map);
indent_puts
- (" (yy_trans_info = &yy_current_state[(unsigned int) yy_c])->");
- indent_puts ("yy_verify == yy_c;");
- indent_put2s (" yy_c = %s )", char_map_2);
+ (" (yy_trans_info = &yy_current_state[(unsigned int) yy_c])->");
+ indent_puts("yy_verify == yy_c;");
+ indent_put2s(" yy_c = %s )", char_map_2);
- indent_up ();
+ indent_up();
if (num_backing_up > 0)
- indent_puts ("{");
+ indent_puts("{");
- indent_puts ("yy_current_state += yy_trans_info->yy_nxt;");
+ indent_puts("yy_current_state += yy_trans_info->yy_nxt;");
if (num_backing_up > 0) {
- outc ('\n');
- gen_backing_up ();
- indent_puts ("}");
+ outc('\n');
+ gen_backing_up();
+ indent_puts("}");
}
+ indent_down();
+ indent_puts("}");
+ } else { /* compressed */
+ indent_puts("do");
- indent_down ();
- indent_puts ("}");
- }
-
- else { /* compressed */
- indent_puts ("do");
-
- indent_up ();
- indent_puts ("{");
+ indent_up();
+ indent_puts("{");
- gen_next_state (false);
+ gen_next_state(false);
- indent_puts ("++yy_cp;");
+ indent_puts("++yy_cp;");
- indent_puts ("}");
- indent_down ();
+ indent_puts("}");
+ indent_down();
- do_indent ();
+ do_indent();
if (interactive)
- out_dec ("while ( yy_base[yy_current_state] != %d );\n", jambase);
+ out_dec("while ( yy_base[yy_current_state] != %d );\n", jambase);
else
- out_dec ("while ( yy_current_state != %d );\n",
- jamstate);
+ out_dec("while ( yy_current_state != %d );\n",
+ jamstate);
if (!reject && !interactive) {
- /* Do the guaranteed-needed backing up to figure out
+ /*
+ * Do the guaranteed-needed backing up to figure out
* the match.
*/
indent_puts
- ("yy_cp = YY_G(yy_last_accepting_cpos);");
+ ("yy_cp = YY_G(yy_last_accepting_cpos);");
indent_puts
- ("yy_current_state = YY_G(yy_last_accepting_state);");
+ ("yy_current_state = YY_G(yy_last_accepting_state);");
}
}
}
@@ -858,188 +872,182 @@ void gen_next_match ()
/* Generate the code to find the next state. */
-void gen_next_state (worry_about_NULs)
- int worry_about_NULs;
-{ /* NOTE - changes in here should be reflected in gen_next_match() */
- char char_map[256];
+void
+gen_next_state(worry_about_NULs)
+ int worry_about_NULs;
+{ /* NOTE - changes in here should be reflected
+ * in gen_next_match() */
+ char char_map[256];
if (worry_about_NULs && !nultrans) {
if (useecs)
- snprintf (char_map, sizeof(char_map),
- "(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : %d)",
- NUL_ec);
+ snprintf(char_map, sizeof(char_map),
+ "(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : %d)",
+ NUL_ec);
else
- snprintf (char_map, sizeof(char_map),
- "(*yy_cp ? YY_SC_TO_UI(*yy_cp) : %d)",
- NUL_ec);
- }
-
- else
- strlcpy (char_map, useecs ?
- "yy_ec[YY_SC_TO_UI(*yy_cp)] " : "YY_SC_TO_UI(*yy_cp)",
- sizeof char_map );
+ snprintf(char_map, sizeof(char_map),
+ "(*yy_cp ? YY_SC_TO_UI(*yy_cp) : %d)",
+ NUL_ec);
+ } else
+ strlcpy(char_map, useecs ?
+ "yy_ec[YY_SC_TO_UI(*yy_cp)] " : "YY_SC_TO_UI(*yy_cp)",
+ sizeof char_map);
if (worry_about_NULs && nultrans) {
if (!fulltbl && !fullspd)
/* Compressed tables back up *before* they match. */
- gen_backing_up ();
+ gen_backing_up();
- indent_puts ("if ( *yy_cp )");
- indent_up ();
- indent_puts ("{");
+ indent_puts("if ( *yy_cp )");
+ indent_up();
+ indent_puts("{");
}
-
if (fulltbl) {
if (gentables)
indent_put2s
- ("yy_current_state = yy_nxt[yy_current_state][%s];",
- char_map);
+ ("yy_current_state = yy_nxt[yy_current_state][%s];",
+ char_map);
else
indent_put2s
- ("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %s];",
- char_map);
- }
-
- else if (fullspd)
+ ("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %s];",
+ char_map);
+ } else if (fullspd)
indent_put2s
- ("yy_current_state += yy_current_state[%s].yy_nxt;",
- char_map);
+ ("yy_current_state += yy_current_state[%s].yy_nxt;",
+ char_map);
else
- gen_next_compressed_state (char_map);
+ gen_next_compressed_state(char_map);
if (worry_about_NULs && nultrans) {
- indent_puts ("}");
- indent_down ();
- indent_puts ("else");
- indent_up ();
+ indent_puts("}");
+ indent_down();
+ indent_puts("else");
+ indent_up();
indent_puts
- ("yy_current_state = yy_NUL_trans[yy_current_state];");
- indent_down ();
+ ("yy_current_state = yy_NUL_trans[yy_current_state];");
+ indent_down();
}
-
if (fullspd || fulltbl)
- gen_backing_up ();
+ gen_backing_up();
if (reject)
- indent_puts ("*YY_G(yy_state_ptr)++ = yy_current_state;");
+ indent_puts("*YY_G(yy_state_ptr)++ = yy_current_state;");
}
/* Generate the code to make a NUL transition. */
-void gen_NUL_trans ()
-{ /* NOTE - changes in here should be reflected in gen_next_match() */
- /* Only generate a definition for "yy_cp" if we'll generate code
- * that uses it. Otherwise lint and the like complain.
+void
+gen_NUL_trans()
+{ /* NOTE - changes in here should be reflected
+ * in gen_next_match() */
+ /*
+ * Only generate a definition for "yy_cp" if we'll generate code that
+ * uses it. Otherwise lint and the like complain.
*/
- int need_backing_up = (num_backing_up > 0 && !reject);
+ int need_backing_up = (num_backing_up > 0 && !reject);
if (need_backing_up && (!nultrans || fullspd || fulltbl))
- /* We're going to need yy_cp lying around for the call
- * below to gen_backing_up().
+ /*
+ * We're going to need yy_cp lying around for the call below
+ * to gen_backing_up().
*/
- indent_puts ("char *yy_cp = YY_G(yy_c_buf_p);");
+ indent_puts("char *yy_cp = YY_G(yy_c_buf_p);");
- outc ('\n');
+ outc('\n');
if (nultrans) {
indent_puts
- ("yy_current_state = yy_NUL_trans[yy_current_state];");
- indent_puts ("yy_is_jam = (yy_current_state == 0);");
- }
-
- else if (fulltbl) {
- do_indent ();
+ ("yy_current_state = yy_NUL_trans[yy_current_state];");
+ indent_puts("yy_is_jam = (yy_current_state == 0);");
+ } else if (fulltbl) {
+ do_indent();
if (gentables)
- out_dec ("yy_current_state = yy_nxt[yy_current_state][%d];\n", NUL_ec);
+ out_dec("yy_current_state = yy_nxt[yy_current_state][%d];\n", NUL_ec);
else
- out_dec ("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %d];\n", NUL_ec);
- indent_puts ("yy_is_jam = (yy_current_state <= 0);");
- }
-
- else if (fullspd) {
- do_indent ();
- out_dec ("int yy_c = %d;\n", NUL_ec);
+ out_dec("yy_current_state = yy_nxt[yy_current_state*YY_NXT_LOLEN + %d];\n", NUL_ec);
+ indent_puts("yy_is_jam = (yy_current_state <= 0);");
+ } else if (fullspd) {
+ do_indent();
+ out_dec("int yy_c = %d;\n", NUL_ec);
indent_puts
- ("yyconst struct yy_trans_info *yy_trans_info;\n");
+ ("yyconst struct yy_trans_info *yy_trans_info;\n");
indent_puts
- ("yy_trans_info = &yy_current_state[(unsigned int) yy_c];");
- indent_puts ("yy_current_state += yy_trans_info->yy_nxt;");
+ ("yy_trans_info = &yy_current_state[(unsigned int) yy_c];");
+ indent_puts("yy_current_state += yy_trans_info->yy_nxt;");
indent_puts
- ("yy_is_jam = (yy_trans_info->yy_verify != yy_c);");
- }
+ ("yy_is_jam = (yy_trans_info->yy_verify != yy_c);");
+ } else {
+ char NUL_ec_str[20];
- else {
- char NUL_ec_str[20];
+ snprintf(NUL_ec_str, sizeof(NUL_ec_str), "%d", NUL_ec);
+ gen_next_compressed_state(NUL_ec_str);
- snprintf (NUL_ec_str, sizeof(NUL_ec_str), "%d", NUL_ec);
- gen_next_compressed_state (NUL_ec_str);
-
- do_indent ();
- out_dec ("yy_is_jam = (yy_current_state == %d);\n",
- jamstate);
+ do_indent();
+ out_dec("yy_is_jam = (yy_current_state == %d);\n",
+ jamstate);
if (reject) {
- /* Only stack this state if it's a transition we
- * actually make. If we stack it on a jam, then
- * the state stack and yy_c_buf_p get out of sync.
+ /*
+ * Only stack this state if it's a transition we
+ * actually make. If we stack it on a jam, then the
+ * state stack and yy_c_buf_p get out of sync.
*/
- indent_puts ("if ( ! yy_is_jam )");
- indent_up ();
+ indent_puts("if ( ! yy_is_jam )");
+ indent_up();
indent_puts
- ("*YY_G(yy_state_ptr)++ = yy_current_state;");
- indent_down ();
+ ("*YY_G(yy_state_ptr)++ = yy_current_state;");
+ indent_down();
}
}
- /* If we've entered an accepting state, back up; note that
- * compressed tables have *already* done such backing up, so
- * we needn't bother with it again.
+ /*
+ * If we've entered an accepting state, back up; note that compressed
+ * tables have *already* done such backing up, so we needn't bother
+ * with it again.
*/
if (need_backing_up && (fullspd || fulltbl)) {
- outc ('\n');
- indent_puts ("if ( ! yy_is_jam )");
- indent_up ();
- indent_puts ("{");
- gen_backing_up ();
- indent_puts ("}");
- indent_down ();
+ outc('\n');
+ indent_puts("if ( ! yy_is_jam )");
+ indent_up();
+ indent_puts("{");
+ gen_backing_up();
+ indent_puts("}");
+ indent_down();
}
}
/* Generate the code to find the start state. */
-void gen_start_state ()
+void
+gen_start_state()
{
if (fullspd) {
if (bol_needed) {
indent_puts
- ("yy_current_state = yy_start_state_list[YY_G(yy_start) + YY_AT_BOL()];");
- }
- else
+ ("yy_current_state = yy_start_state_list[YY_G(yy_start) + YY_AT_BOL()];");
+ } else
indent_puts
- ("yy_current_state = yy_start_state_list[YY_G(yy_start)];");
- }
-
- else {
- indent_puts ("yy_current_state = YY_G(yy_start);");
+ ("yy_current_state = yy_start_state_list[YY_G(yy_start)];");
+ } else {
+ indent_puts("yy_current_state = YY_G(yy_start);");
if (bol_needed)
- indent_puts ("yy_current_state += YY_AT_BOL();");
+ indent_puts("yy_current_state += YY_AT_BOL();");
if (reject) {
/* Set up for storing up states. */
- outn ("m4_ifdef( [[M4_YY_USES_REJECT]],\n[[");
+ outn("m4_ifdef( [[M4_YY_USES_REJECT]],\n[[");
indent_puts
- ("YY_G(yy_state_ptr) = YY_G(yy_state_buf);");
+ ("YY_G(yy_state_ptr) = YY_G(yy_state_buf);");
indent_puts
- ("*YY_G(yy_state_ptr)++ = yy_current_state;");
- outn ("]])");
+ ("*YY_G(yy_state_ptr)++ = yy_current_state;");
+ outn("]])");
}
}
}
@@ -1047,56 +1055,59 @@ void gen_start_state ()
/* gentabs - generate data statements for the transition tables */
-void gentabs ()
+void
+gentabs()
{
- int i, j, k, *accset, nacc, *acc_array, total_states;
- int end_of_buffer_action = num_rules + 1;
- struct yytbl_data *yyacc_tbl = 0, *yymeta_tbl = 0, *yybase_tbl = 0,
- *yydef_tbl = 0, *yynxt_tbl = 0, *yychk_tbl = 0, *yyacclist_tbl=0;
- flex_int32_t *yyacc_data = 0, *yybase_data = 0, *yydef_data = 0,
- *yynxt_data = 0, *yychk_data = 0, *yyacclist_data=0;
- flex_int32_t yybase_curr = 0, yyacclist_curr=0,yyacc_curr=0;
-
- acc_array = allocate_integer_array (current_max_dfas);
+ int i, j, k, *accset, nacc, *acc_array, total_states;
+ int end_of_buffer_action = num_rules + 1;
+ struct yytbl_data *yyacc_tbl = 0, *yymeta_tbl = 0, *yybase_tbl = 0, *yydef_tbl = 0,
+ *yynxt_tbl = 0, *yychk_tbl = 0, *yyacclist_tbl = 0;
+ flex_int32_t *yyacc_data = 0, *yybase_data = 0, *yydef_data = 0, *yynxt_data = 0,
+ *yychk_data = 0, *yyacclist_data = 0;
+ flex_int32_t yybase_curr = 0, yyacclist_curr = 0, yyacc_curr = 0;
+
+ acc_array = allocate_integer_array(current_max_dfas);
nummt = 0;
- /* The compressed table format jams by entering the "jam state",
- * losing information about the previous state in the process.
- * In order to recover the previous state, we effectively need
- * to keep backing-up information.
+ /*
+ * The compressed table format jams by entering the "jam state",
+ * losing information about the previous state in the process. In
+ * order to recover the previous state, we effectively need to keep
+ * backing-up information.
*/
++num_backing_up;
if (reject) {
- /* Write out accepting list and pointer list.
-
- * First we generate the "yy_acclist" array. In the process,
- * we compute the indices that will go into the "yy_accept"
+ /*
+ * Write out accepting list and pointer list.
+ *
+ * First we generate the "yy_acclist" array. In the process, we
+ * compute the indices that will go into the "yy_accept"
* array, and save the indices in the dfaacc array.
*/
- int EOB_accepting_list[2];
+ int EOB_accepting_list[2];
/* Set up accepting structures for the End Of Buffer state. */
EOB_accepting_list[0] = 0;
EOB_accepting_list[1] = end_of_buffer_action;
accsiz[end_of_buffer_state] = 1;
dfaacc[end_of_buffer_state].dfaacc_set =
- EOB_accepting_list;
-
- out_str_dec (long_align ? get_int32_decl () :
- get_int16_decl (), "yy_acclist", MAX (numas,
- 1) + 1);
-
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n",
- long_align ? "flex_int32_t" : "flex_int16_t");
-
- yyacclist_tbl = (struct yytbl_data*)calloc(1,sizeof(struct yytbl_data));
- yytbl_data_init (yyacclist_tbl, YYTD_ID_ACCLIST);
- yyacclist_tbl->td_lolen = MAX(numas,1) + 1;
- yyacclist_tbl->td_data = yyacclist_data =
- (flex_int32_t *) calloc (yyacclist_tbl->td_lolen, sizeof (flex_int32_t));
- yyacclist_curr = 1;
+ EOB_accepting_list;
+
+ out_str_dec(long_align ? get_int32_decl() :
+ get_int16_decl(), "yy_acclist", MAX(numas,
+ 1) + 1);
+
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n",
+ long_align ? "flex_int32_t" : "flex_int16_t");
+
+ yyacclist_tbl = (struct yytbl_data *) calloc(1, sizeof(struct yytbl_data));
+ yytbl_data_init(yyacclist_tbl, YYTD_ID_ACCLIST);
+ yyacclist_tbl->td_lolen = MAX(numas, 1) + 1;
+ yyacclist_tbl->td_data = yyacclist_data =
+ (flex_int32_t *) calloc(yyacclist_tbl->td_lolen, sizeof(flex_int32_t));
+ yyacclist_curr = 1;
j = 1; /* index into "yy_acclist" array */
@@ -1108,42 +1119,42 @@ void gentabs ()
nacc = accsiz[i];
if (trace)
- fprintf (stderr,
- _("state # %d accepts: "),
- i);
+ fprintf(stderr,
+ _("state # %d accepts: "),
+ i);
for (k = 1; k <= nacc; ++k) {
- int accnum = accset[k];
+ int accnum = accset[k];
++j;
if (variable_trailing_context_rules
&& !(accnum &
- YY_TRAILING_HEAD_MASK)
+ YY_TRAILING_HEAD_MASK)
&& accnum > 0
&& accnum <= num_rules
&& rule_type[accnum] ==
RULE_VARIABLE) {
- /* Special hack to flag
+ /*
+ * Special hack to flag
* accepting number as part
* of trailing context rule.
*/
accnum |= YY_TRAILING_MASK;
}
-
- mkdata (accnum);
- yyacclist_data[yyacclist_curr++] = accnum;
+ mkdata(accnum);
+ yyacclist_data[yyacclist_curr++] = accnum;
if (trace) {
- fprintf (stderr, "[%d]",
- accset[k]);
+ fprintf(stderr, "[%d]",
+ accset[k]);
if (k < nacc)
- fputs (", ",
- stderr);
+ fputs(", ",
+ stderr);
else
- putc ('\n',
- stderr);
+ putc('\n',
+ stderr);
}
}
}
@@ -1152,19 +1163,17 @@ void gentabs ()
/* add accepting number for the "jam" state */
acc_array[i] = j;
- dataend ();
- if (tablesext) {
- yytbl_data_compress (yyacclist_tbl);
- if (yytbl_data_fwrite (&tableswr, yyacclist_tbl) < 0)
- flexerror (_("Could not write yyacclist_tbl"));
- yytbl_data_destroy (yyacclist_tbl);
- yyacclist_tbl = NULL;
- }
- }
-
- else {
+ dataend();
+ if (tablesext) {
+ yytbl_data_compress(yyacclist_tbl);
+ if (yytbl_data_fwrite(&tableswr, yyacclist_tbl) < 0)
+ flexerror(_("Could not write yyacclist_tbl"));
+ yytbl_data_destroy(yyacclist_tbl);
+ yyacclist_tbl = NULL;
+ }
+ } else {
dfaacc[end_of_buffer_state].dfaacc_state =
- end_of_buffer_action;
+ end_of_buffer_action;
for (i = 1; i <= lastdfa; ++i)
acc_array[i] = dfaacc[i].dfaacc_state;
@@ -1175,149 +1184,150 @@ void gentabs ()
/* Begin generating yy_accept */
- /* Spit out "yy_accept" array. If we're doing "reject", it'll be
+ /*
+ * Spit out "yy_accept" array. If we're doing "reject", it'll be
* pointers into the "yy_acclist" array. Otherwise it's actual
* accepting numbers. In either case, we just dump the numbers.
*/
- /* "lastdfa + 2" is the size of "yy_accept"; includes room for C arrays
- * beginning at 0 and for "jam" state.
+ /*
+ * "lastdfa + 2" is the size of "yy_accept"; includes room for C
+ * arrays beginning at 0 and for "jam" state.
*/
k = lastdfa + 2;
if (reject)
- /* We put a "cap" on the table associating lists of accepting
- * numbers with state numbers. This is needed because we tell
- * where the end of an accepting list is by looking at where
- * the list for the next state starts.
+ /*
+ * We put a "cap" on the table associating lists of accepting
+ * numbers with state numbers. This is needed because we
+ * tell where the end of an accepting list is by looking at
+ * where the list for the next state starts.
*/
++k;
- out_str_dec (long_align ? get_int32_decl () : get_int16_decl (),
- "yy_accept", k);
+ out_str_dec(long_align ? get_int32_decl() : get_int16_decl(),
+ "yy_accept", k);
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n",
- long_align ? "flex_int32_t" : "flex_int16_t");
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n",
+ long_align ? "flex_int32_t" : "flex_int16_t");
yyacc_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct yytbl_data));
- yytbl_data_init (yyacc_tbl, YYTD_ID_ACCEPT);
+ (struct yytbl_data *) calloc(1,
+ sizeof(struct yytbl_data));
+ yytbl_data_init(yyacc_tbl, YYTD_ID_ACCEPT);
yyacc_tbl->td_lolen = k;
yyacc_tbl->td_data = yyacc_data =
- (flex_int32_t *) calloc (yyacc_tbl->td_lolen, sizeof (flex_int32_t));
- yyacc_curr=1;
+ (flex_int32_t *) calloc(yyacc_tbl->td_lolen, sizeof(flex_int32_t));
+ yyacc_curr = 1;
for (i = 1; i <= lastdfa; ++i) {
- mkdata (acc_array[i]);
+ mkdata(acc_array[i]);
yyacc_data[yyacc_curr++] = acc_array[i];
if (!reject && trace && acc_array[i])
- fprintf (stderr, _("state # %d accepts: [%d]\n"),
- i, acc_array[i]);
+ fprintf(stderr, _("state # %d accepts: [%d]\n"),
+ i, acc_array[i]);
}
/* Add entry for "jam" state. */
- mkdata (acc_array[i]);
+ mkdata(acc_array[i]);
yyacc_data[yyacc_curr++] = acc_array[i];
if (reject) {
/* Add "cap" for the list. */
- mkdata (acc_array[i]);
+ mkdata(acc_array[i]);
yyacc_data[yyacc_curr++] = acc_array[i];
}
-
- dataend ();
+ dataend();
if (tablesext) {
- yytbl_data_compress (yyacc_tbl);
- if (yytbl_data_fwrite (&tableswr, yyacc_tbl) < 0)
- flexerror (_("Could not write yyacc_tbl"));
- yytbl_data_destroy (yyacc_tbl);
+ yytbl_data_compress(yyacc_tbl);
+ if (yytbl_data_fwrite(&tableswr, yyacc_tbl) < 0)
+ flexerror(_("Could not write yyacc_tbl"));
+ yytbl_data_destroy(yyacc_tbl);
yyacc_tbl = NULL;
}
/* End generating yy_accept */
if (useecs) {
- genecs ();
+ genecs();
if (tablesext) {
struct yytbl_data *tbl;
- tbl = mkecstbl ();
- yytbl_data_compress (tbl);
- if (yytbl_data_fwrite (&tableswr, tbl) < 0)
- flexerror (_("Could not write ecstbl"));
- yytbl_data_destroy (tbl);
+ tbl = mkecstbl();
+ yytbl_data_compress(tbl);
+ if (yytbl_data_fwrite(&tableswr, tbl) < 0)
+ flexerror(_("Could not write ecstbl"));
+ yytbl_data_destroy(tbl);
tbl = 0;
}
}
-
if (usemecs) {
/* Begin generating yy_meta */
- /* Write out meta-equivalence classes (used to index
+ /*
+ * Write out meta-equivalence classes (used to index
* templates with).
*/
flex_int32_t *yymecs_data = 0;
yymeta_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct
- yytbl_data));
- yytbl_data_init (yymeta_tbl, YYTD_ID_META);
+ (struct yytbl_data *) calloc(1,
+ sizeof(struct
+ yytbl_data));
+ yytbl_data_init(yymeta_tbl, YYTD_ID_META);
yymeta_tbl->td_lolen = numecs + 1;
yymeta_tbl->td_data = yymecs_data =
- (flex_int32_t *) calloc (yymeta_tbl->td_lolen,
- sizeof (flex_int32_t));
+ (flex_int32_t *) calloc(yymeta_tbl->td_lolen,
+ sizeof(flex_int32_t));
if (trace)
- fputs (_("\n\nMeta-Equivalence Classes:\n"),
- stderr);
+ fputs(_("\n\nMeta-Equivalence Classes:\n"),
+ stderr);
- out_str_dec (get_int32_decl (), "yy_meta", numecs + 1);
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_META, (void**)&yy_meta, sizeof(%s)},\n",
- "flex_int32_t");
+ out_str_dec(get_int32_decl(), "yy_meta", numecs + 1);
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_META, (void**)&yy_meta, sizeof(%s)},\n",
+ "flex_int32_t");
for (i = 1; i <= numecs; ++i) {
if (trace)
- fprintf (stderr, "%d = %d\n",
- i, ABS (tecbck[i]));
+ fprintf(stderr, "%d = %d\n",
+ i, ABS(tecbck[i]));
- mkdata (ABS (tecbck[i]));
- yymecs_data[i] = ABS (tecbck[i]);
+ mkdata(ABS(tecbck[i]));
+ yymecs_data[i] = ABS(tecbck[i]);
}
- dataend ();
+ dataend();
if (tablesext) {
- yytbl_data_compress (yymeta_tbl);
- if (yytbl_data_fwrite (&tableswr, yymeta_tbl) < 0)
- flexerror (_
- ("Could not write yymeta_tbl"));
- yytbl_data_destroy (yymeta_tbl);
+ yytbl_data_compress(yymeta_tbl);
+ if (yytbl_data_fwrite(&tableswr, yymeta_tbl) < 0)
+ flexerror(_
+ ("Could not write yymeta_tbl"));
+ yytbl_data_destroy(yymeta_tbl);
yymeta_tbl = NULL;
}
/* End generating yy_meta */
}
-
total_states = lastdfa + numtemps;
/* Begin generating yy_base */
- out_str_dec ((tblend >= INT16_MAX || long_align) ?
- get_int32_decl () : get_int16_decl (),
- "yy_base", total_states + 1);
-
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n",
- (tblend >= INT16_MAX
- || long_align) ? "flex_int32_t" : "flex_int16_t");
+ out_str_dec((tblend >= INT16_MAX || long_align) ?
+ get_int32_decl() : get_int16_decl(),
+ "yy_base", total_states + 1);
+
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n",
+ (tblend >= INT16_MAX
+ || long_align) ? "flex_int32_t" : "flex_int16_t");
yybase_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct yytbl_data));
- yytbl_data_init (yybase_tbl, YYTD_ID_BASE);
+ (struct yytbl_data *) calloc(1,
+ sizeof(struct yytbl_data));
+ yytbl_data_init(yybase_tbl, YYTD_ID_BASE);
yybase_tbl->td_lolen = total_states + 1;
yybase_tbl->td_data = yybase_data =
- (flex_int32_t *) calloc (yybase_tbl->td_lolen,
- sizeof (flex_int32_t));
+ (flex_int32_t *) calloc(yybase_tbl->td_lolen,
+ sizeof(flex_int32_t));
yybase_curr = 1;
for (i = 1; i <= lastdfa; ++i) {
@@ -1334,142 +1344,142 @@ void gentabs ()
++tmpuses;
def[i] = lastdfa - d + 1;
}
-
- mkdata (base[i]);
+ mkdata(base[i]);
yybase_data[yybase_curr++] = base[i];
}
/* Generate jam state's base index. */
- mkdata (base[i]);
+ mkdata(base[i]);
yybase_data[yybase_curr++] = base[i];
for (++i /* skip jam state */ ; i <= total_states; ++i) {
- mkdata (base[i]);
+ mkdata(base[i]);
yybase_data[yybase_curr++] = base[i];
def[i] = jamstate;
}
- dataend ();
+ dataend();
if (tablesext) {
- yytbl_data_compress (yybase_tbl);
- if (yytbl_data_fwrite (&tableswr, yybase_tbl) < 0)
- flexerror (_("Could not write yybase_tbl"));
- yytbl_data_destroy (yybase_tbl);
+ yytbl_data_compress(yybase_tbl);
+ if (yytbl_data_fwrite(&tableswr, yybase_tbl) < 0)
+ flexerror(_("Could not write yybase_tbl"));
+ yytbl_data_destroy(yybase_tbl);
yybase_tbl = NULL;
}
/* End generating yy_base */
/* Begin generating yy_def */
- out_str_dec ((total_states >= INT16_MAX || long_align) ?
- get_int32_decl () : get_int16_decl (),
- "yy_def", total_states + 1);
+ out_str_dec((total_states >= INT16_MAX || long_align) ?
+ get_int32_decl() : get_int16_decl(),
+ "yy_def", total_states + 1);
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(%s)},\n",
- (total_states >= INT16_MAX
- || long_align) ? "flex_int32_t" : "flex_int16_t");
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(%s)},\n",
+ (total_states >= INT16_MAX
+ || long_align) ? "flex_int32_t" : "flex_int16_t");
yydef_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct yytbl_data));
- yytbl_data_init (yydef_tbl, YYTD_ID_DEF);
+ (struct yytbl_data *) calloc(1,
+ sizeof(struct yytbl_data));
+ yytbl_data_init(yydef_tbl, YYTD_ID_DEF);
yydef_tbl->td_lolen = total_states + 1;
yydef_tbl->td_data = yydef_data =
- (flex_int32_t *) calloc (yydef_tbl->td_lolen, sizeof (flex_int32_t));
+ (flex_int32_t *) calloc(yydef_tbl->td_lolen, sizeof(flex_int32_t));
for (i = 1; i <= total_states; ++i) {
- mkdata (def[i]);
+ mkdata(def[i]);
yydef_data[i] = def[i];
}
- dataend ();
+ dataend();
if (tablesext) {
- yytbl_data_compress (yydef_tbl);
- if (yytbl_data_fwrite (&tableswr, yydef_tbl) < 0)
- flexerror (_("Could not write yydef_tbl"));
- yytbl_data_destroy (yydef_tbl);
+ yytbl_data_compress(yydef_tbl);
+ if (yytbl_data_fwrite(&tableswr, yydef_tbl) < 0)
+ flexerror(_("Could not write yydef_tbl"));
+ yytbl_data_destroy(yydef_tbl);
yydef_tbl = NULL;
}
/* End generating yy_def */
/* Begin generating yy_nxt */
- out_str_dec ((total_states >= INT16_MAX || long_align) ?
- get_int32_decl () : get_int16_decl (), "yy_nxt",
- tblend + 1);
+ out_str_dec((total_states >= INT16_MAX || long_align) ?
+ get_int32_decl() : get_int16_decl(), "yy_nxt",
+ tblend + 1);
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n",
- (total_states >= INT16_MAX
- || long_align) ? "flex_int32_t" : "flex_int16_t");
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n",
+ (total_states >= INT16_MAX
+ || long_align) ? "flex_int32_t" : "flex_int16_t");
yynxt_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct yytbl_data));
- yytbl_data_init (yynxt_tbl, YYTD_ID_NXT);
+ (struct yytbl_data *) calloc(1,
+ sizeof(struct yytbl_data));
+ yytbl_data_init(yynxt_tbl, YYTD_ID_NXT);
yynxt_tbl->td_lolen = tblend + 1;
yynxt_tbl->td_data = yynxt_data =
- (flex_int32_t *) calloc (yynxt_tbl->td_lolen, sizeof (flex_int32_t));
+ (flex_int32_t *) calloc(yynxt_tbl->td_lolen, sizeof(flex_int32_t));
for (i = 1; i <= tblend; ++i) {
- /* Note, the order of the following test is important.
- * If chk[i] is 0, then nxt[i] is undefined.
+ /*
+ * Note, the order of the following test is important. If
+ * chk[i] is 0, then nxt[i] is undefined.
*/
if (chk[i] == 0 || nxt[i] == 0)
nxt[i] = jamstate; /* new state is the JAM state */
- mkdata (nxt[i]);
+ mkdata(nxt[i]);
yynxt_data[i] = nxt[i];
}
- dataend ();
+ dataend();
if (tablesext) {
- yytbl_data_compress (yynxt_tbl);
- if (yytbl_data_fwrite (&tableswr, yynxt_tbl) < 0)
- flexerror (_("Could not write yynxt_tbl"));
- yytbl_data_destroy (yynxt_tbl);
+ yytbl_data_compress(yynxt_tbl);
+ if (yytbl_data_fwrite(&tableswr, yynxt_tbl) < 0)
+ flexerror(_("Could not write yynxt_tbl"));
+ yytbl_data_destroy(yynxt_tbl);
yynxt_tbl = NULL;
}
/* End generating yy_nxt */
/* Begin generating yy_chk */
- out_str_dec ((total_states >= INT16_MAX || long_align) ?
- get_int32_decl () : get_int16_decl (), "yy_chk",
- tblend + 1);
+ out_str_dec((total_states >= INT16_MAX || long_align) ?
+ get_int32_decl() : get_int16_decl(), "yy_chk",
+ tblend + 1);
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(%s)},\n",
- (total_states >= INT16_MAX
- || long_align) ? "flex_int32_t" : "flex_int16_t");
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(%s)},\n",
+ (total_states >= INT16_MAX
+ || long_align) ? "flex_int32_t" : "flex_int16_t");
yychk_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct yytbl_data));
- yytbl_data_init (yychk_tbl, YYTD_ID_CHK);
+ (struct yytbl_data *) calloc(1,
+ sizeof(struct yytbl_data));
+ yytbl_data_init(yychk_tbl, YYTD_ID_CHK);
yychk_tbl->td_lolen = tblend + 1;
yychk_tbl->td_data = yychk_data =
- (flex_int32_t *) calloc (yychk_tbl->td_lolen, sizeof (flex_int32_t));
+ (flex_int32_t *) calloc(yychk_tbl->td_lolen, sizeof(flex_int32_t));
for (i = 1; i <= tblend; ++i) {
if (chk[i] == 0)
++nummt;
- mkdata (chk[i]);
+ mkdata(chk[i]);
yychk_data[i] = chk[i];
}
- dataend ();
+ dataend();
if (tablesext) {
- yytbl_data_compress (yychk_tbl);
- if (yytbl_data_fwrite (&tableswr, yychk_tbl) < 0)
- flexerror (_("Could not write yychk_tbl"));
- yytbl_data_destroy (yychk_tbl);
+ yytbl_data_compress(yychk_tbl);
+ if (yytbl_data_fwrite(&tableswr, yychk_tbl) < 0)
+ flexerror(_("Could not write yychk_tbl"));
+ yytbl_data_destroy(yychk_tbl);
yychk_tbl = NULL;
}
/* End generating yy_chk */
- flex_free ((void *) acc_array);
+ flex_free((void *) acc_array);
}
@@ -1477,12 +1487,13 @@ void gentabs ()
* current indentation level, adding a final newline.
*/
-void indent_put2s (fmt, arg)
- const char *fmt, *arg;
+void
+indent_put2s(fmt, arg)
+ const char *fmt, *arg;
{
- do_indent ();
- out_str (fmt, arg);
- outn ("");
+ do_indent();
+ out_str(fmt, arg);
+ outn("");
}
@@ -1490,682 +1501,653 @@ void indent_put2s (fmt, arg)
* newline.
*/
-void indent_puts (str)
- const char *str;
+void
+indent_puts(str)
+ const char *str;
{
- do_indent ();
- outn (str);
+ do_indent();
+ outn(str);
}
/* make_tables - generate transition tables and finishes generating output file
*/
-void make_tables ()
+void
+make_tables()
{
int i;
- int did_eof_rule = false;
+ int did_eof_rule = false;
struct yytbl_data *yynultrans_tbl;
- skelout (); /* %% [2.0] - break point in skel */
+ skelout(); /* %% [2.0] - break point in skel */
- /* First, take care of YY_DO_BEFORE_ACTION depending on yymore
- * being used.
+ /*
+ * First, take care of YY_DO_BEFORE_ACTION depending on yymore being
+ * used.
*/
- set_indent (1);
+ set_indent(1);
if (yymore_used && !yytext_is_array) {
- indent_puts ("YY_G(yytext_ptr) -= YY_G(yy_more_len); \\");
+ indent_puts("YY_G(yytext_ptr) -= YY_G(yy_more_len); \\");
indent_puts
- ("yyleng = (size_t) (yy_cp - YY_G(yytext_ptr)); \\");
- }
-
- else
- indent_puts ("yyleng = (size_t) (yy_cp - yy_bp); \\");
+ ("yyleng = (size_t) (yy_cp - YY_G(yytext_ptr)); \\");
+ } else
+ indent_puts("yyleng = (size_t) (yy_cp - yy_bp); \\");
/* Now also deal with copying yytext_ptr to yytext if needed. */
- skelout (); /* %% [3.0] - break point in skel */
+ skelout(); /* %% [3.0] - break point in skel */
if (yytext_is_array) {
if (yymore_used)
indent_puts
- ("if ( yyleng + YY_G(yy_more_offset) >= YYLMAX ) \\");
+ ("if ( yyleng + YY_G(yy_more_offset) >= YYLMAX ) \\");
else
- indent_puts ("if ( yyleng >= YYLMAX ) \\");
+ indent_puts("if ( yyleng >= YYLMAX ) \\");
- indent_up ();
+ indent_up();
indent_puts
- ("YY_FATAL_ERROR( \"token too large, exceeds YYLMAX\" ); \\");
- indent_down ();
+ ("YY_FATAL_ERROR( \"token too large, exceeds YYLMAX\" ); \\");
+ indent_down();
if (yymore_used) {
indent_puts
- ("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); \\");
+ ("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); \\");
- indent_puts ("YY_G(yy_more_offset) = 0; \\");
- }
- else {
+ ("YY_G(yy_prev_more_offset) = YY_G(yy_more_offset); \\");
+ indent_puts("YY_G(yy_more_offset) = 0; \\");
+ } else {
indent_puts
- ("yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG); \\");
+ ("yy_flex_strncpy( yytext, YY_G(yytext_ptr), yyleng + 1 M4_YY_CALL_LAST_ARG); \\");
}
}
+ set_indent(0);
- set_indent (0);
-
- skelout (); /* %% [4.0] - break point in skel */
+ skelout(); /* %% [4.0] - break point in skel */
/* This is where we REALLY begin generating the tables. */
- out_dec ("#define YY_NUM_RULES %d\n", num_rules);
- out_dec ("#define YY_END_OF_BUFFER %d\n", num_rules + 1);
+ out_dec("#define YY_NUM_RULES %d\n", num_rules);
+ out_dec("#define YY_END_OF_BUFFER %d\n", num_rules + 1);
if (fullspd) {
- /* Need to define the transet type as a size large
- * enough to hold the biggest offset.
+ /*
+ * Need to define the transet type as a size large enough to
+ * hold the biggest offset.
*/
- int total_table_size = tblend + numecs + 1;
- char *trans_offset_type =
- (total_table_size >= INT16_MAX || long_align) ?
- "flex_int32_t" : "flex_int16_t";
-
- set_indent (0);
- indent_puts ("struct yy_trans_info");
- indent_up ();
- indent_puts ("{");
-
- /* We require that yy_verify and yy_nxt must be of the same size int. */
- indent_put2s ("%s yy_verify;", trans_offset_type);
+ int total_table_size = tblend + numecs + 1;
+ char *trans_offset_type =
+ (total_table_size >= INT16_MAX || long_align) ?
+ "flex_int32_t" : "flex_int16_t";
+
+ set_indent(0);
+ indent_puts("struct yy_trans_info");
+ indent_up();
+ indent_puts("{");
+
+ /*
+ * We require that yy_verify and yy_nxt must be of the same
+ * size int.
+ */
+ indent_put2s("%s yy_verify;", trans_offset_type);
- /* In cases where its sister yy_verify *is* a "yes, there is
+ /*
+ * In cases where its sister yy_verify *is* a "yes, there is
* a transition", yy_nxt is the offset (in records) to the
* next state. In most cases where there is no transition,
* the value of yy_nxt is irrelevant. If yy_nxt is the -1th
- * record of a state, though, then yy_nxt is the action number
- * for that state.
+ * record of a state, though, then yy_nxt is the action
+ * number for that state.
*/
- indent_put2s ("%s yy_nxt;", trans_offset_type);
- indent_puts ("};");
- indent_down ();
- }
- else {
- /* We generate a bogus 'struct yy_trans_info' data type
- * so we can guarantee that it is always declared in the skel.
- * This is so we can compile "sizeof(struct yy_trans_info)"
- * in any scanner.
+ indent_put2s("%s yy_nxt;", trans_offset_type);
+ indent_puts("};");
+ indent_down();
+ } else {
+ /*
+ * We generate a bogus 'struct yy_trans_info' data type so we
+ * can guarantee that it is always declared in the skel. This
+ * is so we can compile "sizeof(struct yy_trans_info)" in any
+ * scanner.
*/
indent_puts
- ("/* This struct is not used in this scanner,");
- indent_puts (" but its presence is necessary. */");
- indent_puts ("struct yy_trans_info");
- indent_up ();
- indent_puts ("{");
- indent_puts ("flex_int32_t yy_verify;");
- indent_puts ("flex_int32_t yy_nxt;");
- indent_puts ("};");
- indent_down ();
+ ("/* This struct is not used in this scanner,");
+ indent_puts(" but its presence is necessary. */");
+ indent_puts("struct yy_trans_info");
+ indent_up();
+ indent_puts("{");
+ indent_puts("flex_int32_t yy_verify;");
+ indent_puts("flex_int32_t yy_nxt;");
+ indent_puts("};");
+ indent_down();
}
if (fullspd) {
- genctbl ();
+ genctbl();
if (tablesext) {
struct yytbl_data *tbl;
- tbl = mkctbl ();
- yytbl_data_compress (tbl);
- if (yytbl_data_fwrite (&tableswr, tbl) < 0)
- flexerror (_("Could not write ftbl"));
- yytbl_data_destroy (tbl);
-
- tbl = mkssltbl ();
- yytbl_data_compress (tbl);
- if (yytbl_data_fwrite (&tableswr, tbl) < 0)
- flexerror (_("Could not write ssltbl"));
- yytbl_data_destroy (tbl);
+ tbl = mkctbl();
+ yytbl_data_compress(tbl);
+ if (yytbl_data_fwrite(&tableswr, tbl) < 0)
+ flexerror(_("Could not write ftbl"));
+ yytbl_data_destroy(tbl);
+
+ tbl = mkssltbl();
+ yytbl_data_compress(tbl);
+ if (yytbl_data_fwrite(&tableswr, tbl) < 0)
+ flexerror(_("Could not write ssltbl"));
+ yytbl_data_destroy(tbl);
tbl = 0;
if (useecs) {
- tbl = mkecstbl ();
- yytbl_data_compress (tbl);
- if (yytbl_data_fwrite (&tableswr, tbl) < 0)
- flexerror (_
- ("Could not write ecstbl"));
- yytbl_data_destroy (tbl);
+ tbl = mkecstbl();
+ yytbl_data_compress(tbl);
+ if (yytbl_data_fwrite(&tableswr, tbl) < 0)
+ flexerror(_
+ ("Could not write ecstbl"));
+ yytbl_data_destroy(tbl);
tbl = 0;
}
}
- }
- else if (fulltbl) {
- genftbl ();
+ } else if (fulltbl) {
+ genftbl();
if (tablesext) {
struct yytbl_data *tbl;
- tbl = mkftbl ();
- yytbl_data_compress (tbl);
- if (yytbl_data_fwrite (&tableswr, tbl) < 0)
- flexerror (_("Could not write ftbl"));
- yytbl_data_destroy (tbl);
+ tbl = mkftbl();
+ yytbl_data_compress(tbl);
+ if (yytbl_data_fwrite(&tableswr, tbl) < 0)
+ flexerror(_("Could not write ftbl"));
+ yytbl_data_destroy(tbl);
tbl = 0;
if (useecs) {
- tbl = mkecstbl ();
- yytbl_data_compress (tbl);
- if (yytbl_data_fwrite (&tableswr, tbl) < 0)
- flexerror (_
- ("Could not write ecstbl"));
- yytbl_data_destroy (tbl);
+ tbl = mkecstbl();
+ yytbl_data_compress(tbl);
+ if (yytbl_data_fwrite(&tableswr, tbl) < 0)
+ flexerror(_
+ ("Could not write ecstbl"));
+ yytbl_data_destroy(tbl);
tbl = 0;
}
}
- }
- else
- gentabs ();
+ } else
+ gentabs();
if (do_yylineno) {
- geneoltbl ();
+ geneoltbl();
if (tablesext) {
struct yytbl_data *tbl;
- tbl = mkeoltbl ();
- yytbl_data_compress (tbl);
- if (yytbl_data_fwrite (&tableswr, tbl) < 0)
- flexerror (_("Could not write eoltbl"));
- yytbl_data_destroy (tbl);
+ tbl = mkeoltbl();
+ yytbl_data_compress(tbl);
+ if (yytbl_data_fwrite(&tableswr, tbl) < 0)
+ flexerror(_("Could not write eoltbl"));
+ yytbl_data_destroy(tbl);
tbl = 0;
}
}
-
- /* Definitions for backing up. We don't need them if REJECT
- * is being used because then we use an alternative backin-up
- * technique instead.
+ /*
+ * Definitions for backing up. We don't need them if REJECT is being
+ * used because then we use an alternative backin-up technique
+ * instead.
*/
if (num_backing_up > 0 && !reject) {
if (!C_plus_plus && !reentrant) {
indent_puts
- ("static yy_state_type yy_last_accepting_state;");
+ ("static yy_state_type yy_last_accepting_state;");
indent_puts
- ("static char *yy_last_accepting_cpos;\n");
+ ("static char *yy_last_accepting_cpos;\n");
}
}
-
if (nultrans) {
flex_int32_t *yynultrans_data = 0;
/* Begin generating yy_NUL_trans */
- out_str_dec (get_state_decl (), "yy_NUL_trans",
- lastdfa + 1);
- buf_prints (&yydmap_buf,
- "\t{YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(%s)},\n",
- (fullspd) ? "struct yy_trans_info*" :
- "flex_int32_t");
+ out_str_dec(get_state_decl(), "yy_NUL_trans",
+ lastdfa + 1);
+ buf_prints(&yydmap_buf,
+ "\t{YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(%s)},\n",
+ (fullspd) ? "struct yy_trans_info*" :
+ "flex_int32_t");
yynultrans_tbl =
- (struct yytbl_data *) calloc (1,
- sizeof (struct
- yytbl_data));
- yytbl_data_init (yynultrans_tbl, YYTD_ID_NUL_TRANS);
+ (struct yytbl_data *) calloc(1,
+ sizeof(struct
+ yytbl_data));
+ yytbl_data_init(yynultrans_tbl, YYTD_ID_NUL_TRANS);
if (fullspd)
yynultrans_tbl->td_flags |= YYTD_PTRANS;
yynultrans_tbl->td_lolen = lastdfa + 1;
yynultrans_tbl->td_data = yynultrans_data =
- (flex_int32_t *) calloc (yynultrans_tbl->td_lolen,
- sizeof (flex_int32_t));
+ (flex_int32_t *) calloc(yynultrans_tbl->td_lolen,
+ sizeof(flex_int32_t));
for (i = 1; i <= lastdfa; ++i) {
if (fullspd) {
- out_dec (" &yy_transition[%d],\n",
- base[i]);
+ out_dec(" &yy_transition[%d],\n",
+ base[i]);
yynultrans_data[i] = base[i];
- }
- else {
- mkdata (nultrans[i]);
+ } else {
+ mkdata(nultrans[i]);
yynultrans_data[i] = nultrans[i];
}
}
- dataend ();
+ dataend();
if (tablesext) {
- yytbl_data_compress (yynultrans_tbl);
- if (yytbl_data_fwrite (&tableswr, yynultrans_tbl) <
+ yytbl_data_compress(yynultrans_tbl);
+ if (yytbl_data_fwrite(&tableswr, yynultrans_tbl) <
0)
- flexerror (_
- ("Could not write yynultrans_tbl"));
- yytbl_data_destroy (yynultrans_tbl);
+ flexerror(_
+ ("Could not write yynultrans_tbl"));
+ yytbl_data_destroy(yynultrans_tbl);
yynultrans_tbl = NULL;
}
/* End generating yy_NUL_trans */
}
-
if (!C_plus_plus && !reentrant) {
- indent_puts ("extern int yy_flex_debug;");
- indent_put2s ("int yy_flex_debug = %s;\n",
- ddebug ? "1" : "0");
- }
-
- if (ddebug) { /* Spit out table mapping rules to line numbers. */
- out_str_dec (long_align ? get_int32_decl () :
- get_int16_decl (), "yy_rule_linenum",
- num_rules);
+ indent_puts("extern int yy_flex_debug;");
+ indent_put2s("int yy_flex_debug = %s;\n",
+ ddebug ? "1" : "0");
+ }
+ if (ddebug) { /* Spit out table mapping rules to line
+ * numbers. */
+ out_str_dec(long_align ? get_int32_decl() :
+ get_int16_decl(), "yy_rule_linenum",
+ num_rules);
for (i = 1; i < num_rules; ++i)
- mkdata (rule_linenum[i]);
- dataend ();
+ mkdata(rule_linenum[i]);
+ dataend();
}
-
if (reject) {
- outn ("m4_ifdef( [[M4_YY_USES_REJECT]],\n[[");
+ 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;");
- outn ("static char *yy_full_match;");
- outn ("static int yy_lp;");
+ outn("static yy_state_type *yy_state_buf=0, *yy_state_ptr=0;");
+ outn("static char *yy_full_match;");
+ outn("static int yy_lp;");
}
-
if (variable_trailing_context_rules) {
if (!C_plus_plus && !reentrant) {
- outn ("static int yy_looking_for_trail_begin = 0;");
- outn ("static int yy_full_lp;");
- outn ("static int *yy_full_state;");
+ outn("static int yy_looking_for_trail_begin = 0;");
+ outn("static int yy_full_lp;");
+ outn("static int *yy_full_state;");
}
-
- out_hex ("#define YY_TRAILING_MASK 0x%x\n",
- (unsigned int) YY_TRAILING_MASK);
- out_hex ("#define YY_TRAILING_HEAD_MASK 0x%x\n",
- (unsigned int) YY_TRAILING_HEAD_MASK);
+ out_hex("#define YY_TRAILING_MASK 0x%x\n",
+ (unsigned int) YY_TRAILING_MASK);
+ out_hex("#define YY_TRAILING_HEAD_MASK 0x%x\n",
+ (unsigned int) YY_TRAILING_HEAD_MASK);
}
-
- outn ("#define REJECT \\");
- outn ("{ \\");
- outn ("*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */ \\");
- outn ("yy_cp = YY_G(yy_full_match); /* restore poss. backed-over text */ \\");
+ outn("#define REJECT \\");
+ outn("{ \\");
+ outn("*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */ \\");
+ outn("yy_cp = YY_G(yy_full_match); /* restore poss. backed-over text */ \\");
if (variable_trailing_context_rules) {
- outn ("YY_G(yy_lp) = YY_G(yy_full_lp); /* restore orig. accepting pos. */ \\");
- outn ("YY_G(yy_state_ptr) = YY_G(yy_full_state); /* restore orig. state */ \\");
- outn ("yy_current_state = *YY_G(yy_state_ptr); /* restore curr. state */ \\");
+ outn("YY_G(yy_lp) = YY_G(yy_full_lp); /* restore orig. accepting pos. */ \\");
+ outn("YY_G(yy_state_ptr) = YY_G(yy_full_state); /* restore orig. state */ \\");
+ outn("yy_current_state = *YY_G(yy_state_ptr); /* restore curr. state */ \\");
}
+ outn("++YY_G(yy_lp); \\");
+ outn("goto find_rule; \\");
- outn ("++YY_G(yy_lp); \\");
- outn ("goto find_rule; \\");
-
- outn ("}");
- outn ("]])\n");
- }
-
- else {
- outn ("/* The intent behind this definition is that it'll catch");
- outn (" * any uses of REJECT which flex missed.");
- outn (" */");
- outn ("#define REJECT reject_used_but_not_detected");
+ outn("}");
+ outn("]])\n");
+ } else {
+ outn("/* The intent behind this definition is that it'll catch");
+ outn(" * any uses of REJECT which flex missed.");
+ outn(" */");
+ outn("#define REJECT reject_used_but_not_detected");
}
if (yymore_used) {
if (!C_plus_plus) {
if (yytext_is_array) {
- if (!reentrant){
- indent_puts ("static int yy_more_offset = 0;");
- indent_puts ("static int yy_prev_more_offset = 0;");
- }
- }
- else if (!reentrant) {
+ if (!reentrant) {
+ indent_puts("static int yy_more_offset = 0;");
+ indent_puts("static int yy_prev_more_offset = 0;");
+ }
+ } else if (!reentrant) {
indent_puts
- ("static int yy_more_flag = 0;");
+ ("static int yy_more_flag = 0;");
indent_puts
- ("static int yy_more_len = 0;");
+ ("static int yy_more_len = 0;");
}
}
-
if (yytext_is_array) {
indent_puts
- ("#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");
+ ("#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
- ("#define YY_RESTORE_YY_MORE_OFFSET \\");
- indent_up ();
- indent_puts ("{ \\");
+ ("#define YY_RESTORE_YY_MORE_OFFSET \\");
+ indent_up();
+ indent_puts("{ \\");
indent_puts
- ("YY_G(yy_more_offset) = YY_G(yy_prev_more_offset); \\");
- indent_puts ("yyleng -= YY_G(yy_more_offset); \\");
- indent_puts ("}");
- indent_down ();
- }
- else {
+ ("YY_G(yy_more_offset) = YY_G(yy_prev_more_offset); \\");
+ indent_puts("yyleng -= YY_G(yy_more_offset); \\");
+ indent_puts("}");
+ indent_down();
+ } else {
indent_puts
- ("#define yymore() (YY_G(yy_more_flag) = 1)");
+ ("#define yymore() (YY_G(yy_more_flag) = 1)");
indent_puts
- ("#define YY_MORE_ADJ YY_G(yy_more_len)");
- indent_puts ("#define YY_RESTORE_YY_MORE_OFFSET");
+ ("#define YY_MORE_ADJ YY_G(yy_more_len)");
+ indent_puts("#define YY_RESTORE_YY_MORE_OFFSET");
}
- }
-
- else {
+ } else {
indent_puts
- ("#define yymore() yymore_used_but_not_detected");
- indent_puts ("#define YY_MORE_ADJ 0");
- indent_puts ("#define YY_RESTORE_YY_MORE_OFFSET");
+ ("#define yymore() yymore_used_but_not_detected");
+ indent_puts("#define YY_MORE_ADJ 0");
+ indent_puts("#define YY_RESTORE_YY_MORE_OFFSET");
}
if (!C_plus_plus) {
if (yytext_is_array) {
- outn ("#ifndef YYLMAX");
- outn ("#define YYLMAX 8192");
- outn ("#endif\n");
- if (!reentrant){
- outn ("char yytext[YYLMAX];");
- outn ("char *yytext_ptr;");
- }
- }
-
- else {
- if(! reentrant)
- outn ("char *yytext;");
+ outn("#ifndef YYLMAX");
+ outn("#define YYLMAX 8192");
+ outn("#endif\n");
+ if (!reentrant) {
+ outn("char yytext[YYLMAX];");
+ outn("char *yytext_ptr;");
+ }
+ } else {
+ if (!reentrant)
+ outn("char *yytext;");
}
}
+ out(&action_array[defs1_offset]);
- out (&action_array[defs1_offset]);
+ line_directive_out(stdout, 0);
- line_directive_out (stdout, 0);
-
- skelout (); /* %% [5.0] - break point in skel */
+ skelout(); /* %% [5.0] - break point in skel */
if (!C_plus_plus) {
if (use_read) {
- outn ("\terrno=0; \\");
- outn ("\twhile ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\");
- outn ("\t{ \\");
- outn ("\t\tif( errno != EINTR) \\");
- outn ("\t\t{ \\");
- outn ("\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\");
- outn ("\t\t\tbreak; \\");
- outn ("\t\t} \\");
- outn ("\t\terrno=0; \\");
- outn ("\t\tclearerr(yyin); \\");
- outn ("\t}\\");
- }
-
- else {
- outn ("\tif ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \\");
- outn ("\t\t{ \\");
- outn ("\t\tint c = '*'; \\");
- outn ("\t\tsize_t n; \\");
- outn ("\t\tfor ( n = 0; n < max_size && \\");
- outn ("\t\t\t (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\");
- outn ("\t\t\tbuf[n] = (char) c; \\");
- outn ("\t\tif ( c == '\\n' ) \\");
- outn ("\t\t\tbuf[n++] = (char) c; \\");
- outn ("\t\tif ( c == EOF && ferror( yyin ) ) \\");
- outn ("\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\");
- outn ("\t\tresult = n; \\");
- outn ("\t\t} \\");
- outn ("\telse \\");
- outn ("\t\t{ \\");
- outn ("\t\terrno=0; \\");
- outn ("\t\twhile ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \\");
- outn ("\t\t\t{ \\");
- outn ("\t\t\tif( errno != EINTR) \\");
- outn ("\t\t\t\t{ \\");
- outn ("\t\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\");
- outn ("\t\t\t\tbreak; \\");
- outn ("\t\t\t\t} \\");
- outn ("\t\t\terrno=0; \\");
- outn ("\t\t\tclearerr(yyin); \\");
- outn ("\t\t\t} \\");
- outn ("\t\t}\\");
+ outn("\terrno=0; \\");
+ outn("\twhile ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\");
+ outn("\t{ \\");
+ outn("\t\tif( errno != EINTR) \\");
+ outn("\t\t{ \\");
+ outn("\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\");
+ outn("\t\t\tbreak; \\");
+ outn("\t\t} \\");
+ outn("\t\terrno=0; \\");
+ outn("\t\tclearerr(yyin); \\");
+ outn("\t}\\");
+ } else {
+ outn("\tif ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \\");
+ outn("\t\t{ \\");
+ outn("\t\tint c = '*'; \\");
+ outn("\t\tsize_t n; \\");
+ outn("\t\tfor ( n = 0; n < max_size && \\");
+ outn("\t\t\t (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\");
+ outn("\t\t\tbuf[n] = (char) c; \\");
+ outn("\t\tif ( c == '\\n' ) \\");
+ outn("\t\t\tbuf[n++] = (char) c; \\");
+ outn("\t\tif ( c == EOF && ferror( yyin ) ) \\");
+ outn("\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\");
+ outn("\t\tresult = n; \\");
+ outn("\t\t} \\");
+ outn("\telse \\");
+ outn("\t\t{ \\");
+ outn("\t\terrno=0; \\");
+ outn("\t\twhile ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \\");
+ outn("\t\t\t{ \\");
+ outn("\t\t\tif( errno != EINTR) \\");
+ outn("\t\t\t\t{ \\");
+ outn("\t\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\");
+ outn("\t\t\t\tbreak; \\");
+ outn("\t\t\t\t} \\");
+ outn("\t\t\terrno=0; \\");
+ outn("\t\t\tclearerr(yyin); \\");
+ outn("\t\t\t} \\");
+ outn("\t\t}\\");
}
}
+ skelout(); /* %% [6.0] - break point in skel */
- skelout (); /* %% [6.0] - break point in skel */
-
- indent_puts ("#define YY_RULE_SETUP \\");
- indent_up ();
+ indent_puts("#define YY_RULE_SETUP \\");
+ indent_up();
if (bol_needed) {
- indent_puts ("if ( yyleng > 0 ) \\");
- indent_up ();
- indent_puts ("YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \\");
- indent_puts ("\t\t(yytext[yyleng - 1] == '\\n'); \\");
- indent_down ();
+ indent_puts("if ( yyleng > 0 ) \\");
+ indent_up();
+ indent_puts("YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \\");
+ indent_puts("\t\t(yytext[yyleng - 1] == '\\n'); \\");
+ indent_down();
}
- indent_puts ("YY_USER_ACTION");
- indent_down ();
+ indent_puts("YY_USER_ACTION");
+ indent_down();
- skelout (); /* %% [7.0] - break point in skel */
+ skelout(); /* %% [7.0] - break point in skel */
/* Copy prolog to output file. */
- out (&action_array[prolog_offset]);
+ out(&action_array[prolog_offset]);
- line_directive_out (stdout, 0);
+ line_directive_out(stdout, 0);
- skelout (); /* %% [8.0] - break point in skel */
+ skelout(); /* %% [8.0] - break point in skel */
- set_indent (2);
+ set_indent(2);
if (yymore_used && !yytext_is_array) {
- indent_puts ("YY_G(yy_more_len) = 0;");
- indent_puts ("if ( YY_G(yy_more_flag) )");
- indent_up ();
- indent_puts ("{");
+ indent_puts("YY_G(yy_more_len) = 0;");
+ indent_puts("if ( YY_G(yy_more_flag) )");
+ indent_up();
+ indent_puts("{");
indent_puts
- ("YY_G(yy_more_len) = YY_G(yy_c_buf_p) - YY_G(yytext_ptr);");
- indent_puts ("YY_G(yy_more_flag) = 0;");
- indent_puts ("}");
- indent_down ();
+ ("YY_G(yy_more_len) = YY_G(yy_c_buf_p) - YY_G(yytext_ptr);");
+ indent_puts("YY_G(yy_more_flag) = 0;");
+ indent_puts("}");
+ indent_down();
}
+ skelout(); /* %% [9.0] - break point in skel */
- skelout (); /* %% [9.0] - break point in skel */
-
- gen_start_state ();
+ gen_start_state();
/* Note, don't use any indentation. */
- outn ("yy_match:");
- gen_next_match ();
+ outn("yy_match:");
+ gen_next_match();
- skelout (); /* %% [10.0] - break point in skel */
- set_indent (2);
- gen_find_action ();
+ skelout(); /* %% [10.0] - break point in skel */
+ set_indent(2);
+ gen_find_action();
- skelout (); /* %% [11.0] - break point in skel */
- outn ("m4_ifdef( [[M4_YY_USE_LINENO]],[[");
+ skelout(); /* %% [11.0] - break point in skel */
+ 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 ();
- indent_puts ("{");
- indent_puts ("yy_size_t yyl;");
- do_indent ();
- out_str ("for ( yyl = %s; yyl < yyleng; ++yyl )\n",
- yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" :
- "YY_G(yy_more_len)") : "0");
- indent_up ();
- indent_puts ("if ( yytext[yyl] == '\\n' )");
- indent_up ();
- indent_puts ("M4_YY_INCR_LINENO();");
- indent_down ();
- indent_down ();
- indent_puts ("}");
- indent_down ();
- outn ("]])");
-
- skelout (); /* %% [12.0] - break point in skel */
+ ("if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )");
+ indent_up();
+ indent_puts("{");
+ indent_puts("yy_size_t yyl;");
+ do_indent();
+ out_str("for ( yyl = %s; yyl < yyleng; ++yyl )\n",
+ yymore_used ? (yytext_is_array ? "YY_G(yy_prev_more_offset)" :
+ "YY_G(yy_more_len)") : "0");
+ indent_up();
+ indent_puts("if ( yytext[yyl] == '\\n' )");
+ indent_up();
+ indent_puts("M4_YY_INCR_LINENO();");
+ indent_down();
+ indent_down();
+ indent_puts("}");
+ indent_down();
+ outn("]])");
+
+ skelout(); /* %% [12.0] - break point in skel */
if (ddebug) {
- indent_puts ("if ( yy_flex_debug )");
- indent_up ();
+ indent_puts("if ( yy_flex_debug )");
+ indent_up();
- indent_puts ("{");
- indent_puts ("if ( yy_act == 0 )");
- indent_up ();
- indent_puts (C_plus_plus ?
- "std::cerr << \"--scanner backing up\\n\";" :
- "fprintf( stderr, \"--scanner backing up\\n\" );");
- indent_down ();
+ indent_puts("{");
+ indent_puts("if ( yy_act == 0 )");
+ indent_up();
+ indent_puts(C_plus_plus ?
+ "std::cerr << \"--scanner backing up\\n\";" :
+ "fprintf( stderr, \"--scanner backing up\\n\" );");
+ indent_down();
- do_indent ();
- out_dec ("else if ( yy_act < %d )\n", num_rules);
- indent_up ();
+ do_indent();
+ out_dec("else if ( yy_act < %d )\n", num_rules);
+ indent_up();
if (C_plus_plus) {
indent_puts
- ("std::cerr << \"--accepting rule at line \" << yy_rule_linenum[yy_act] <<");
+ ("std::cerr << \"--accepting rule at line \" << yy_rule_linenum[yy_act] <<");
indent_puts
- (" \"(\\\"\" << yytext << \"\\\")\\n\";");
- }
- else {
+ (" \"(\\\"\" << yytext << \"\\\")\\n\";");
+ } else {
indent_puts
- ("fprintf( stderr, \"--accepting rule at line %ld (\\\"%s\\\")\\n\",");
+ ("fprintf( stderr, \"--accepting rule at line %ld (\\\"%s\\\")\\n\",");
indent_puts
- (" (long)yy_rule_linenum[yy_act], yytext );");
+ (" (long)yy_rule_linenum[yy_act], yytext );");
}
- indent_down ();
+ indent_down();
- do_indent ();
- out_dec ("else if ( yy_act == %d )\n", num_rules);
- indent_up ();
+ do_indent();
+ out_dec("else if ( yy_act == %d )\n", num_rules);
+ indent_up();
if (C_plus_plus) {
indent_puts
- ("std::cerr << \"--accepting default rule (\\\"\" << yytext << \"\\\")\\n\";");
- }
- else {
+ ("std::cerr << \"--accepting default rule (\\\"\" << yytext << \"\\\")\\n\";");
+ } else {
indent_puts
- ("fprintf( stderr, \"--accepting default rule (\\\"%s\\\")\\n\",");
- indent_puts (" yytext );");
+ ("fprintf( stderr, \"--accepting default rule (\\\"%s\\\")\\n\",");
+ indent_puts(" yytext );");
}
- indent_down ();
+ indent_down();
- do_indent ();
- out_dec ("else if ( yy_act == %d )\n", num_rules + 1);
- indent_up ();
+ do_indent();
+ out_dec("else if ( yy_act == %d )\n", num_rules + 1);
+ indent_up();
- indent_puts (C_plus_plus ?
- "std::cerr << \"--(end of buffer or a NUL)\\n\";" :
- "fprintf( stderr, \"--(end of buffer or a NUL)\\n\" );");
+ indent_puts(C_plus_plus ?
+ "std::cerr << \"--(end of buffer or a NUL)\\n\";" :
+ "fprintf( stderr, \"--(end of buffer or a NUL)\\n\" );");
- indent_down ();
+ indent_down();
- do_indent ();
- outn ("else");
- indent_up ();
+ do_indent();
+ outn("else");
+ indent_up();
if (C_plus_plus) {
indent_puts
- ("std::cerr << \"--EOF (start condition \" << YY_START << \")\\n\";");
- }
- else {
+ ("std::cerr << \"--EOF (start condition \" << YY_START << \")\\n\";");
+ } else {
indent_puts
- ("fprintf( stderr, \"--EOF (start condition %d)\\n\", YY_START );");
+ ("fprintf( stderr, \"--EOF (start condition %d)\\n\", YY_START );");
}
- indent_down ();
+ indent_down();
- indent_puts ("}");
- indent_down ();
+ indent_puts("}");
+ indent_down();
}
-
/* Copy actions to output file. */
- skelout (); /* %% [13.0] - break point in skel */
- indent_up ();
- gen_bu_action ();
- out (&action_array[action_offset]);
+ skelout(); /* %% [13.0] - break point in skel */
+ indent_up();
+ gen_bu_action();
+ out(&action_array[action_offset]);
- line_directive_out (stdout, 0);
+ line_directive_out(stdout, 0);
/* generate cases for any missing EOF rules */
for (i = 1; i <= lastsc; ++i)
if (!sceof[i]) {
- do_indent ();
- out_str ("case YY_STATE_EOF(%s):\n", scname[i]);
+ do_indent();
+ out_str("case YY_STATE_EOF(%s):\n", scname[i]);
did_eof_rule = true;
}
-
if (did_eof_rule) {
- indent_up ();
- indent_puts ("yyterminate();");
- indent_down ();
+ indent_up();
+ indent_puts("yyterminate();");
+ indent_down();
}
-
-
/* Generate code for handling NUL's, if needed. */
- /* First, deal with backing up and setting up yy_cp if the scanner
+ /*
+ * First, deal with backing up and setting up yy_cp if the scanner
* finds that it should JAM on the NUL.
*/
- skelout (); /* %% [14.0] - break point in skel */
- set_indent (4);
+ skelout(); /* %% [14.0] - break point in skel */
+ set_indent(4);
if (fullspd || fulltbl)
- indent_puts ("yy_cp = YY_G(yy_c_buf_p);");
+ indent_puts("yy_cp = YY_G(yy_c_buf_p);");
else { /* compressed table */
if (!reject && !interactive) {
- /* Do the guaranteed-needed backing up to figure
- * out the match.
+ /*
+ * Do the guaranteed-needed backing up to figure out
+ * the match.
*/
indent_puts
- ("yy_cp = YY_G(yy_last_accepting_cpos);");
+ ("yy_cp = YY_G(yy_last_accepting_cpos);");
indent_puts
- ("yy_current_state = YY_G(yy_last_accepting_state);");
- }
-
- else
- /* Still need to initialize yy_cp, though
+ ("yy_current_state = YY_G(yy_last_accepting_state);");
+ } else
+ /*
+ * Still need to initialize yy_cp, though
* yy_current_state was set up by
* yy_get_previous_state().
*/
- indent_puts ("yy_cp = YY_G(yy_c_buf_p);");
+ indent_puts("yy_cp = YY_G(yy_c_buf_p);");
}
/* Generate code for yy_get_previous_state(). */
- set_indent (1);
- skelout (); /* %% [15.0] - break point in skel */
+ set_indent(1);
+ skelout(); /* %% [15.0] - break point in skel */
- gen_start_state ();
+ gen_start_state();
- set_indent (2);
- skelout (); /* %% [16.0] - break point in skel */
- gen_next_state (true);
+ set_indent(2);
+ skelout(); /* %% [16.0] - break point in skel */
+ gen_next_state(true);
- set_indent (1);
- skelout (); /* %% [17.0] - break point in skel */
- gen_NUL_trans ();
+ set_indent(1);
+ skelout(); /* %% [17.0] - break point in skel */
+ gen_NUL_trans();
- skelout (); /* %% [18.0] - break point in skel */
- skelout (); /* %% [19.0] - break point in skel */
+ skelout(); /* %% [18.0] - break point in skel */
+ skelout(); /* %% [19.0] - break point in skel */
/* Update BOL and yylineno inside of input(). */
if (bol_needed) {
indent_puts
- ("YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\\n');");
+ ("YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\\n');");
if (do_yylineno) {
indent_puts
- ("if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol )");
- indent_up ();
- indent_puts ("M4_YY_INCR_LINENO();");
- indent_down ();
+ ("if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol )");
+ indent_up();
+ indent_puts("M4_YY_INCR_LINENO();");
+ indent_down();
}
+ } else if (do_yylineno) {
+ indent_puts("if ( c == '\\n' )");
+ indent_up();
+ indent_puts("M4_YY_INCR_LINENO();");
+ indent_down();
}
-
- else if (do_yylineno) {
- indent_puts ("if ( c == '\\n' )");
- indent_up ();
- indent_puts ("M4_YY_INCR_LINENO();");
- indent_down ();
- }
-
- skelout ();
+ skelout();
/* Copy remainder of input to output. */
- line_directive_out (stdout, 1);
+ line_directive_out(stdout, 1);
if (sectnum == 3) {
- OUT_BEGIN_CODE ();
- (void) flexscan (); /* copy remainder of input to output */
- OUT_END_CODE ();
+ OUT_BEGIN_CODE();
+ (void) flexscan(); /* copy remainder of input to output */
+ OUT_END_CODE();
}
}
diff --git a/usr.bin/lex/libmain.c b/usr.bin/lex/libmain.c
index 37bc4ee1347..b7b11acae44 100644
--- a/usr.bin/lex/libmain.c
+++ b/usr.bin/lex/libmain.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: libmain.c,v 1.8 2015/11/19 19:43:40 tedu Exp $ */
+/* $OpenBSD: libmain.c,v 1.9 2015/11/19 22:52:40 tedu Exp $ */
/* libmain - flex run-time support library "main" function */
@@ -23,13 +23,14 @@
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
-extern int yylex ();
+extern int yylex();
-int main (argc, argv)
- int argc;
- char *argv[];
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
{
- while (yylex () != 0) ;
+ while (yylex() != 0);
return 0;
}
diff --git a/usr.bin/lex/libyywrap.c b/usr.bin/lex/libyywrap.c
index f359c95ee5d..de8b09bdd9f 100644
--- a/usr.bin/lex/libyywrap.c
+++ b/usr.bin/lex/libyywrap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: libyywrap.c,v 1.8 2015/11/19 19:43:40 tedu Exp $ */
+/* $OpenBSD: libyywrap.c,v 1.9 2015/11/19 22:52:40 tedu Exp $ */
/* libyywrap - flex run-time support library "yywrap" function */
@@ -23,7 +23,8 @@
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
-int yywrap (void)
+int
+yywrap(void)
{
return 1;
}
diff --git a/usr.bin/lex/main.c b/usr.bin/lex/main.c
index 0ebbb5cbb09..1fcb8ed8a9c 100644
--- a/usr.bin/lex/main.c
+++ b/usr.bin/lex/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.17 2015/11/19 22:35:19 tedu Exp $ */
+/* $OpenBSD: main.c,v 1.18 2015/11/19 22:52:40 tedu Exp $ */
/* flex - tool to generate fast lexical analyzers */
@@ -32,7 +32,8 @@
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
-
+
+
#include "flexdef.h"
#include "version.h"
@@ -43,80 +44,77 @@ static char flex_version[] = FLEX_VERSION;
/* declare functions that have forward references */
-void flexinit PROTO ((int, char **));
-void readin PROTO ((void));
-void set_up_initial_allocations PROTO ((void));
-static char *basename2 PROTO ((char *path, int should_strip_ext));
+void flexinit PROTO((int, char **));
+void readin PROTO((void));
+void set_up_initial_allocations PROTO((void));
+static char *basename2 PROTO((char *path, int should_strip_ext));
/* these globals are all defined and commented in flexdef.h */
-int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt;
-int interactive, lex_compat, posix_compat, do_yylineno,
- useecs, fulltbl, usemecs;
-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_lval, bison_bridge_lloc;
-int yymore_used, reject, real_reject, continued_action, in_rule;
-int yymore_really_used, reject_really_used;
-int datapos, dataline, linenum;
-FILE *skelfile = NULL;
-int skel_ind = 0;
-char *action_array;
-int action_size, defs1_offset, prolog_offset, action_offset,
- action_index;
-char *infilename = NULL, *outfilename = NULL, *headerfilename = NULL;
-int did_outfilename;
-char *prefix, *yyclass, *extra_type = NULL;
-int do_stdinit, use_stdout;
-int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
-int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
-int maximum_mns, current_mns, current_max_rules;
-int num_rules, num_eof_rules, default_rule, lastnfa;
-int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
-int *accptnum, *assoc_rule, *state_type;
-int *rule_type, *rule_linenum, *rule_useful;
-int current_state_type;
-int variable_trailing_context_rules;
-int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
-int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
-int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs,
- tecfwd[CSIZE + 1];
-int tecbck[CSIZE + 1];
-int lastsc, *scset, *scbol, *scxclu, *sceof;
-int current_max_scs;
-char **scname;
-int current_max_dfa_size, current_max_xpairs;
-int current_max_template_xpairs, current_max_dfas;
-int lastdfa, *nxt, *chk, *tnxt;
-int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz;
+int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt;
+int interactive, lex_compat, posix_compat, do_yylineno, useecs, fulltbl,
+ usemecs;
+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_lval, bison_bridge_lloc;
+int yymore_used, reject, real_reject, continued_action, in_rule;
+int yymore_really_used, reject_really_used;
+int datapos, dataline, linenum;
+FILE *skelfile = NULL;
+int skel_ind = 0;
+char *action_array;
+int action_size, defs1_offset, prolog_offset, action_offset, action_index;
+char *infilename = NULL, *outfilename = NULL, *headerfilename = NULL;
+int did_outfilename;
+char *prefix, *yyclass, *extra_type = NULL;
+int do_stdinit, use_stdout;
+int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
+int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
+int maximum_mns, current_mns, current_max_rules;
+int num_rules, num_eof_rules, default_rule, lastnfa;
+int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
+int *accptnum, *assoc_rule, *state_type;
+int *rule_type, *rule_linenum, *rule_useful;
+int current_state_type;
+int variable_trailing_context_rules;
+int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
+int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
+int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs, tecfwd[CSIZE + 1];
+int tecbck[CSIZE + 1];
+int lastsc, *scset, *scbol, *scxclu, *sceof;
+int current_max_scs;
+char **scname;
+int current_max_dfa_size, current_max_xpairs;
+int current_max_template_xpairs, current_max_dfas;
+int lastdfa, *nxt, *chk, *tnxt;
+int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz;
union dfaacc_union *dfaacc;
-int *accsiz, *dhash, numas;
-int numsnpairs, jambase, jamstate;
-int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
-int current_maxccls, current_max_ccl_tbl_size;
-Char *ccltbl;
-char nmstr[MAXLINE];
-int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
-int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
-int num_backing_up, bol_needed;
-FILE *backing_up_file;
-int end_of_buffer_state;
-char **input_files;
-int num_input_files;
+int *accsiz, *dhash, numas;
+int numsnpairs, jambase, jamstate;
+int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
+int current_maxccls, current_max_ccl_tbl_size;
+Char *ccltbl;
+char nmstr[MAXLINE];
+int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
+int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
+int num_backing_up, bol_needed;
+FILE *backing_up_file;
+int end_of_buffer_state;
+char **input_files;
+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 *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;
+bool tablesext, tablesverify, gentables;
+char *tablesfilename = 0, *tablesname = 0;
struct yytbl_writer tableswr;
/* Make sure program_name is initialized so we don't crash if writing
* out an error message before getting the program name from argv[0].
*/
-char *program_name = "flex";
+char *program_name = "flex";
#ifndef SHORT_FILE_NAMES
static const char *outfile_template = "lex.%s.%s";
@@ -133,130 +131,131 @@ extern unsigned _stklen = 16384;
#endif
/* From scan.l */
-extern FILE* yyout;
+extern FILE *yyout;
static char outfile_path[MAXLINE];
static int outfile_created = 0;
static char *skelname = NULL;
-static int _stdout_closed = 0; /* flag to prevent double-fclose() on stdout. */
+static int _stdout_closed = 0; /* flag to prevent double-fclose() on stdout. */
const char *escaped_qstart = "[[]]M4_YY_NOOP[M4_YY_NOOP[M4_YY_NOOP[[]]";
-const char *escaped_qend = "[[]]M4_YY_NOOP]M4_YY_NOOP]M4_YY_NOOP[[]]";
+const char *escaped_qend = "[[]]M4_YY_NOOP]M4_YY_NOOP]M4_YY_NOOP[[]]";
/* 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[]));
+int flex_main PROTO((int argc, char *argv[]));
+int main PROTO((int argc, char *argv[]));
-int flex_main (argc, argv)
- int argc;
- char *argv[];
+int
+flex_main(argc, argv)
+ int argc;
+ char *argv[];
{
- int i, exit_status, child_status;
-
- /* Set a longjmp target. Yes, I know it's a hack, but it gets worse: The
- * return value of setjmp, if non-zero, is the desired exit code PLUS ONE.
- * For example, if you want 'main' to return with code '2', then call
- * longjmp() with an argument of 3. This is because it is invalid to
- * specify a value of 0 to longjmp. FLEX_EXIT(n) should be used instead of
- * exit(n);
+ int i, exit_status, child_status;
+
+ /*
+ * Set a longjmp target. Yes, I know it's a hack, but it gets worse:
+ * The return value of setjmp, if non-zero, is the desired exit code
+ * PLUS ONE. For example, if you want 'main' to return with code '2',
+ * then call longjmp() with an argument of 3. This is because it is
+ * invalid to specify a value of 0 to longjmp. FLEX_EXIT(n) should be
+ * used instead of exit(n);
*/
- exit_status = setjmp (flex_main_jmp_buf);
- if (exit_status){
- if (stdout && !_stdout_closed && !ferror(stdout)){
- fflush(stdout);
- fclose(stdout);
- }
- while (wait(&child_status) > 0){
- if (!WIFEXITED (child_status)
- || WEXITSTATUS (child_status) != 0){
- /* report an error of a child
- */
- if( exit_status <= 1 )
- exit_status = 2;
-
- }
- }
- return exit_status - 1;
- }
-
- flexinit (argc, argv);
-
- readin ();
-
- skelout ();
+ exit_status = setjmp(flex_main_jmp_buf);
+ if (exit_status) {
+ if (stdout && !_stdout_closed && !ferror(stdout)) {
+ fflush(stdout);
+ fclose(stdout);
+ }
+ while (wait(&child_status) > 0) {
+ if (!WIFEXITED(child_status)
+ || WEXITSTATUS(child_status) != 0) {
+ /*
+ * report an error of a child
+ */
+ if (exit_status <= 1)
+ exit_status = 2;
+
+ }
+ }
+ return exit_status - 1;
+ }
+ flexinit(argc, argv);
+
+ readin();
+
+ skelout();
/* %% [1.5] DFA */
- ntod ();
+ ntod();
for (i = 1; i <= num_rules; ++i)
if (!rule_useful[i] && i != default_rule)
- line_warning (_("rule cannot be matched"),
- rule_linenum[i]);
+ line_warning(_("rule cannot be matched"),
+ rule_linenum[i]);
if (spprdflt && !reject && rule_useful[default_rule])
- line_warning (_
- ("-s option given but default rule can be matched"),
- rule_linenum[default_rule]);
+ line_warning(_
+ ("-s option given but default rule can be matched"),
+ rule_linenum[default_rule]);
/* Generate the C state transition tables from the DFA. */
- make_tables ();
+ make_tables();
- /* Note, flexend does not return. It exits with its argument
- * as status.
+ /*
+ * Note, flexend does not return. It exits with its argument as
+ * status.
*/
- flexend (0);
+ flexend(0);
return 0; /* keep compilers/lint happy */
}
/* Wrapper around flex_main, so flex_main can be built as a library. */
-int main (argc, argv)
- int argc;
- char *argv[];
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
{
#if ENABLE_NLS
#if HAVE_LOCALE_H
- setlocale (LC_MESSAGES, "");
- setlocale (LC_CTYPE, "");
- textdomain (PACKAGE);
- bindtextdomain (PACKAGE, LOCALEDIR);
+ setlocale(LC_MESSAGES, "");
+ setlocale(LC_CTYPE, "");
+ textdomain(PACKAGE);
+ bindtextdomain(PACKAGE, LOCALEDIR);
#endif
#endif
- if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1)
- {
- fprintf( stderr, _( "%s: pledge\n"),
- program_name);
+ if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1) {
+ fprintf(stderr, _("%s: pledge\n"),
+ program_name);
exit(1);
}
-
- return flex_main (argc, argv);
+ return flex_main(argc, argv);
}
/* check_options - check user-specified options */
-void check_options ()
+void
+check_options()
{
- int i;
- const char * m4 = NULL;
+ int i;
+ const char *m4 = NULL;
if (lex_compat) {
if (C_plus_plus)
- flexerror (_("Can't use -+ with -l option"));
+ flexerror(_("Can't use -+ with -l option"));
if (fulltbl || fullspd)
- flexerror (_("Can't use -f or -F with -l option"));
+ flexerror(_("Can't use -f or -F with -l option"));
if (reentrant || bison_bridge_lval)
- flexerror (_
- ("Can't use --reentrant or --bison-bridge with -l option"));
+ flexerror(_
+ ("Can't use --reentrant or --bison-bridge with -l option"));
yytext_is_array = true;
do_yylineno = true;
use_read = false;
}
-
-
#if 0
/* This makes no sense whatsoever. I'm removing it. */
if (do_yylineno)
@@ -270,50 +269,47 @@ void check_options ()
else
csize = CSIZE;
}
-
if (interactive == unspecified) {
if (fulltbl || fullspd)
interactive = false;
else
interactive = true;
}
-
if (fulltbl || fullspd) {
if (usemecs)
- flexerror (_
- ("-Cf/-CF and -Cm don't make sense together"));
+ flexerror(_
+ ("-Cf/-CF and -Cm don't make sense together"));
if (interactive)
- flexerror (_("-Cf/-CF and -I are incompatible"));
+ flexerror(_("-Cf/-CF and -I are incompatible"));
if (lex_compat)
- flexerror (_
- ("-Cf/-CF are incompatible with lex-compatibility mode"));
+ flexerror(_
+ ("-Cf/-CF are incompatible with lex-compatibility mode"));
if (fulltbl && fullspd)
- flexerror (_
- ("-Cf and -CF are mutually exclusive"));
+ flexerror(_
+ ("-Cf and -CF are mutually exclusive"));
}
-
if (C_plus_plus && fullspd)
- flexerror (_("Can't use -+ with -CF option"));
+ flexerror(_("Can't use -+ with -CF option"));
if (C_plus_plus && yytext_is_array) {
- warn (_("%array incompatible with -+ option"));
+ warn(_("%array incompatible with -+ option"));
yytext_is_array = false;
}
-
if (C_plus_plus && (reentrant))
- flexerror (_("Options -+ and --reentrant are mutually exclusive."));
+ flexerror(_("Options -+ and --reentrant are mutually exclusive."));
if (C_plus_plus && bison_bridge_lval)
- flexerror (_("bison bridge not supported for the C++ scanner."));
+ flexerror(_("bison bridge not supported for the C++ scanner."));
if (useecs) { /* Set up doubly-linked equivalence classes. */
- /* We loop all the way up to csize, since ecgroup[csize] is
+ /*
+ * We loop all the way up to csize, since ecgroup[csize] is
* the position used for NUL characters.
*/
ecgroup[1] = NIL;
@@ -324,9 +320,7 @@ void check_options ()
}
nextecm[csize] = NIL;
- }
-
- else {
+ } else {
/* Put everything in its own equivalence class. */
for (i = 1; i <= csize; ++i) {
ecgroup[i] = i;
@@ -334,58 +328,55 @@ void check_options ()
}
}
- if (!ansi_func_defs)
- buf_m4_define( &m4defs_buf, "M4_YY_NO_ANSI_FUNC_DEFS", NULL);
+ 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 (!ansi_func_protos)
+ buf_m4_define(&m4defs_buf, "M4_YY_NO_ANSI_FUNC_PROTOS", NULL);
- if (extra_type)
- buf_m4_define( &m4defs_buf, "M4_EXTRA_TYPE_DEFS", extra_type);
+ if (extra_type)
+ buf_m4_define(&m4defs_buf, "M4_EXTRA_TYPE_DEFS", extra_type);
if (!use_stdout) {
- FILE *prev_stdout;
+ FILE *prev_stdout;
if (!did_outfilename) {
- char *suffix;
+ char *suffix;
if (C_plus_plus)
suffix = "cc";
else
suffix = "c";
- snprintf (outfile_path, sizeof(outfile_path), outfile_template,
- prefix, suffix);
+ snprintf(outfile_path, sizeof(outfile_path), outfile_template,
+ prefix, suffix);
outfilename = outfile_path;
}
-
- prev_stdout = freopen (outfilename, "w+", stdout);
+ prev_stdout = freopen(outfilename, "w+", stdout);
if (prev_stdout == NULL)
- lerrsf (_("could not create %s"), outfilename);
+ lerrsf(_("could not create %s"), outfilename);
outfile_created = 1;
}
-
-
- /* Setup the filter chain. */
- output_chain = filter_create_int(NULL, filter_tee_header, headerfilename);
- if ( !(m4 = getenv("M4")))
- m4 = M4;
- 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;
+ /* Setup the filter chain. */
+ output_chain = filter_create_int(NULL, filter_tee_header, headerfilename);
+ if (!(m4 = getenv("M4")))
+ m4 = M4;
+ 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. */
- buf_m4_define (&m4defs_buf, "M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0");
+ buf_m4_define(&m4defs_buf, "M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0");
if (tablesext)
gentables = false;
@@ -395,100 +386,97 @@ void check_options ()
if (tablesext) {
- FILE *tablesout;
+ FILE *tablesout;
struct yytbl_hdr hdr;
- char *pname = 0;
- int nbytes = 0;
+ char *pname = 0;
+ int nbytes = 0;
- buf_m4_define (&m4defs_buf, "M4_YY_TABLES_EXTERNAL", NULL);
+ buf_m4_define(&m4defs_buf, "M4_YY_TABLES_EXTERNAL", NULL);
if (!tablesfilename) {
- nbytes = strlen (prefix) + strlen (tablesfile_template) + 2;
- tablesfilename = pname = (char *) calloc (nbytes, 1);
- snprintf (pname, nbytes, tablesfile_template, prefix);
+ nbytes = strlen(prefix) + strlen(tablesfile_template) + 2;
+ tablesfilename = pname = (char *) calloc(nbytes, 1);
+ snprintf(pname, nbytes, tablesfile_template, prefix);
}
-
- if ((tablesout = fopen (tablesfilename, "w")) == NULL)
- lerrsf (_("could not create %s"), tablesfilename);
+ if ((tablesout = fopen(tablesfilename, "w")) == NULL)
+ lerrsf(_("could not create %s"), tablesfilename);
if (pname)
- free (pname);
+ free(pname);
tablesfilename = 0;
- yytbl_writer_init (&tableswr, tablesout);
+ yytbl_writer_init(&tableswr, tablesout);
- nbytes = strlen (prefix) + strlen ("tables") + 2;
- tablesname = (char *) calloc (nbytes, 1);
- snprintf (tablesname, nbytes, "%stables", prefix);
- yytbl_hdr_init (&hdr, flex_version, tablesname);
+ nbytes = strlen(prefix) + strlen("tables") + 2;
+ tablesname = (char *) calloc(nbytes, 1);
+ snprintf(tablesname, nbytes, "%stables", prefix);
+ yytbl_hdr_init(&hdr, flex_version, tablesname);
- if (yytbl_hdr_fwrite (&tableswr, &hdr) <= 0)
- flexerror (_("could not write tables header"));
+ if (yytbl_hdr_fwrite(&tableswr, &hdr) <= 0)
+ flexerror(_("could not write tables header"));
}
-
- if (skelname && (skelfile = fopen (skelname, "r")) == NULL)
- lerrsf (_("can't open skeleton file %s"), skelname);
+ if (skelname && (skelfile = fopen(skelname, "r")) == NULL)
+ lerrsf(_("can't open skeleton file %s"), skelname);
if (reentrant) {
- buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL);
+ buf_m4_define(&m4defs_buf, "M4_YY_REENTRANT", NULL);
if (yytext_is_array)
- buf_m4_define (&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL);
+ buf_m4_define(&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL);
}
+ if (bison_bridge_lval)
+ buf_m4_define(&m4defs_buf, "M4_YY_BISON_LVAL", NULL);
- if ( bison_bridge_lval)
- buf_m4_define (&m4defs_buf, "M4_YY_BISON_LVAL", NULL);
-
- if ( bison_bridge_lloc)
- buf_m4_define (&m4defs_buf, "<M4_YY_BISON_LLOC>", NULL);
+ if (bison_bridge_lloc)
+ buf_m4_define(&m4defs_buf, "<M4_YY_BISON_LLOC>", NULL);
buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix);
if (did_outfilename)
- line_directive_out (stdout, 0);
+ line_directive_out(stdout, 0);
if (do_yylineno)
- buf_m4_define (&m4defs_buf, "M4_YY_USE_LINENO", NULL);
+ 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";
- size_t strsz;
-
- str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(scname[i]) + (int)(1 + log10(i)) + 2);
- if (!str)
- flexfatal(_("allocation of macro definition failed"));
- snprintf(str, strsz, 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);
- }
-
- /* This is where we begin writing to the file. */
-
- /* Dump the %top code. */
- if( top_buf.elts)
- outn((char*) top_buf.elts);
-
- /* Dump the m4 definitions. */
- buf_print_strings(&m4defs_buf, stdout);
- m4defs_buf.nelts = 0; /* memory leak here. */
-
- /* Place a bogus line directive, it will be fixed in the filter. */
- outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
+ 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";
+ size_t strsz;
+
+ str = (char *) flex_alloc(strsz = strlen(fmt) + strlen(scname[i]) + (int) (1 + log10(i)) + 2);
+ if (!str)
+ flexfatal(_("allocation of macro definition failed"));
+ snprintf(str, strsz, 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);
+ }
+
+ /* This is where we begin writing to the file. */
+
+ /* Dump the %top code. */
+ if (top_buf.elts)
+ outn((char *) top_buf.elts);
+
+ /* Dump the m4 definitions. */
+ buf_print_strings(&m4defs_buf, stdout);
+ m4defs_buf.nelts = 0; /* memory leak here. */
+
+ /* Place a bogus line directive, it will be fixed in the filter. */
+ outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
/* Dump the user defined preproc directives. */
if (userdef_buf.elts)
- outn ((char *) (userdef_buf.elts));
+ outn((char *) (userdef_buf.elts));
- skelout ();
+ skelout();
/* %% [1.0] */
}
@@ -498,457 +486,453 @@ void check_options ()
* This routine does not return.
*/
-void flexend (exit_status)
- int exit_status;
+void
+flexend(exit_status)
+ int exit_status;
{
static int called_before = -1; /* prevent infinite recursion. */
- int tblsiz;
+ int tblsiz;
if (++called_before)
- FLEX_EXIT (exit_status);
+ FLEX_EXIT(exit_status);
if (skelfile != NULL) {
- if (ferror (skelfile))
- lerrsf (_("input error reading skeleton file %s"),
- skelname);
+ if (ferror(skelfile))
+ lerrsf(_("input error reading skeleton file %s"),
+ skelname);
- else if (fclose (skelfile))
- lerrsf (_("error closing skeleton file %s"),
- skelname);
+ else if (fclose(skelfile))
+ lerrsf(_("error closing skeleton file %s"),
+ skelname);
}
-
#if 0
- fprintf (header_out,
- "#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n");
- fprintf (header_out,
- "/* Beware! Start conditions are not prefixed. */\n");
-
- /* Special case for "INITIAL" */
- 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,
- "#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n");
-
- /* Kill ALL flex-related macros. This is so the user
- * can #include more than one generated header file. */
- fprintf (header_out, "#ifndef YY_HEADER_NO_UNDEFS\n");
- fprintf (header_out,
- "/* Undefine all internal macros, etc., that do no belong in the header. */\n\n");
-
- {
- const char * undef_list[] = {
-
- "BEGIN",
- "ECHO",
- "EOB_ACT_CONTINUE_SCAN",
- "EOB_ACT_END_OF_FILE",
- "EOB_ACT_LAST_MATCH",
- "FLEX_SCANNER",
- "FLEX_STD",
- "REJECT",
- "YYFARGS0",
- "YYFARGS1",
- "YYFARGS2",
- "YYFARGS3",
- "YYLMAX",
- "YYSTATE",
- "YY_AT_BOL",
- "YY_BREAK",
- "YY_BUFFER_EOF_PENDING",
- "YY_BUFFER_NEW",
- "YY_BUFFER_NORMAL",
- "YY_BUF_SIZE",
- "M4_YY_CALL_LAST_ARG",
- "M4_YY_CALL_ONLY_ARG",
- "YY_CURRENT_BUFFER",
- "YY_DECL",
- "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",
- "YY_EXIT_FAILURE",
- "YY_EXTRA_TYPE",
- "YY_FATAL_ERROR",
- "YY_FLEX_DEFINED_ECHO",
- "YY_FLEX_LEX_COMPAT",
- "YY_FLEX_MAJOR_VERSION",
- "YY_FLEX_MINOR_VERSION",
- "YY_FLEX_SUBMINOR_VERSION",
- "YY_FLUSH_BUFFER",
- "YY_G",
- "YY_INPUT",
- "YY_INTERACTIVE",
- "YY_INT_ALIGNED",
- "YY_LAST_ARG",
- "YY_LESS_LINENO",
- "YY_LEX_ARGS",
- "YY_LEX_DECLARATION",
- "YY_LEX_PROTO",
- "YY_MAIN",
- "YY_MORE_ADJ",
- "YY_NEED_STRLEN",
- "YY_NEW_FILE",
- "YY_NULL",
- "YY_NUM_RULES",
- "YY_ONLY_ARG",
- "YY_PARAMS",
- "YY_PROTO",
- "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_START",
- "YY_START_STACK_INCR",
- "YY_STATE_EOF",
- "YY_STDINIT",
- "YY_TRAILING_HEAD_MASK",
- "YY_TRAILING_MASK",
- "YY_USER_ACTION",
- "YY_USE_CONST",
- "YY_USE_PROTOS",
- "unput",
- "yyTABLES_NAME",
- "yy_create_buffer",
- "yy_delete_buffer",
- "yy_flex_debug",
- "yy_flush_buffer",
- "yy_init_buffer",
- "yy_load_buffer_state",
- "yy_new_buffer",
- "yy_scan_buffer",
- "yy_scan_bytes",
- "yy_scan_string",
- "yy_set_bol",
- "yy_set_interactive",
- "yy_switch_to_buffer",
- "yypush_buffer_state",
- "yypop_buffer_state",
- "yyensure_buffer_stack",
- "yyalloc",
- "yyconst",
- "yyextra",
- "yyfree",
- "yyget_debug",
- "yyget_extra",
- "yyget_in",
- "yyget_leng",
- "yyget_lineno",
- "yyget_lloc",
- "yyget_lval",
- "yyget_out",
- "yyget_text",
- "yyin",
- "yyleng",
- "yyless",
- "yylex",
- "yylex_destroy",
- "yylex_init",
- "yylex_init_extra",
- "yylineno",
- "yylloc",
- "yylval",
- "yymore",
- "yyout",
- "yyrealloc",
- "yyrestart",
- "yyset_debug",
- "yyset_extra",
- "yyset_in",
- "yyset_lineno",
- "yyset_lloc",
- "yyset_lval",
- "yyset_out",
- "yytables_destroy",
- "yytables_fload",
- "yyterminate",
- "yytext",
- "yytext_ptr",
- "yywrap",
-
- /* must be null-terminated */
- NULL};
-
-
- for (i=0; undef_list[i] != NULL; i++)
- fprintf (header_out, "#undef %s\n", undef_list[i]);
- }
-
- /* undef any of the auto-generated symbols. */
- for (i = 0; i < defs_buf.nelts; i++) {
-
- /* don't undef start conditions */
- if (sclookup (((char **) defs_buf.elts)[i]) > 0)
- continue;
- fprintf (header_out, "#undef %s\n",
- ((char **) defs_buf.elts)[i]);
- }
+ fprintf(header_out,
+ "#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n");
+ fprintf(header_out,
+ "/* Beware! Start conditions are not prefixed. */\n");
+
+ /* Special case for "INITIAL" */
+ 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,
+ "#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n");
+
+ /*
+ * Kill ALL flex-related macros. This is so the user can #include
+ * more than one generated header file.
+ */
+ fprintf(header_out, "#ifndef YY_HEADER_NO_UNDEFS\n");
+ fprintf(header_out,
+ "/* Undefine all internal macros, etc., that do no belong in the header. */\n\n");
+
+ {
+ const char *undef_list[] = {
+
+ "BEGIN",
+ "ECHO",
+ "EOB_ACT_CONTINUE_SCAN",
+ "EOB_ACT_END_OF_FILE",
+ "EOB_ACT_LAST_MATCH",
+ "FLEX_SCANNER",
+ "FLEX_STD",
+ "REJECT",
+ "YYFARGS0",
+ "YYFARGS1",
+ "YYFARGS2",
+ "YYFARGS3",
+ "YYLMAX",
+ "YYSTATE",
+ "YY_AT_BOL",
+ "YY_BREAK",
+ "YY_BUFFER_EOF_PENDING",
+ "YY_BUFFER_NEW",
+ "YY_BUFFER_NORMAL",
+ "YY_BUF_SIZE",
+ "M4_YY_CALL_LAST_ARG",
+ "M4_YY_CALL_ONLY_ARG",
+ "YY_CURRENT_BUFFER",
+ "YY_DECL",
+ "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",
+ "YY_EXIT_FAILURE",
+ "YY_EXTRA_TYPE",
+ "YY_FATAL_ERROR",
+ "YY_FLEX_DEFINED_ECHO",
+ "YY_FLEX_LEX_COMPAT",
+ "YY_FLEX_MAJOR_VERSION",
+ "YY_FLEX_MINOR_VERSION",
+ "YY_FLEX_SUBMINOR_VERSION",
+ "YY_FLUSH_BUFFER",
+ "YY_G",
+ "YY_INPUT",
+ "YY_INTERACTIVE",
+ "YY_INT_ALIGNED",
+ "YY_LAST_ARG",
+ "YY_LESS_LINENO",
+ "YY_LEX_ARGS",
+ "YY_LEX_DECLARATION",
+ "YY_LEX_PROTO",
+ "YY_MAIN",
+ "YY_MORE_ADJ",
+ "YY_NEED_STRLEN",
+ "YY_NEW_FILE",
+ "YY_NULL",
+ "YY_NUM_RULES",
+ "YY_ONLY_ARG",
+ "YY_PARAMS",
+ "YY_PROTO",
+ "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_START",
+ "YY_START_STACK_INCR",
+ "YY_STATE_EOF",
+ "YY_STDINIT",
+ "YY_TRAILING_HEAD_MASK",
+ "YY_TRAILING_MASK",
+ "YY_USER_ACTION",
+ "YY_USE_CONST",
+ "YY_USE_PROTOS",
+ "unput",
+ "yyTABLES_NAME",
+ "yy_create_buffer",
+ "yy_delete_buffer",
+ "yy_flex_debug",
+ "yy_flush_buffer",
+ "yy_init_buffer",
+ "yy_load_buffer_state",
+ "yy_new_buffer",
+ "yy_scan_buffer",
+ "yy_scan_bytes",
+ "yy_scan_string",
+ "yy_set_bol",
+ "yy_set_interactive",
+ "yy_switch_to_buffer",
+ "yypush_buffer_state",
+ "yypop_buffer_state",
+ "yyensure_buffer_stack",
+ "yyalloc",
+ "yyconst",
+ "yyextra",
+ "yyfree",
+ "yyget_debug",
+ "yyget_extra",
+ "yyget_in",
+ "yyget_leng",
+ "yyget_lineno",
+ "yyget_lloc",
+ "yyget_lval",
+ "yyget_out",
+ "yyget_text",
+ "yyin",
+ "yyleng",
+ "yyless",
+ "yylex",
+ "yylex_destroy",
+ "yylex_init",
+ "yylex_init_extra",
+ "yylineno",
+ "yylloc",
+ "yylval",
+ "yymore",
+ "yyout",
+ "yyrealloc",
+ "yyrestart",
+ "yyset_debug",
+ "yyset_extra",
+ "yyset_in",
+ "yyset_lineno",
+ "yyset_lloc",
+ "yyset_lval",
+ "yyset_out",
+ "yytables_destroy",
+ "yytables_fload",
+ "yyterminate",
+ "yytext",
+ "yytext_ptr",
+ "yywrap",
+
+ /* must be null-terminated */
+ NULL};
+
+
+ for (i = 0; undef_list[i] != NULL; i++)
+ fprintf(header_out, "#undef %s\n", undef_list[i]);
+ }
+
+ /* undef any of the auto-generated symbols. */
+ for (i = 0; i < defs_buf.nelts; i++) {
- fprintf (header_out,
- "#endif /* !YY_HEADER_NO_UNDEFS */\n");
- fprintf (header_out, "\n");
- fprintf (header_out, "#undef %sIN_HEADER\n", prefix);
- fprintf (header_out, "#endif /* %sHEADER_H */\n", prefix);
-
- if (ferror (header_out))
- lerrsf (_("error creating header file %s"),
- headerfilename);
- fflush (header_out);
- fclose (header_out);
+ /* don't undef start conditions */
+ if (sclookup(((char **) defs_buf.elts)[i]) > 0)
+ continue;
+ fprintf(header_out, "#undef %s\n",
+ ((char **) defs_buf.elts)[i]);
+ }
+
+ fprintf(header_out,
+ "#endif /* !YY_HEADER_NO_UNDEFS */\n");
+ fprintf(header_out, "\n");
+ fprintf(header_out, "#undef %sIN_HEADER\n", prefix);
+ fprintf(header_out, "#endif /* %sHEADER_H */\n", prefix);
+
+ if (ferror(header_out))
+ lerrsf(_("error creating header file %s"),
+ headerfilename);
+ fflush(header_out);
+ fclose(header_out);
#endif
if (exit_status != 0 && outfile_created) {
- if (ferror (stdout))
- lerrsf (_("error writing output file %s"),
- outfilename);
+ if (ferror(stdout))
+ lerrsf(_("error writing output file %s"),
+ outfilename);
- else if ((_stdout_closed = 1) && fclose (stdout))
- lerrsf (_("error closing output file %s"),
- outfilename);
+ else if ((_stdout_closed = 1) && fclose(stdout))
+ lerrsf(_("error closing output file %s"),
+ outfilename);
- else if (unlink (outfilename))
- lerrsf (_("error deleting output file %s"),
- outfilename);
+ else if (unlink(outfilename))
+ lerrsf(_("error deleting output file %s"),
+ outfilename);
}
-
-
if (backing_up_report && backing_up_file) {
if (num_backing_up == 0)
- fprintf (backing_up_file, _("No backing up.\n"));
+ fprintf(backing_up_file, _("No backing up.\n"));
else if (fullspd || fulltbl)
- fprintf (backing_up_file,
- _
- ("%d backing up (non-accepting) states.\n"),
- num_backing_up);
+ fprintf(backing_up_file,
+ _
+ ("%d backing up (non-accepting) states.\n"),
+ num_backing_up);
else
- fprintf (backing_up_file,
- _("Compressed tables always back up.\n"));
+ fprintf(backing_up_file,
+ _("Compressed tables always back up.\n"));
- if (ferror (backing_up_file))
- lerrsf (_("error writing backup file %s"),
- backing_name);
+ if (ferror(backing_up_file))
+ lerrsf(_("error writing backup file %s"),
+ backing_name);
- else if (fclose (backing_up_file))
- lerrsf (_("error closing backup file %s"),
- backing_name);
+ else if (fclose(backing_up_file))
+ lerrsf(_("error closing backup file %s"),
+ backing_name);
}
-
if (printstats) {
- fprintf (stderr, _("%s version %s usage statistics:\n"),
- program_name, flex_version);
+ fprintf(stderr, _("%s version %s usage statistics:\n"),
+ program_name, flex_version);
- fprintf (stderr, _(" scanner options: -"));
+ fprintf(stderr, _(" scanner options: -"));
if (C_plus_plus)
- putc ('+', stderr);
+ putc('+', stderr);
if (backing_up_report)
- putc ('b', stderr);
+ putc('b', stderr);
if (ddebug)
- putc ('d', stderr);
+ putc('d', stderr);
if (sf_case_ins())
- putc ('i', stderr);
+ putc('i', stderr);
if (lex_compat)
- putc ('l', stderr);
+ putc('l', stderr);
if (posix_compat)
- putc ('X', stderr);
+ putc('X', stderr);
if (performance_report > 0)
- putc ('p', stderr);
+ putc('p', stderr);
if (performance_report > 1)
- putc ('p', stderr);
+ putc('p', stderr);
if (spprdflt)
- putc ('s', stderr);
+ putc('s', stderr);
if (reentrant)
- fputs ("--reentrant", stderr);
+ fputs("--reentrant", stderr);
if (bison_bridge_lval)
- fputs ("--bison-bridge", stderr);
+ fputs("--bison-bridge", stderr);
if (bison_bridge_lloc)
- fputs ("--bison-locations", stderr);
+ fputs("--bison-locations", stderr);
if (use_stdout)
- putc ('t', stderr);
+ putc('t', stderr);
if (printstats)
- putc ('v', stderr); /* always true! */
+ putc('v', stderr); /* always true! */
if (nowarn)
- putc ('w', stderr);
+ putc('w', stderr);
if (interactive == false)
- putc ('B', stderr);
+ putc('B', stderr);
if (interactive == true)
- putc ('I', stderr);
+ putc('I', stderr);
if (!gen_line_dirs)
- putc ('L', stderr);
+ putc('L', stderr);
if (trace)
- putc ('T', stderr);
+ putc('T', stderr);
if (csize == unspecified)
- /* We encountered an error fairly early on, so csize
+ /*
+ * We encountered an error fairly early on, so csize
* never got specified. Define it now, to prevent
* bogus table sizes being written out below.
*/
csize = 256;
if (csize == 128)
- putc ('7', stderr);
+ putc('7', stderr);
else
- putc ('8', stderr);
+ putc('8', stderr);
- fprintf (stderr, " -C");
+ fprintf(stderr, " -C");
if (long_align)
- putc ('a', stderr);
+ putc('a', stderr);
if (fulltbl)
- putc ('f', stderr);
+ putc('f', stderr);
if (fullspd)
- putc ('F', stderr);
+ putc('F', stderr);
if (useecs)
- putc ('e', stderr);
+ putc('e', stderr);
if (usemecs)
- putc ('m', stderr);
+ putc('m', stderr);
if (use_read)
- putc ('r', stderr);
+ putc('r', stderr);
if (did_outfilename)
- fprintf (stderr, " -o%s", outfilename);
+ fprintf(stderr, " -o%s", outfilename);
if (skelname)
- fprintf (stderr, " -S%s", skelname);
+ fprintf(stderr, " -S%s", skelname);
- if (strcmp (prefix, "yy"))
- fprintf (stderr, " -P%s", prefix);
+ if (strcmp(prefix, "yy"))
+ fprintf(stderr, " -P%s", prefix);
- putc ('\n', stderr);
+ putc('\n', stderr);
- fprintf (stderr, _(" %d/%d NFA states\n"),
- lastnfa, current_mns);
- fprintf (stderr, _(" %d/%d DFA states (%d words)\n"),
- lastdfa, current_max_dfas, totnst);
- fprintf (stderr, _(" %d rules\n"),
- num_rules + num_eof_rules -
- 1 /* - 1 for def. rule */ );
+ fprintf(stderr, _(" %d/%d NFA states\n"),
+ lastnfa, current_mns);
+ fprintf(stderr, _(" %d/%d DFA states (%d words)\n"),
+ lastdfa, current_max_dfas, totnst);
+ fprintf(stderr, _(" %d rules\n"),
+ num_rules + num_eof_rules -
+ 1 /* - 1 for def. rule */ );
if (num_backing_up == 0)
- fprintf (stderr, _(" No backing up\n"));
+ fprintf(stderr, _(" No backing up\n"));
else if (fullspd || fulltbl)
- fprintf (stderr,
- _
- (" %d backing-up (non-accepting) states\n"),
- num_backing_up);
+ fprintf(stderr,
+ _
+ (" %d backing-up (non-accepting) states\n"),
+ num_backing_up);
else
- fprintf (stderr,
- _
- (" Compressed tables always back-up\n"));
+ fprintf(stderr,
+ _
+ (" Compressed tables always back-up\n"));
if (bol_needed)
- fprintf (stderr,
- _(" Beginning-of-line patterns used\n"));
+ fprintf(stderr,
+ _(" Beginning-of-line patterns used\n"));
- fprintf (stderr, _(" %d/%d start conditions\n"), lastsc,
- current_max_scs);
- fprintf (stderr,
- _
- (" %d epsilon states, %d double epsilon states\n"),
- numeps, eps2);
+ fprintf(stderr, _(" %d/%d start conditions\n"), lastsc,
+ current_max_scs);
+ fprintf(stderr,
+ _
+ (" %d epsilon states, %d double epsilon states\n"),
+ numeps, eps2);
if (lastccl == 0)
- fprintf (stderr, _(" no character classes\n"));
+ fprintf(stderr, _(" no character classes\n"));
else
- fprintf (stderr,
- _
- (" %d/%d character classes needed %d/%d words of storage, %d reused\n"),
- lastccl, current_maxccls,
- cclmap[lastccl] + ccllen[lastccl],
- current_max_ccl_tbl_size, cclreuse);
-
- fprintf (stderr, _(" %d state/nextstate pairs created\n"),
- numsnpairs);
- fprintf (stderr,
- _(" %d/%d unique/duplicate transitions\n"),
- numuniq, numdup);
+ fprintf(stderr,
+ _
+ (" %d/%d character classes needed %d/%d words of storage, %d reused\n"),
+ lastccl, current_maxccls,
+ cclmap[lastccl] + ccllen[lastccl],
+ current_max_ccl_tbl_size, cclreuse);
+
+ fprintf(stderr, _(" %d state/nextstate pairs created\n"),
+ numsnpairs);
+ fprintf(stderr,
+ _(" %d/%d unique/duplicate transitions\n"),
+ numuniq, numdup);
if (fulltbl) {
tblsiz = lastdfa * numecs;
- fprintf (stderr, _(" %d table entries\n"),
- tblsiz);
- }
-
- else {
+ fprintf(stderr, _(" %d table entries\n"),
+ tblsiz);
+ } else {
tblsiz = 2 * (lastdfa + numtemps) + 2 * tblend;
- fprintf (stderr,
- _(" %d/%d base-def entries created\n"),
- lastdfa + numtemps, current_max_dfas);
- fprintf (stderr,
- _
- (" %d/%d (peak %d) nxt-chk entries created\n"),
- tblend, current_max_xpairs, peakpairs);
- fprintf (stderr,
- _
- (" %d/%d (peak %d) template nxt-chk entries created\n"),
- numtemps * nummecs,
- current_max_template_xpairs,
- numtemps * numecs);
- fprintf (stderr, _(" %d empty table entries\n"),
- nummt);
- fprintf (stderr, _(" %d protos created\n"),
- numprots);
- fprintf (stderr,
- _(" %d templates created, %d uses\n"),
- numtemps, tmpuses);
+ fprintf(stderr,
+ _(" %d/%d base-def entries created\n"),
+ lastdfa + numtemps, current_max_dfas);
+ fprintf(stderr,
+ _
+ (" %d/%d (peak %d) nxt-chk entries created\n"),
+ tblend, current_max_xpairs, peakpairs);
+ fprintf(stderr,
+ _
+ (" %d/%d (peak %d) template nxt-chk entries created\n"),
+ numtemps * nummecs,
+ current_max_template_xpairs,
+ numtemps * numecs);
+ fprintf(stderr, _(" %d empty table entries\n"),
+ nummt);
+ fprintf(stderr, _(" %d protos created\n"),
+ numprots);
+ fprintf(stderr,
+ _(" %d templates created, %d uses\n"),
+ numtemps, tmpuses);
}
if (useecs) {
tblsiz = tblsiz + csize;
- fprintf (stderr,
- _
- (" %d/%d equivalence classes created\n"),
- numecs, csize);
+ fprintf(stderr,
+ _
+ (" %d/%d equivalence classes created\n"),
+ numecs, csize);
}
-
if (usemecs) {
tblsiz = tblsiz + numecs;
- fprintf (stderr,
- _
- (" %d/%d meta-equivalence classes created\n"),
- nummecs, csize);
+ fprintf(stderr,
+ _
+ (" %d/%d meta-equivalence classes created\n"),
+ nummecs, csize);
}
-
- fprintf (stderr,
- _
- (" %d (%d saved) hash collisions, %d DFAs equal\n"),
- hshcol, hshsave, dfaeql);
- fprintf (stderr, _(" %d sets of reallocations needed\n"),
- num_reallocs);
- fprintf (stderr, _(" %d total table entries needed\n"),
- tblsiz);
+ fprintf(stderr,
+ _
+ (" %d (%d saved) hash collisions, %d DFAs equal\n"),
+ hshcol, hshsave, dfaeql);
+ fprintf(stderr, _(" %d sets of reallocations needed\n"),
+ num_reallocs);
+ fprintf(stderr, _(" %d total table entries needed\n"),
+ tblsiz);
}
-
- FLEX_EXIT (exit_status);
+ FLEX_EXIT(exit_status);
}
/* flexinit - initialize flex */
-void flexinit (argc, argv)
- int argc;
- char **argv;
+void
+flexinit(argc, argv)
+ int argc;
+ char **argv;
{
- int i, sawcmpflag, rv, optind;
- char *arg;
+ int i, sawcmpflag, rv, optind;
+ char *arg;
scanopt_t sopt;
printstats = syntaxerror = trace = spprdflt = false;
lex_compat = posix_compat = C_plus_plus = backing_up_report =
- ddebug = fulltbl = false;
+ ddebug = fulltbl = false;
fullspd = long_align = nowarn = yymore_used = continued_action =
- false;
+ false;
do_yylineno = yytext_is_array = in_rule = reject = do_stdinit =
- false;
+ false;
yymore_really_used = reject_really_used = unspecified;
interactive = csize = unspecified;
do_yywrap = gen_line_dirs = usemecs = useecs = true;
@@ -961,61 +945,62 @@ void flexinit (argc, argv)
tablesext = tablesverify = false;
gentables = true;
tablesfilename = tablesname = NULL;
- ansi_func_defs = ansi_func_protos = true;
+ ansi_func_defs = ansi_func_protos = true;
sawcmpflag = false;
/* Initialize dynamic array for holding the rule actions. */
action_size = 2048; /* default size of action array in bytes */
- action_array = allocate_character_array (action_size);
+ action_array = allocate_character_array(action_size);
defs1_offset = prolog_offset = action_offset = action_index = 0;
action_array[0] = '\0';
/* Initialize any buffers. */
- buf_init (&userdef_buf, sizeof (char)); /* one long string */
- buf_init (&defs_buf, sizeof (char *)); /* list of strings */
- buf_init (&yydmap_buf, sizeof (char)); /* one long string */
- buf_init (&top_buf, sizeof (char)); /* one long string */
+ buf_init(&userdef_buf, sizeof(char)); /* one long string */
+ buf_init(&defs_buf, sizeof(char *)); /* list of strings */
+ buf_init(&yydmap_buf, sizeof(char)); /* one long string */
+ buf_init(&top_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);
- }
+ {
+ 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);
+ }
- sf_init ();
+ sf_init();
- /* initialize regex lib */
- flex_init_regex();
+ /* initialize regex lib */
+ flex_init_regex();
/* Enable C++ if program name ends with '+'. */
- program_name = basename2 (argv[0], 0);
+ program_name = basename2(argv[0], 0);
if (program_name[0] != '\0' &&
- program_name[strlen (program_name) - 1] == '+')
+ program_name[strlen(program_name) - 1] == '+')
C_plus_plus = true;
/* read flags */
- sopt = scanopt_init (flexopts, argc, argv, 0);
+ sopt = scanopt_init(flexopts, argc, argv, 0);
if (!sopt) {
/* This will only happen when flexopts array is altered. */
- fprintf (stderr,
- _("Internal error. flexopts are malformed.\n"));
- FLEX_EXIT (1);
+ fprintf(stderr,
+ _("Internal error. flexopts are malformed.\n"));
+ FLEX_EXIT(1);
}
-
- while ((rv = scanopt (sopt, &arg, &optind)) != 0) {
+ while ((rv = scanopt(sopt, &arg, &optind)) != 0) {
if (rv < 0) {
- /* Scanopt has already printed an option-specific error message. */
- fprintf (stderr,
- _
- ("Try `%s --help' for more information.\n"),
- program_name);
- FLEX_EXIT (1);
+ /*
+ * Scanopt has already printed an option-specific
+ * error message.
+ */
+ fprintf(stderr,
+ _
+ ("Try `%s --help' for more information.\n"),
+ program_name);
+ FLEX_EXIT(1);
}
-
switch ((enum flexopt_flag_t) rv) {
case OPT_CPLUSPLUS:
C_plus_plus = true;
@@ -1039,7 +1024,6 @@ void flexinit (argc, argv)
fulltbl = false;
sawcmpflag = true;
}
-
for (i = 0; arg && arg[i] != '\0'; i++)
switch (arg[i]) {
case 'a':
@@ -1067,9 +1051,9 @@ void flexinit (argc, argv)
break;
default:
- lerrif (_
- ("unknown -C option '%c'"),
- (int) arg[i]);
+ lerrif(_
+ ("unknown -C option '%c'"),
+ (int) arg[i]);
break;
}
break;
@@ -1093,8 +1077,8 @@ void flexinit (argc, argv)
break;
case OPT_HELP:
- usage ();
- FLEX_EXIT (0);
+ usage();
+ FLEX_EXIT(0);
case OPT_INTERACTIVE:
interactive = true;
@@ -1112,17 +1096,17 @@ void flexinit (argc, argv)
posix_compat = true;
break;
- case OPT_PREPROC_LEVEL:
- preproc_level = strtol(arg,NULL,0);
- break;
+ case OPT_PREPROC_LEVEL:
+ preproc_level = strtol(arg, NULL, 0);
+ break;
case OPT_MAIN:
- buf_strdefine (&userdef_buf, "YY_MAIN", "1");
+ buf_strdefine(&userdef_buf, "YY_MAIN", "1");
do_yywrap = false;
break;
case OPT_NO_MAIN:
- buf_strdefine (&userdef_buf, "YY_MAIN", "0");
+ buf_strdefine(&userdef_buf, "YY_MAIN", "0");
break;
case OPT_NO_LINE:
@@ -1175,8 +1159,8 @@ void flexinit (argc, argv)
break;
case OPT_NO_UNISTD_H:
- //buf_strdefine (&userdef_buf, "YY_NO_UNISTD_H", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_NO_UNISTD_H",0);
+ //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:
@@ -1197,8 +1181,8 @@ void flexinit (argc, argv)
break;
case OPT_VERSION:
- printf (_("%s %s\n"), program_name, flex_version);
- FLEX_EXIT (0);
+ printf(_("%s %s\n"), program_name, flex_version);
+ FLEX_EXIT(0);
case OPT_WARN:
nowarn = false;
@@ -1225,11 +1209,11 @@ void flexinit (argc, argv)
break;
case OPT_ALWAYS_INTERACTIVE:
- buf_m4_define (&m4defs_buf, "M4_YY_ALWAYS_INTERACTIVE", 0);
+ buf_m4_define(&m4defs_buf, "M4_YY_ALWAYS_INTERACTIVE", 0);
break;
case OPT_NEVER_INTERACTIVE:
- buf_m4_define( &m4defs_buf, "M4_YY_NEVER_INTERACTIVE", 0);
+ buf_m4_define(&m4defs_buf, "M4_YY_NEVER_INTERACTIVE", 0);
break;
case OPT_ARRAY:
@@ -1263,24 +1247,23 @@ void flexinit (argc, argv)
case OPT_PREPROCDEFINE:
{
/* arg is "symbol" or "symbol=definition". */
- char *def;
+ char *def;
for (def = arg;
- *def != '\0' && *def != '='; ++def) ;
+ *def != '\0' && *def != '='; ++def);
- buf_strappend (&userdef_buf, "#define ");
+ buf_strappend(&userdef_buf, "#define ");
if (*def == '\0') {
- buf_strappend (&userdef_buf, arg);
- buf_strappend (&userdef_buf,
- " 1\n");
- }
- else {
- buf_strnappend (&userdef_buf, arg,
- def - arg);
- buf_strappend (&userdef_buf, " ");
- buf_strappend (&userdef_buf,
- def + 1);
- buf_strappend (&userdef_buf, "\n");
+ buf_strappend(&userdef_buf, arg);
+ buf_strappend(&userdef_buf,
+ " 1\n");
+ } else {
+ buf_strnappend(&userdef_buf, arg,
+ def - arg);
+ buf_strappend(&userdef_buf, " ");
+ buf_strappend(&userdef_buf,
+ def + 1);
+ buf_strappend(&userdef_buf, "\n");
}
}
break;
@@ -1290,8 +1273,8 @@ void flexinit (argc, argv)
break;
case OPT_STACK:
- //buf_strdefine (&userdef_buf, "YY_STACK_USED", "1");
- buf_m4_define( &m4defs_buf, "M4_YY_STACK_USED",0);
+ //buf_strdefine(&userdef_buf, "YY_STACK_USED", "1");
+ buf_m4_define(&m4defs_buf, "M4_YY_STACK_USED", 0);
break;
case OPT_STDINIT:
@@ -1338,113 +1321,113 @@ 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_DEFS:
+ ansi_func_defs = false;
+ break;
- case OPT_NO_ANSI_FUNC_PROTOS:
- ansi_func_protos = 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_m4_define( &m4defs_buf, "M4_YY_NO_PUSH_STATE",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_POP_STATE",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_TOP_STATE",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_UNPUT",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BUFFER",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BYTES",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_STRING",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_GET_EXTRA",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_SET_EXTRA",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_GET_LENG",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_GET_TEXT",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_GET_LINENO",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_SET_LINENO",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_GET_IN",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_SET_IN",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_GET_OUT",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_SET_OUT",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_GET_LVAL",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_SET_LVAL",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_GET_LLOC",0);
+ //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_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0);
+ //buf_strdefine(&userdef_buf, "YY_NO_SET_LLOC", "1");
+ buf_m4_define(&m4defs_buf, "M4_YY_NO_SET_LLOC", 0);
break;
} /* switch */
} /* while scanopt() */
- scanopt_destroy (sopt);
+ scanopt_destroy(sopt);
num_input_files = argc - optind;
input_files = argv + optind;
- set_input_file (num_input_files > 0 ? input_files[0] : NULL);
+ set_input_file(num_input_files > 0 ? input_files[0] : NULL);
lastccl = lastsc = lastdfa = lastnfa = 0;
num_rules = num_eof_rules = default_rule = 0;
numas = numsnpairs = tmpuses = 0;
numecs = numeps = eps2 = num_reallocs = hshcol = dfaeql = totnst =
- 0;
+ 0;
numuniq = numdup = hshsave = eofseen = datapos = dataline = 0;
num_backing_up = onesp = numprots = 0;
variable_trailing_context_rules = bol_needed = false;
@@ -1452,63 +1435,67 @@ void flexinit (argc, argv)
linenum = sectnum = 1;
firstprot = NIL;
- /* Used in mkprot() so that the first proto goes in slot 1
- * of the proto queue.
+ /*
+ * Used in mkprot() so that the first proto goes in slot 1 of the
+ * proto queue.
*/
lastprot = 1;
- set_up_initial_allocations ();
+ set_up_initial_allocations();
}
/* readin - read in the rules section of the input file(s) */
-void readin ()
+void
+readin()
{
static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;";
static char yy_nostdinit[] =
- "FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;";
+ "FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;";
- line_directive_out ((FILE *) 0, 1);
+ line_directive_out((FILE *) 0, 1);
- if (yyparse ()) {
- pinpoint_message (_("fatal parse error"));
- flexend (1);
+ if (yyparse()) {
+ pinpoint_message(_("fatal parse error"));
+ flexend(1);
}
-
if (syntaxerror)
- flexend (1);
-
- /* If the user explicitly requested posix compatibility by specifing the
- * posix-compat option, then we check for conflicting options. However, if
- * the POSIXLY_CORRECT variable is set, then we quietly make flex as
- * posix-compatible as possible. This is the recommended behavior
- * according to the GNU Coding Standards.
- *
- * Note: The posix option was added to flex to provide the posix behavior
- * of the repeat operator in regular expressions, e.g., `ab{3}'
+ flexend(1);
+
+ /*
+ * If the user explicitly requested posix compatibility by specifing
+ * the posix-compat option, then we check for conflicting options.
+ * However, if the POSIXLY_CORRECT variable is set, then we quietly
+ * make flex as posix-compatible as possible. This is the
+ * recommended behavior according to the GNU Coding Standards.
+ *
+ * Note: The posix option was added to flex to provide the posix
+ * behavior of the repeat operator in regular expressions, e.g.,
+ * `ab{3}'
*/
if (posix_compat) {
- /* TODO: This is where we try to make flex behave according to
- * posiz, AND check for conflicting options. How far should we go
- * with this? Should we disable all the neat-o flex features?
+ /*
+ * TODO: This is where we try to make flex behave according
+ * to posiz, AND check for conflicting options. How far
+ * should we go with this? Should we disable all the neat-o
+ * flex features?
+ */
+ /*
+ * Update: Estes says no, since other flex features don't
+ * violate posix.
*/
- /* Update: Estes says no, since other flex features don't violate posix. */
}
-
- if (getenv ("POSIXLY_CORRECT")) {
+ if (getenv("POSIXLY_CORRECT")) {
posix_compat = true;
}
-
if (backing_up_report) {
- backing_up_file = fopen (backing_name, "w");
+ backing_up_file = fopen(backing_name, "w");
if (backing_up_file == NULL)
- lerrsf (_
- ("could not create backing-up info file %s"),
- backing_name);
- }
-
- else
+ lerrsf(_
+ ("could not create backing-up info file %s"),
+ backing_name);
+ } else
backing_up_file = NULL;
if (yymore_really_used == true)
@@ -1523,43 +1510,38 @@ void readin ()
if (performance_report > 0) {
if (lex_compat) {
- fprintf (stderr,
- _
- ("-l AT&T lex compatibility option entails a large performance penalty\n"));
- fprintf (stderr,
- _
- (" and may be the actual source of other reported performance penalties\n"));
+ fprintf(stderr,
+ _
+ ("-l AT&T lex compatibility option entails a large performance penalty\n"));
+ fprintf(stderr,
+ _
+ (" and may be the actual source of other reported performance penalties\n"));
+ } else if (do_yylineno) {
+ fprintf(stderr,
+ _
+ ("%%option yylineno entails a performance penalty ONLY on rules that can match newline characters\n"));
}
-
- else if (do_yylineno) {
- fprintf (stderr,
- _
- ("%%option yylineno entails a performance penalty ONLY on rules that can match newline characters\n"));
- }
-
if (performance_report > 1) {
if (interactive)
- fprintf (stderr,
- _
- ("-I (interactive) entails a minor performance penalty\n"));
+ fprintf(stderr,
+ _
+ ("-I (interactive) entails a minor performance penalty\n"));
if (yymore_used)
- fprintf (stderr,
- _
- ("yymore() entails a minor performance penalty\n"));
+ fprintf(stderr,
+ _
+ ("yymore() entails a minor performance penalty\n"));
}
-
if (reject)
- fprintf (stderr,
- _
- ("REJECT entails a large performance penalty\n"));
+ fprintf(stderr,
+ _
+ ("REJECT entails a large performance penalty\n"));
if (variable_trailing_context_rules)
- fprintf (stderr,
- _
- ("Variable trailing context rules entail a large performance penalty\n"));
+ fprintf(stderr,
+ _
+ ("Variable trailing context rules entail a large performance penalty\n"));
}
-
if (reject)
real_reject = true;
@@ -1568,206 +1550,196 @@ void readin ()
if ((fulltbl || fullspd) && reject) {
if (real_reject)
- flexerror (_
- ("REJECT cannot be used with -f or -F"));
+ flexerror(_
+ ("REJECT cannot be used with -f or -F"));
else if (do_yylineno)
- flexerror (_
- ("%option yylineno cannot be used with REJECT"));
+ flexerror(_
+ ("%option yylineno cannot be used with REJECT"));
else
- flexerror (_
- ("variable trailing context rules cannot be used with -f or -F"));
+ flexerror(_
+ ("variable trailing context rules cannot be used with -f or -F"));
+ }
+ if (reject) {
+ out_m4_define("M4_YY_USES_REJECT", NULL);
+ //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) {
if (!C_plus_plus)
- if (reentrant)
- outn ("\n#define yywrap(yyscanner) 1");
- else
- outn ("\n#define yywrap() 1");
- outn ("#define YY_SKIP_YYWRAP");
+ if (reentrant)
+ outn("\n#define yywrap(yyscanner) 1");
+ else
+ outn("\n#define yywrap() 1");
+ outn("#define YY_SKIP_YYWRAP");
}
-
if (ddebug)
- outn ("\n#define FLEX_DEBUG");
+ outn("\n#define FLEX_DEBUG");
- OUT_BEGIN_CODE ();
+ OUT_BEGIN_CODE();
if (csize == 256)
- outn ("typedef unsigned char YY_CHAR;");
+ outn("typedef unsigned char YY_CHAR;");
else
- outn ("typedef char YY_CHAR;");
- OUT_END_CODE ();
+ outn("typedef char YY_CHAR;");
+ OUT_END_CODE();
if (C_plus_plus) {
- outn ("#define yytext_ptr yytext");
+ outn("#define yytext_ptr yytext");
if (interactive)
- outn ("#define YY_INTERACTIVE");
- }
-
- else {
- OUT_BEGIN_CODE ();
+ outn("#define YY_INTERACTIVE");
+ } else {
+ OUT_BEGIN_CODE();
/* In reentrant scanner, stdinit is handled in flex.skl. */
if (do_stdinit) {
- if (reentrant){
- outn ("#ifdef VMS");
- outn ("#ifdef __VMS_POSIX");
- outn ("#define YY_STDINIT");
- outn ("#endif");
- outn ("#else");
- outn ("#define YY_STDINIT");
- outn ("#endif");
+ 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);
- outn ("#else");
- outn (yy_stdinit);
- outn ("#endif");
- outn ("#else");
- outn (yy_stdinit);
- outn ("#endif");
+ outn("#ifdef VMS");
+ outn("#ifndef __VMS_POSIX");
+ outn(yy_nostdinit);
+ outn("#else");
+ outn(yy_stdinit);
+ outn("#endif");
+ outn("#else");
+ outn(yy_stdinit);
+ outn("#endif");
} else {
- if(!reentrant)
- outn (yy_nostdinit);
+ if (!reentrant)
+ outn(yy_nostdinit);
}
- OUT_END_CODE ();
+ OUT_END_CODE();
}
- OUT_BEGIN_CODE ();
+ OUT_BEGIN_CODE();
if (fullspd)
- outn ("typedef yyconst struct yy_trans_info *yy_state_type;");
+ outn("typedef yyconst struct yy_trans_info *yy_state_type;");
else if (!C_plus_plus)
- outn ("typedef int yy_state_type;");
- OUT_END_CODE ();
+ outn("typedef int yy_state_type;");
+ OUT_END_CODE();
if (lex_compat)
- outn ("#define YY_FLEX_LEX_COMPAT");
+ outn("#define YY_FLEX_LEX_COMPAT");
if (!C_plus_plus && !reentrant) {
- outn ("extern int yylineno;");
- OUT_BEGIN_CODE ();
- outn ("int yylineno = 1;");
- OUT_END_CODE ();
+ outn("extern int yylineno;");
+ OUT_BEGIN_CODE();
+ outn("int yylineno = 1;");
+ OUT_END_CODE();
}
-
if (C_plus_plus) {
- outn ("\n#include <FlexLexer.h>");
+ outn("\n#include <FlexLexer.h>");
- if (!do_yywrap) {
+ if (!do_yywrap) {
outn("\nint yyFlexLexer::yywrap() { return 1; }");
}
-
if (yyclass) {
- outn ("int yyFlexLexer::yylex()");
- outn ("\t{");
- outn ("\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );");
- outn ("\treturn 0;");
- outn ("\t}");
-
- out_str ("\n#define YY_DECL int %s::yylex()\n",
- yyclass);
+ outn("int yyFlexLexer::yylex()");
+ outn("\t{");
+ outn("\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );");
+ outn("\treturn 0;");
+ outn("\t}");
+
+ out_str("\n#define YY_DECL int %s::yylex()\n",
+ yyclass);
}
- }
+ } else {
- else {
-
- /* Watch out: yytext_ptr is a variable when yytext is an array,
- * but it's a macro when yytext is a pointer.
+ /*
+ * Watch out: yytext_ptr is a variable when yytext is an
+ * array, but it's a macro when yytext is a pointer.
*/
if (yytext_is_array) {
if (!reentrant)
- outn ("extern char yytext[];\n");
- }
- else {
+ outn("extern char yytext[];\n");
+ } else {
if (reentrant) {
- outn ("#define yytext_ptr yytext_r");
- }
- else {
- outn ("extern char *yytext;");
- outn ("#define yytext_ptr yytext");
+ outn("#define yytext_ptr yytext_r");
+ } else {
+ outn("extern char *yytext;");
+ outn("#define yytext_ptr yytext");
}
}
if (yyclass)
- flexerror (_
- ("%option yyclass only meaningful for C++ scanners"));
+ flexerror(_
+ ("%option yyclass only meaningful for C++ scanners"));
}
if (useecs)
- numecs = cre8ecs (nextecm, ecgroup, csize);
+ numecs = cre8ecs(nextecm, ecgroup, csize);
else
numecs = csize;
/* Now map the equivalence class for NUL to its expected place. */
ecgroup[0] = ecgroup[csize];
- NUL_ec = ABS (ecgroup[0]);
+ NUL_ec = ABS(ecgroup[0]);
if (useecs)
- ccl2ecl ();
+ ccl2ecl();
}
/* set_up_initial_allocations - allocate memory for internal tables */
-void set_up_initial_allocations ()
+void
+set_up_initial_allocations()
{
maximum_mns = (long_align ? MAXIMUM_MNS_LONG : MAXIMUM_MNS);
current_mns = INITIAL_MNS;
- firstst = allocate_integer_array (current_mns);
- lastst = allocate_integer_array (current_mns);
- finalst = allocate_integer_array (current_mns);
- transchar = allocate_integer_array (current_mns);
- trans1 = allocate_integer_array (current_mns);
- trans2 = allocate_integer_array (current_mns);
- accptnum = allocate_integer_array (current_mns);
- assoc_rule = allocate_integer_array (current_mns);
- state_type = allocate_integer_array (current_mns);
+ firstst = allocate_integer_array(current_mns);
+ lastst = allocate_integer_array(current_mns);
+ finalst = allocate_integer_array(current_mns);
+ transchar = allocate_integer_array(current_mns);
+ trans1 = allocate_integer_array(current_mns);
+ trans2 = allocate_integer_array(current_mns);
+ accptnum = allocate_integer_array(current_mns);
+ assoc_rule = allocate_integer_array(current_mns);
+ state_type = allocate_integer_array(current_mns);
current_max_rules = INITIAL_MAX_RULES;
- rule_type = allocate_integer_array (current_max_rules);
- rule_linenum = allocate_integer_array (current_max_rules);
- rule_useful = allocate_integer_array (current_max_rules);
- rule_has_nl = allocate_bool_array (current_max_rules);
+ rule_type = allocate_integer_array(current_max_rules);
+ rule_linenum = allocate_integer_array(current_max_rules);
+ rule_useful = allocate_integer_array(current_max_rules);
+ rule_has_nl = allocate_bool_array(current_max_rules);
current_max_scs = INITIAL_MAX_SCS;
- scset = allocate_integer_array (current_max_scs);
- scbol = allocate_integer_array (current_max_scs);
- scxclu = allocate_integer_array (current_max_scs);
- sceof = allocate_integer_array (current_max_scs);
- scname = allocate_char_ptr_array (current_max_scs);
+ scset = allocate_integer_array(current_max_scs);
+ scbol = allocate_integer_array(current_max_scs);
+ scxclu = allocate_integer_array(current_max_scs);
+ sceof = allocate_integer_array(current_max_scs);
+ scname = allocate_char_ptr_array(current_max_scs);
current_maxccls = INITIAL_MAX_CCLS;
- cclmap = allocate_integer_array (current_maxccls);
- ccllen = allocate_integer_array (current_maxccls);
- cclng = allocate_integer_array (current_maxccls);
- ccl_has_nl = allocate_bool_array (current_maxccls);
+ cclmap = allocate_integer_array(current_maxccls);
+ ccllen = allocate_integer_array(current_maxccls);
+ cclng = allocate_integer_array(current_maxccls);
+ ccl_has_nl = allocate_bool_array(current_maxccls);
current_max_ccl_tbl_size = INITIAL_MAX_CCL_TBL_SIZE;
- ccltbl = allocate_Character_array (current_max_ccl_tbl_size);
+ ccltbl = allocate_Character_array(current_max_ccl_tbl_size);
current_max_dfa_size = INITIAL_MAX_DFA_SIZE;
current_max_xpairs = INITIAL_MAX_XPAIRS;
- nxt = allocate_integer_array (current_max_xpairs);
- chk = allocate_integer_array (current_max_xpairs);
+ nxt = allocate_integer_array(current_max_xpairs);
+ chk = allocate_integer_array(current_max_xpairs);
current_max_template_xpairs = INITIAL_MAX_TEMPLATE_XPAIRS;
- tnxt = allocate_integer_array (current_max_template_xpairs);
+ tnxt = allocate_integer_array(current_max_template_xpairs);
current_max_dfas = INITIAL_MAX_DFAS;
- base = allocate_integer_array (current_max_dfas);
- def = allocate_integer_array (current_max_dfas);
- dfasiz = allocate_integer_array (current_max_dfas);
- accsiz = allocate_integer_array (current_max_dfas);
- dhash = allocate_integer_array (current_max_dfas);
- dss = allocate_int_ptr_array (current_max_dfas);
- dfaacc = allocate_dfaacc_union (current_max_dfas);
+ base = allocate_integer_array(current_max_dfas);
+ def = allocate_integer_array(current_max_dfas);
+ dfasiz = allocate_integer_array(current_max_dfas);
+ accsiz = allocate_integer_array(current_max_dfas);
+ dhash = allocate_integer_array(current_max_dfas);
+ dss = allocate_int_ptr_array(current_max_dfas);
+ dfaacc = allocate_dfaacc_union(current_max_dfas);
nultrans = (int *) 0;
}
@@ -1775,11 +1747,12 @@ void set_up_initial_allocations ()
/* extracts basename from path, optionally stripping the extension "\.*"
* (same concept as /bin/sh `basename`, but different handling of extension). */
-static char *basename2 (path, strip_ext)
- char *path;
- int strip_ext; /* boolean */
+static char *
+basename2(path, strip_ext)
+ char *path;
+ int strip_ext; /* boolean */
{
- char *b, *e = 0;
+ char *b, *e = 0;
b = path;
for (b = path; *path; path++)
@@ -1793,72 +1766,72 @@ static char *basename2 (path, strip_ext)
return b;
}
-void usage ()
+void
+usage()
{
- FILE *f = stdout;
+ FILE *f = stdout;
if (!did_outfilename) {
- snprintf (outfile_path, sizeof(outfile_path), outfile_template,
- prefix, C_plus_plus ? "cc" : "c");
+ snprintf(outfile_path, sizeof(outfile_path), outfile_template,
+ prefix, C_plus_plus ? "cc" : "c");
outfilename = outfile_path;
}
-
- fprintf (f, _("Usage: %s [OPTIONS] [FILE]...\n"), program_name);
- fprintf (f,
- _
- ("Generates programs that perform pattern-matching on text.\n"
- "\n" "Table Compression:\n"
- " -Ca, --align trade off larger tables for better memory alignment\n"
- " -Ce, --ecs construct equivalence classes\n"
- " -Cf do not compress tables; use -f representation\n"
- " -CF do not compress tables; use -F representation\n"
- " -Cm, --meta-ecs construct meta-equivalence classes\n"
- " -Cr, --read use read() instead of stdio for scanner input\n"
- " -f, --full generate fast, large scanner. Same as -Cfr\n"
- " -F, --fast use alternate table representation. Same as -CFr\n"
- " -Cem default compression (same as --ecs --meta-ecs)\n"
- "\n" "Debugging:\n"
- " -d, --debug enable debug mode in scanner\n"
- " -b, --backup write backing-up information to %s\n"
- " -p, --perf-report write performance report to stderr\n"
- " -s, --nodefault suppress default rule to ECHO unmatched text\n"
- " -T, --trace %s should run in trace mode\n"
- " -w, --nowarn do not generate warnings\n"
- " -v, --verbose write summary of scanner statistics to stdout\n"
- "\n" "Files:\n"
- " -o, --outfile=FILE specify output filename\n"
- " -S, --skel=FILE specify skeleton file\n"
- " -t, --stdout write scanner on stdout instead of %s\n"
- " --yyclass=NAME name of C++ class\n"
- " --header-file=FILE create a C header file in addition to the scanner\n"
- " --tables-file[=FILE] write tables to FILE\n" "\n"
- "Scanner behavior:\n"
- " -7, --7bit generate 7-bit scanner\n"
- " -8, --8bit generate 8-bit scanner\n"
- " -B, --batch generate batch scanner (opposite of -I)\n"
- " -i, --case-insensitive ignore case in patterns\n"
- " -l, --lex-compat maximal compatibility with original lex\n"
- " -X, --posix-compat maximal compatibility with POSIX lex\n"
- " -I, --interactive generate interactive scanner (opposite of -B)\n"
- " --yylineno track line count in yylineno\n"
- "\n" "Generated code:\n"
- " -+, --c++ generate C++ scanner class\n"
- " -Dmacro[=defn] #define macro defn (default defn is '1')\n"
- " -L, --noline suppress #line directives in scanner\n"
- " -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"
- " -n do-nothing POSIX option\n"
- " -?\n"
- " -h, --help produce this help message\n"
- " -V, --version report %s version\n"),
- backing_name, program_name, outfile_path, program_name);
+ fprintf(f, _("Usage: %s [OPTIONS] [FILE]...\n"), program_name);
+ fprintf(f,
+ _
+ ("Generates programs that perform pattern-matching on text.\n"
+ "\n" "Table Compression:\n"
+ " -Ca, --align trade off larger tables for better memory alignment\n"
+ " -Ce, --ecs construct equivalence classes\n"
+ " -Cf do not compress tables; use -f representation\n"
+ " -CF do not compress tables; use -F representation\n"
+ " -Cm, --meta-ecs construct meta-equivalence classes\n"
+ " -Cr, --read use read() instead of stdio for scanner input\n"
+ " -f, --full generate fast, large scanner. Same as -Cfr\n"
+ " -F, --fast use alternate table representation. Same as -CFr\n"
+ " -Cem default compression (same as --ecs --meta-ecs)\n"
+ "\n" "Debugging:\n"
+ " -d, --debug enable debug mode in scanner\n"
+ " -b, --backup write backing-up information to %s\n"
+ " -p, --perf-report write performance report to stderr\n"
+ " -s, --nodefault suppress default rule to ECHO unmatched text\n"
+ " -T, --trace %s should run in trace mode\n"
+ " -w, --nowarn do not generate warnings\n"
+ " -v, --verbose write summary of scanner statistics to stdout\n"
+ "\n" "Files:\n"
+ " -o, --outfile=FILE specify output filename\n"
+ " -S, --skel=FILE specify skeleton file\n"
+ " -t, --stdout write scanner on stdout instead of %s\n"
+ " --yyclass=NAME name of C++ class\n"
+ " --header-file=FILE create a C header file in addition to the scanner\n"
+ " --tables-file[=FILE] write tables to FILE\n" "\n"
+ "Scanner behavior:\n"
+ " -7, --7bit generate 7-bit scanner\n"
+ " -8, --8bit generate 8-bit scanner\n"
+ " -B, --batch generate batch scanner (opposite of -I)\n"
+ " -i, --case-insensitive ignore case in patterns\n"
+ " -l, --lex-compat maximal compatibility with original lex\n"
+ " -X, --posix-compat maximal compatibility with POSIX lex\n"
+ " -I, --interactive generate interactive scanner (opposite of -B)\n"
+ " --yylineno track line count in yylineno\n"
+ "\n" "Generated code:\n"
+ " -+, --c++ generate C++ scanner class\n"
+ " -Dmacro[=defn] #define macro defn (default defn is '1')\n"
+ " -L, --noline suppress #line directives in scanner\n"
+ " -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"
+ " -n do-nothing POSIX option\n"
+ " -?\n"
+ " -h, --help produce this help message\n"
+ " -V, --version report %s version\n"),
+ backing_name, program_name, outfile_path, program_name);
}
diff --git a/usr.bin/lex/misc.c b/usr.bin/lex/misc.c
index 0dddc3aace7..539be6d3277 100644
--- a/usr.bin/lex/misc.c
+++ b/usr.bin/lex/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.15 2015/11/19 19:43:40 tedu Exp $ */
+/* $OpenBSD: misc.c,v 1.16 2015/11/19 22:52:40 tedu Exp $ */
/* misc - miscellaneous flex routines */
@@ -54,64 +54,66 @@
/* we allow the skeleton to push and pop. */
struct sko_state {
- bool dc; /**< do_copy */
+ bool dc; /**< do_copy */
};
-static struct sko_state *sko_stack=0;
-static int sko_len=0,sko_sz=0;
-static void sko_push(bool dc)
+static struct sko_state *sko_stack = 0;
+static int sko_len = 0, sko_sz = 0;
+static void
+sko_push(bool dc)
{
- if(!sko_stack){
- sko_sz = 1;
- sko_stack = (struct sko_state*)flex_alloc(sizeof(struct sko_state)*sko_sz);
- if (!sko_stack)
- flexfatal(_("allocation of sko_stack failed"));
- sko_len = 0;
- }
- if(sko_len >= sko_sz){
- sko_sz *= 2;
- sko_stack = (struct sko_state*)flex_realloc(sko_stack,sizeof(struct sko_state)*sko_sz);
- }
-
- /* initialize to zero and push */
- sko_stack[sko_len].dc = dc;
- sko_len++;
+ if (!sko_stack) {
+ sko_sz = 1;
+ sko_stack = (struct sko_state *) flex_alloc(sizeof(struct sko_state) * sko_sz);
+ if (!sko_stack)
+ flexfatal(_("allocation of sko_stack failed"));
+ sko_len = 0;
+ }
+ if (sko_len >= sko_sz) {
+ sko_sz *= 2;
+ sko_stack = (struct sko_state *) flex_realloc(sko_stack, sizeof(struct sko_state) * sko_sz);
+ }
+ /* initialize to zero and push */
+ sko_stack[sko_len].dc = dc;
+ sko_len++;
}
-static void sko_peek(bool *dc)
+static void
+sko_peek(bool * dc)
{
- if(sko_len <= 0)
- flex_die("peek attempt when sko stack is empty");
- if(dc)
- *dc = sko_stack[sko_len-1].dc;
+ if (sko_len <= 0)
+ flex_die("peek attempt when sko stack is empty");
+ if (dc)
+ *dc = sko_stack[sko_len - 1].dc;
}
-static void sko_pop(bool* dc)
+static void
+sko_pop(bool * dc)
{
- sko_peek(dc);
- sko_len--;
- if(sko_len < 0)
- flex_die("popped too many times in skeleton.");
+ sko_peek(dc);
+ sko_len--;
+ if (sko_len < 0)
+ flex_die("popped too many times in skeleton.");
}
/* Append "#define defname value\n" to the running buffer. */
-void action_define (defname, value)
- const char *defname;
- int value;
+void
+action_define(defname, value)
+ const char *defname;
+ int value;
{
- char buf[MAXLINE];
- char *cpy;
+ char buf[MAXLINE];
+ char *cpy;
- if ((int) strlen (defname) > MAXLINE / 2) {
- format_pinpoint_message (_
- ("name \"%s\" ridiculously long"),
- defname);
+ if ((int) strlen(defname) > MAXLINE / 2) {
+ format_pinpoint_message(_
+ ("name \"%s\" ridiculously long"),
+ defname);
return;
}
-
- snprintf (buf, sizeof(buf), "#define %s %d\n", defname, value);
- add_action (buf);
+ snprintf(buf, sizeof(buf), "#define %s %d\n", defname, value);
+ add_action(buf);
/* track #defines so we can undef them when we're done. */
- cpy = copy_string (defname);
- buf_append (&defs_buf, &cpy, 1);
+ cpy = copy_string(defname);
+ buf_append(&defs_buf, &cpy, 1);
}
@@ -119,34 +121,36 @@ void action_define (defname, value)
* @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)
+void
+action_m4_define(const char *defname, const char *value)
{
- char buf[MAXLINE];
+ char buf[MAXLINE];
- flexfatal ("DO NOT USE THIS FUNCTION!");
+ flexfatal("DO NOT USE THIS FUNCTION!");
- if ((int) strlen (defname) > MAXLINE / 2) {
- format_pinpoint_message (_
- ("name \"%s\" ridiculously long"),
- defname);
+ if ((int) strlen(defname) > MAXLINE / 2) {
+ format_pinpoint_message(_
+ ("name \"%s\" ridiculously long"),
+ defname);
return;
}
-
- snprintf (buf, sizeof(buf), "m4_define([[%s]],[[%s]])m4_dnl\n", defname, value?value:"");
- add_action (buf);
+ snprintf(buf, sizeof(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)
- const char *new_text;
+void
+add_action(new_text)
+ const char *new_text;
{
- int len = strlen (new_text);
+ int len = strlen(new_text);
while (len + action_index >= action_size - 10 /* slop */ ) {
- int new_size = action_size * 2;
+ int new_size = action_size * 2;
if (new_size <= 0)
- /* Increase just a little, to try to avoid overflow
+ /*
+ * Increase just a little, to try to avoid overflow
* on 16-bit machines.
*/
action_size += action_size / 8;
@@ -154,12 +158,12 @@ void add_action (new_text)
action_size = new_size;
action_array =
- reallocate_character_array (action_array,
- action_size);
+ reallocate_character_array(action_array,
+ action_size);
}
- strlcpy ( &action_array[action_index], new_text,
- action_size - action_index );
+ strlcpy(&action_array[action_index], new_text,
+ action_size - action_index);
action_index += len;
}
@@ -167,17 +171,18 @@ void add_action (new_text)
/* allocate_array - allocate memory for an integer array of the given size */
-void *allocate_array (size, element_size)
- int size;
- size_t element_size;
+void *
+allocate_array(size, element_size)
+ int size;
+ size_t element_size;
{
void *mem;
- size_t num_bytes = element_size * size;
+ size_t num_bytes = element_size * size;
- mem = flex_alloc (num_bytes);
+ mem = flex_alloc(num_bytes);
if (!mem)
- flexfatal (_
- ("memory allocation failed in allocate_array()"));
+ flexfatal(_
+ ("memory allocation failed in allocate_array()"));
return mem;
}
@@ -185,11 +190,12 @@ void *allocate_array (size, element_size)
/* all_lower - true if a string is all lower-case */
-int all_lower (str)
- char *str;
+int
+all_lower(str)
+ char *str;
{
while (*str) {
- if (!isascii ((Char) * str) || !islower ((Char) * str))
+ if (!isascii((Char) * str) || !islower((Char) * str))
return 0;
++str;
}
@@ -200,11 +206,12 @@ int all_lower (str)
/* all_upper - true if a string is all upper-case */
-int all_upper (str)
- char *str;
+int
+all_upper(str)
+ char *str;
{
while (*str) {
- if (!isascii ((Char) * str) || !isupper ((Char) * str))
+ if (!isascii((Char) * str) || !isupper((Char) * str))
return 0;
++str;
}
@@ -215,9 +222,10 @@ int all_upper (str)
/* intcmp - compares two integers for use by qsort. */
-int intcmp (const void *a, const void *b)
+int
+intcmp(const void *a, const void *b)
{
- return *(const int *) a - *(const int *) b;
+ return *(const int *) a - *(const int *) b;
}
@@ -226,51 +234,54 @@ int intcmp (const void *a, const void *b)
* and exits.
*/
-void check_char (c)
- int c;
+void
+check_char(c)
+ int c;
{
if (c >= CSIZE)
- lerrsf (_("bad character '%s' detected in check_char()"),
- readable_form (c));
+ lerrsf(_("bad character '%s' detected in check_char()"),
+ readable_form(c));
if (c >= csize)
- lerrsf (_
- ("scanner requires -8 flag to use the character %s"),
- readable_form (c));
+ lerrsf(_
+ ("scanner requires -8 flag to use the character %s"),
+ readable_form(c));
}
/* clower - replace upper-case letter to lower-case */
-Char clower (c)
- int c;
+Char
+clower(c)
+ int c;
{
- return (Char) ((isascii (c) && isupper (c)) ? tolower (c) : c);
+ return (Char) ((isascii(c) && isupper(c)) ? tolower(c) : c);
}
/* copy_string - returns a dynamically allocated copy of a string */
-char *copy_string (str)
- const char *str;
+char *
+copy_string(str)
+ const char *str;
{
const char *c1;
char *c2;
- char *copy;
+ char *copy;
unsigned int size;
/* find length */
- for (c1 = str; *c1; ++c1) ;
+ for (c1 = str; *c1; ++c1);
- size = (c1 - str + 1) * sizeof (char);
+ size = (c1 - str + 1) * sizeof(char);
- copy = (char *) flex_alloc (size);
+ copy = (char *) flex_alloc(size);
if (copy == NULL)
- flexfatal (_("dynamic memory failure in copy_string()"));
+ flexfatal(_("dynamic memory failure in copy_string()"));
- for (c2 = copy; (*c2++ = *str++) != 0;) ;
+ for (c2 = copy; (*c2++ = *str++) != 0;);
return copy;
}
@@ -280,18 +291,19 @@ char *copy_string (str)
* returns a dynamically allocated copy of a (potentially) unsigned string
*/
-Char *copy_unsigned_string (str)
- Char *str;
+Char *
+copy_unsigned_string(str)
+ Char *str;
{
Char *c;
- Char *copy;
+ Char *copy;
/* find length */
- for (c = str; *c; ++c) ;
+ for (c = str; *c; ++c);
- copy = allocate_Character_array (c - str + 1);
+ copy = allocate_Character_array(c - str + 1);
- for (c = copy; (*c++ = *str++) != 0;) ;
+ for (c = copy; (*c++ = *str++) != 0;);
return copy;
}
@@ -299,30 +311,31 @@ Char *copy_unsigned_string (str)
/* cclcmp - compares two characters for use by qsort with '\0' sorting last. */
-int cclcmp (const void *a, const void *b)
+int
+cclcmp(const void *a, const void *b)
{
- if (!*(const Char *) a)
- return 1;
- else
- if (!*(const Char *) b)
- return - 1;
+ if (!*(const Char *) a)
+ return 1;
+ else if (!*(const Char *) b)
+ return -1;
else
- return *(const Char *) a - *(const Char *) b;
+ return *(const Char *) a - *(const Char *) b;
}
/* dataend - finish up a block of data declarations */
-void dataend ()
+void
+dataend()
{
/* short circuit any output */
if (gentables) {
if (datapos > 0)
- dataflush ();
+ dataflush();
/* add terminator for initialization; { for vi */
- outn (" } ;\n");
+ outn(" } ;\n");
}
dataline = 0;
datapos = 0;
@@ -331,22 +344,23 @@ void dataend ()
/* dataflush - flush generated data statements */
-void dataflush ()
+void
+dataflush()
{
/* short circuit any output */
if (!gentables)
return;
- outc ('\n');
+ outc('\n');
if (++dataline >= NUMDATALINES) {
- /* Put out a blank line so that the table is grouped into
+ /*
+ * Put out a blank line so that the table is grouped into
* large blocks that enable the user to find elements easily.
*/
- outc ('\n');
+ outc('\n');
dataline = 0;
}
-
/* Reset the number of characters written on the current line. */
datapos = 0;
}
@@ -354,33 +368,36 @@ void dataflush ()
/* flexerror - report an error message and terminate */
-void flexerror (msg)
- const char *msg;
+void
+flexerror(msg)
+ const char *msg;
{
- fprintf (stderr, "%s: %s\n", program_name, msg);
- flexend (1);
+ fprintf(stderr, "%s: %s\n", program_name, msg);
+ flexend(1);
}
/* flexfatal - report a fatal error message and terminate */
-void flexfatal (msg)
- const char *msg;
+void
+flexfatal(msg)
+ const char *msg;
{
- fprintf (stderr, _("%s: fatal internal error, %s\n"),
- program_name, msg);
- FLEX_EXIT (1);
+ fprintf(stderr, _("%s: fatal internal error, %s\n"),
+ program_name, msg);
+ FLEX_EXIT(1);
}
/* htoi - convert a hexadecimal digit string to an integer value */
-int htoi (str)
- Char str[];
+int
+htoi(str)
+ Char str[];
{
unsigned int result;
- (void) sscanf ((char *) str, "%x", &result);
+ (void) sscanf((char *) str, "%x", &result);
return result;
}
@@ -388,51 +405,55 @@ int htoi (str)
/* lerrif - report an error message formatted with one integer argument */
-void lerrif (msg, arg)
- const char *msg;
- int arg;
+void
+lerrif(msg, arg)
+ const char *msg;
+ int arg;
{
- char errmsg[MAXLINE];
+ char errmsg[MAXLINE];
- snprintf (errmsg, sizeof(errmsg), msg, arg);
- flexerror (errmsg);
+ snprintf(errmsg, sizeof(errmsg), msg, arg);
+ flexerror(errmsg);
}
/* lerrsf - report an error message formatted with one string argument */
-void lerrsf (msg, arg)
+void
+lerrsf(msg, arg)
const char *msg, arg[];
{
- char errmsg[MAXLINE];
+ char errmsg[MAXLINE];
- snprintf (errmsg, sizeof(errmsg)-1, msg, arg);
- errmsg[sizeof(errmsg)-1] = 0; /* ensure NULL termination */
- flexerror (errmsg);
+ snprintf(errmsg, sizeof(errmsg) - 1, msg, arg);
+ errmsg[sizeof(errmsg) - 1] = 0; /* ensure NULL termination */
+ flexerror(errmsg);
}
/* lerrsf_fatal - as lerrsf, but call flexfatal */
-void lerrsf_fatal (msg, arg)
+void
+lerrsf_fatal(msg, arg)
const char *msg, arg[];
{
- char errmsg[MAXLINE];
+ char errmsg[MAXLINE];
- snprintf (errmsg, sizeof(errmsg)-1, msg, arg);
- errmsg[sizeof(errmsg)-1] = 0; /* ensure NULL termination */
- flexfatal (errmsg);
+ snprintf(errmsg, sizeof(errmsg) - 1, msg, arg);
+ errmsg[sizeof(errmsg) - 1] = 0; /* ensure NULL termination */
+ flexfatal(errmsg);
}
/* line_directive_out - spit out a "#line" statement */
-void line_directive_out (output_file, do_infile)
- FILE *output_file;
- int do_infile;
+void
+line_directive_out(output_file, do_infile)
+ FILE *output_file;
+ int do_infile;
{
- char directive[MAXLINE], filename[MAXLINE];
- char *s1, *s2, *s3;
+ char directive[MAXLINE], filename[MAXLINE];
+ char *s1, *s2, *s3;
static const char *line_fmt = "#line %d \"%s\"\n";
if (!gen_line_dirs)
@@ -441,10 +462,10 @@ void line_directive_out (output_file, do_infile)
s1 = do_infile ? infilename : "M4_YY_OUTFILE_NAME";
if (do_infile && !s1)
- s1 = "<stdin>";
-
+ s1 = "<stdin>";
+
s2 = filename;
- s3 = &filename[sizeof (filename) - 2];
+ s3 = &filename[sizeof(filename) - 2];
while (s2 < s3 && *s1) {
if (*s1 == '\\')
@@ -457,19 +478,19 @@ void line_directive_out (output_file, do_infile)
*s2 = '\0';
if (do_infile)
- snprintf (directive, sizeof(directive), line_fmt, linenum, filename);
+ snprintf(directive, sizeof(directive), line_fmt, linenum, filename);
else {
- snprintf (directive, sizeof(directive), line_fmt, 0, filename);
+ snprintf(directive, sizeof(directive), line_fmt, 0, filename);
}
- /* If output_file is nil then we should put the directive in
- * the accumulated actions.
+ /*
+ * If output_file is nil then we should put the directive in the
+ * accumulated actions.
*/
if (output_file) {
- fputs (directive, output_file);
- }
- else
- add_action (directive);
+ fputs(directive, output_file);
+ } else
+ add_action(directive);
}
@@ -477,7 +498,8 @@ void line_directive_out (output_file, do_infile)
* representing where the user's section 1 definitions end
* and the prolog begins
*/
-void mark_defs1 ()
+void
+mark_defs1()
{
defs1_offset = 0;
action_array[action_index++] = '\0';
@@ -489,7 +511,8 @@ void mark_defs1 ()
/* mark_prolog - mark the current position in the action array as
* representing the end of the action prolog
*/
-void mark_prolog ()
+void
+mark_prolog()
{
action_array[action_index++] = '\0';
action_offset = action_index;
@@ -501,28 +524,28 @@ void mark_prolog ()
*
* Generates a data statement initializing the current 2-D array to "value".
*/
-void mk2data (value)
- int value;
+void
+mk2data(value)
+ int value;
{
/* short circuit any output */
if (!gentables)
return;
if (datapos >= NUMDATAITEMS) {
- outc (',');
- dataflush ();
+ outc(',');
+ dataflush();
}
-
if (datapos == 0)
/* Indent. */
- out (" ");
+ out(" ");
else
- outc (',');
+ outc(',');
++datapos;
- out_dec ("%5d", value);
+ out_dec("%5d", value);
}
@@ -531,38 +554,39 @@ void mk2data (value)
* Generates a data statement initializing the current array element to
* "value".
*/
-void mkdata (value)
- int value;
+void
+mkdata(value)
+ int value;
{
/* short circuit any output */
if (!gentables)
return;
if (datapos >= NUMDATAITEMS) {
- outc (',');
- dataflush ();
+ outc(',');
+ dataflush();
}
-
if (datapos == 0)
/* Indent. */
- out (" ");
+ out(" ");
else
- outc (',');
+ outc(',');
++datapos;
- out_dec ("%5d", value);
+ out_dec("%5d", value);
}
/* myctoi - return the integer represented by a string of digits */
-int myctoi (array)
- const char *array;
+int
+myctoi(array)
+ const char *array;
{
- int val = 0;
+ int val = 0;
- (void) sscanf (array, "%d", &val);
+ (void) sscanf(array, "%d", &val);
return val;
}
@@ -570,10 +594,11 @@ int myctoi (array)
/* myesc - return character corresponding to escape sequence */
-Char myesc (array)
- Char array[];
+Char
+myesc(array)
+ Char array[];
{
- Char c, esc_char;
+ Char c, esc_char;
switch (array[1]) {
case 'b':
@@ -608,11 +633,12 @@ Char myesc (array)
case '6':
case '7':
{ /* \<octal> */
- int sptr = 1;
+ int sptr = 1;
- while (isascii (array[sptr]) &&
- isdigit (array[sptr]))
- /* Don't increment inside loop control
+ while (isascii(array[sptr]) &&
+ isdigit(array[sptr]))
+ /*
+ * Don't increment inside loop control
* because if isdigit() is a macro it might
* expand into multiple increments ...
*/
@@ -621,7 +647,7 @@ Char myesc (array)
c = array[sptr];
array[sptr] = '\0';
- esc_char = otoi (array + 1);
+ esc_char = otoi(array + 1);
array[sptr] = c;
@@ -630,11 +656,12 @@ Char myesc (array)
case 'x':
{ /* \x<hex> */
- int sptr = 2;
+ int sptr = 2;
- while (isascii (array[sptr]) &&
- isxdigit (array[sptr]))
- /* Don't increment inside loop control
+ while (isascii(array[sptr]) &&
+ isxdigit(array[sptr]))
+ /*
+ * Don't increment inside loop control
* because if isdigit() is a macro it might
* expand into multiple increments ...
*/
@@ -643,7 +670,7 @@ Char myesc (array)
c = array[sptr];
array[sptr] = '\0';
- esc_char = htoi (array + 2);
+ esc_char = htoi(array + 2);
array[sptr] = c;
@@ -658,12 +685,13 @@ Char myesc (array)
/* otoi - convert an octal digit string to an integer value */
-int otoi (str)
- Char str[];
+int
+otoi(str)
+ Char str[];
{
unsigned int result;
- (void) sscanf ((char *) str, "%o", &result);
+ (void) sscanf((char *) str, "%o", &result);
return result;
}
@@ -672,63 +700,72 @@ int otoi (str)
* generated scanner, keeping track of the line count.
*/
-void out (str)
- const char *str;
+void
+out(str)
+ const char *str;
{
- fputs (str, stdout);
+ fputs(str, stdout);
}
-void out_dec (fmt, n)
- const char *fmt;
- int n;
+void
+out_dec(fmt, n)
+ const char *fmt;
+ int n;
{
- fprintf (stdout, fmt, n);
+ fprintf(stdout, fmt, n);
}
-void out_dec2 (fmt, n1, n2)
- const char *fmt;
- int n1, n2;
+void
+out_dec2(fmt, n1, n2)
+ const char *fmt;
+ int n1, n2;
{
- fprintf (stdout, fmt, n1, n2);
+ fprintf(stdout, fmt, n1, n2);
}
-void out_hex (fmt, x)
- const char *fmt;
- unsigned int x;
+void
+out_hex(fmt, x)
+ const char *fmt;
+ unsigned int x;
{
- fprintf (stdout, fmt, x);
+ fprintf(stdout, fmt, x);
}
-void out_str (fmt, str)
- const char *fmt, str[];
+void
+out_str(fmt, str)
+ const char *fmt, str[];
{
- fprintf (stdout,fmt, str);
+ fprintf(stdout, fmt, str);
}
-void out_str3 (fmt, s1, s2, s3)
- const char *fmt, s1[], s2[], s3[];
+void
+out_str3(fmt, s1, s2, s3)
+ const char *fmt, s1[], s2[], s3[];
{
- fprintf (stdout,fmt, s1, s2, s3);
+ fprintf(stdout, fmt, s1, s2, s3);
}
-void out_str_dec (fmt, str, n)
- const char *fmt, str[];
- int n;
+void
+out_str_dec(fmt, str, n)
+ const char *fmt, str[];
+ int n;
{
- fprintf (stdout,fmt, str, n);
+ fprintf(stdout, fmt, str, n);
}
-void outc (c)
- int c;
+void
+outc(c)
+ int c;
{
- fputc (c, stdout);
+ fputc(c, stdout);
}
-void outn (str)
- const char *str;
+void
+outn(str)
+ const char *str;
{
- fputs (str,stdout);
- fputc('\n',stdout);
+ fputs(str, stdout);
+ fputc('\n', stdout);
}
/** Print "m4_define( [[def]], [[val]])m4_dnl\n".
@@ -736,10 +773,11 @@ void outn (str)
* @param val The definition; may be NULL.
* @return buf
*/
-void out_m4_define (const char* def, const char* val)
+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:"");
+ const char *fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n";
+ fprintf(stdout, fmt, def, val ? val : "");
}
@@ -748,8 +786,9 @@ void out_m4_define (const char* def, const char* val)
* The returned string is in static storage.
*/
-char *readable_form (c)
- int c;
+char *
+readable_form(c)
+ int c;
{
static char rform[10];
@@ -774,12 +813,10 @@ char *readable_form (c)
#endif
default:
- snprintf (rform, sizeof(rform), "\\%.3o", (unsigned int) c);
+ snprintf(rform, sizeof(rform), "\\%.3o", (unsigned int) c);
return rform;
}
- }
-
- else if (c == ' ')
+ } else if (c == ' ')
return "' '";
else {
@@ -793,17 +830,18 @@ char *readable_form (c)
/* reallocate_array - increase the size of a dynamic array */
-void *reallocate_array (array, size, element_size)
- void *array;
- int size;
- size_t element_size;
+void *
+reallocate_array(array, size, element_size)
+ void *array;
+ int size;
+ size_t element_size;
{
void *new_array;
- size_t num_bytes = element_size * size;
+ size_t num_bytes = element_size * size;
- new_array = flex_realloc (array, num_bytes);
+ new_array = flex_realloc(array, num_bytes);
if (!new_array)
- flexfatal (_("attempt to increase array size failed"));
+ flexfatal(_("attempt to increase array size failed"));
return new_array;
}
@@ -815,127 +853,111 @@ void *reallocate_array (array, size, element_size)
* Copies skelfile or skel array to stdout until a line beginning with
* "%%" or EOF is found.
*/
-void skelout ()
+void
+skelout()
{
- char buf_storage[MAXLINE];
- char *buf = buf_storage;
- bool do_copy = true;
+ char buf_storage[MAXLINE];
+ char *buf = buf_storage;
+ bool do_copy = true;
- /* "reset" the state by clearing the buffer and pushing a '1' */
- if(sko_len > 0)
- sko_peek(&do_copy);
- sko_len = 0;
- sko_push(do_copy=true);
+ /* "reset" the state by clearing the buffer and pushing a '1' */
+ if (sko_len > 0)
+ sko_peek(&do_copy);
+ sko_len = 0;
+ sko_push(do_copy = true);
- /* Loop pulling lines either from the skelfile, if we're using
- * one, or from the skel[] array.
+ /*
+ * Loop pulling lines either from the skelfile, if we're using one,
+ * or from the skel[] array.
*/
while (skelfile ?
- (fgets (buf, MAXLINE, skelfile) != NULL) :
- ((buf = (char *) skel[skel_ind++]) != 0)) {
+ (fgets(buf, MAXLINE, skelfile) != NULL) :
+ ((buf = (char *) skel[skel_ind++]) != 0)) {
if (skelfile)
- chomp (buf);
+ chomp(buf);
/* copy from skel array */
if (buf[0] == '%') { /* control line */
/* print the control line as a comment. */
if (ddebug && buf[1] != '#') {
- if (buf[strlen (buf) - 1] == '\\')
- out_str ("/* %s */\\\n", buf);
+ if (buf[strlen(buf) - 1] == '\\')
+ out_str("/* %s */\\\n", buf);
else
- out_str ("/* %s */\n", buf);
+ out_str("/* %s */\n", buf);
}
-
- /* We've been accused of using cryptic markers in the skel.
- * So we'll use emacs-style-hyphenated-commands.
- * We might consider a hash if this if-else-if-else
- * chain gets too large.
+ /*
+ * We've been accused of using cryptic markers in the
+ * skel. So we'll use
+ * emacs-style-hyphenated-commands. We might consider
+ * a hash if this if-else-if-else chain gets too
+ * large.
*/
#define cmd_match(s) (strncmp(buf,(s),strlen(s))==0)
if (buf[1] == '%') {
/* %% is a break point for skelout() */
return;
- }
- else if (cmd_match (CMD_PUSH)){
- sko_push(do_copy);
- if(ddebug){
- out_str("/*(state = (%s) */",do_copy?"true":"false");
- }
- out_str("%s\n", buf[strlen (buf) - 1] =='\\' ? "\\" : "");
- }
- else if (cmd_match (CMD_POP)){
- sko_pop(&do_copy);
- if(ddebug){
- out_str("/*(state = (%s) */",do_copy?"true":"false");
- }
- out_str("%s\n", buf[strlen (buf) - 1] =='\\' ? "\\" : "");
- }
- else if (cmd_match (CMD_IF_REENTRANT)){
- sko_push(do_copy);
- do_copy = reentrant && do_copy;
- }
- else if (cmd_match (CMD_IF_NOT_REENTRANT)){
- sko_push(do_copy);
- do_copy = !reentrant && do_copy;
- }
- else if (cmd_match(CMD_IF_BISON_BRIDGE)){
- sko_push(do_copy);
- do_copy = bison_bridge_lval && do_copy;
- }
- else if (cmd_match(CMD_IF_NOT_BISON_BRIDGE)){
- sko_push(do_copy);
- do_copy = !bison_bridge_lval && do_copy;
- }
- else if (cmd_match (CMD_ENDIF)){
- sko_pop(&do_copy);
- }
- else if (cmd_match (CMD_IF_TABLES_SER)) {
- do_copy = do_copy && tablesext;
- }
- else if (cmd_match (CMD_TABLES_YYDMAP)) {
+ } else if (cmd_match(CMD_PUSH)) {
+ sko_push(do_copy);
+ if (ddebug) {
+ out_str("/*(state = (%s) */", do_copy ? "true" : "false");
+ }
+ out_str("%s\n", buf[strlen(buf) - 1] == '\\' ? "\\" : "");
+ } else if (cmd_match(CMD_POP)) {
+ sko_pop(&do_copy);
+ if (ddebug) {
+ out_str("/*(state = (%s) */", do_copy ? "true" : "false");
+ }
+ out_str("%s\n", buf[strlen(buf) - 1] == '\\' ? "\\" : "");
+ } else if (cmd_match(CMD_IF_REENTRANT)) {
+ sko_push(do_copy);
+ do_copy = reentrant && do_copy;
+ } else if (cmd_match(CMD_IF_NOT_REENTRANT)) {
+ sko_push(do_copy);
+ do_copy = !reentrant && do_copy;
+ } else if (cmd_match(CMD_IF_BISON_BRIDGE)) {
+ sko_push(do_copy);
+ do_copy = bison_bridge_lval && do_copy;
+ } else if (cmd_match(CMD_IF_NOT_BISON_BRIDGE)) {
+ sko_push(do_copy);
+ do_copy = !bison_bridge_lval && do_copy;
+ } else if (cmd_match(CMD_ENDIF)) {
+ sko_pop(&do_copy);
+ } else if (cmd_match(CMD_IF_TABLES_SER)) {
+ do_copy = do_copy && tablesext;
+ } else if (cmd_match(CMD_TABLES_YYDMAP)) {
if (tablesext && yydmap_buf.elts)
- outn ((char *) (yydmap_buf.elts));
- }
- else if (cmd_match (CMD_DEFINE_YYTABLES)) {
- out_str("#define YYTABLES_NAME \"%s\"\n",
- tablesname?tablesname:"yytables");
- }
- else if (cmd_match (CMD_IF_CPP_ONLY)) {
+ outn((char *) (yydmap_buf.elts));
+ } else if (cmd_match(CMD_DEFINE_YYTABLES)) {
+ out_str("#define YYTABLES_NAME \"%s\"\n",
+ tablesname ? tablesname : "yytables");
+ } else if (cmd_match(CMD_IF_CPP_ONLY)) {
/* only for C++ */
- sko_push(do_copy);
+ sko_push(do_copy);
do_copy = C_plus_plus;
- }
- else if (cmd_match (CMD_IF_C_ONLY)) {
+ } else if (cmd_match(CMD_IF_C_ONLY)) {
/* %- only for C */
- sko_push(do_copy);
+ sko_push(do_copy);
do_copy = !C_plus_plus;
- }
- else if (cmd_match (CMD_IF_C_OR_CPP)) {
+ } else if (cmd_match(CMD_IF_C_OR_CPP)) {
/* %* for C and C++ */
- sko_push(do_copy);
+ sko_push(do_copy);
do_copy = true;
- }
- else if (cmd_match (CMD_NOT_FOR_HEADER)) {
+ } else if (cmd_match(CMD_NOT_FOR_HEADER)) {
/* %c begin linkage-only (non-header) code. */
- OUT_BEGIN_CODE ();
- }
- else if (cmd_match (CMD_OK_FOR_HEADER)) {
+ OUT_BEGIN_CODE();
+ } else if (cmd_match(CMD_OK_FOR_HEADER)) {
/* %e end linkage-only code. */
- OUT_END_CODE ();
- }
- else if (buf[1] == '#') {
+ OUT_END_CODE();
+ } else if (buf[1] == '#') {
/* %# a comment in the skel. ignore. */
+ } else {
+ flexfatal(_("bad line in skeleton file"));
}
- else {
- flexfatal (_("bad line in skeleton file"));
- }
- }
-
- else if (do_copy)
- outn (buf);
+ } else if (do_copy)
+ outn(buf);
} /* end while */
}
@@ -946,23 +968,24 @@ void skelout ()
* element_n. Formats the output with spaces and carriage returns.
*/
-void transition_struct_out (element_v, element_n)
- int element_v, element_n;
+void
+transition_struct_out(element_v, element_n)
+ int element_v, element_n;
{
/* short circuit any output */
if (!gentables)
return;
- out_dec2 (" {%4d,%4d },", element_v, element_n);
+ out_dec2(" {%4d,%4d },", element_v, element_n);
datapos += TRANS_STRUCT_PRINT_LENGTH;
if (datapos >= 79 - TRANS_STRUCT_PRINT_LENGTH) {
- outc ('\n');
+ outc('\n');
if (++dataline % 10 == 0)
- outc ('\n');
+ outc('\n');
datapos = 0;
}
@@ -972,14 +995,15 @@ void transition_struct_out (element_v, element_n)
/* The following is only needed when building flex's parser using certain
* broken versions of bison.
*/
-void *yy_flex_xmalloc (size)
- int size;
+void *
+yy_flex_xmalloc(size)
+ int size;
{
- void *result = flex_alloc ((size_t) size);
+ void *result = flex_alloc((size_t) size);
if (!result)
- flexfatal (_
- ("memory allocation failed in yy_flex_xmalloc()"));
+ flexfatal(_
+ ("memory allocation failed in yy_flex_xmalloc()"));
return result;
}
@@ -990,9 +1014,10 @@ void *yy_flex_xmalloc (size)
* Sets region_ptr[0] through region_ptr[size_in_bytes - 1] to zero.
*/
-void zero_out (region_ptr, size_in_bytes)
- char *region_ptr;
- size_t size_in_bytes;
+void
+zero_out(region_ptr, size_in_bytes)
+ char *region_ptr;
+ size_t size_in_bytes;
{
char *rp, *rp_end;
@@ -1006,10 +1031,11 @@ void zero_out (region_ptr, size_in_bytes)
/* Remove all '\n' and '\r' characters, if any, from the end of str.
* str can be any null-terminated string, or NULL.
* returns str. */
-char *chomp (str)
- char *str;
+char *
+chomp(str)
+ char *str;
{
- char *p = str;
+ char *p = str;
if (!str || !*str) /* s is null or empty string */
return str;
diff --git a/usr.bin/lex/nfa.c b/usr.bin/lex/nfa.c
index f92f7fa9b86..272febfc69e 100644
--- a/usr.bin/lex/nfa.c
+++ b/usr.bin/lex/nfa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfa.c,v 1.10 2015/11/19 19:43:40 tedu Exp $ */
+/* $OpenBSD: nfa.c,v 1.11 2015/11/19 22:52:40 tedu Exp $ */
/* nfa - NFA construction routines */
@@ -38,8 +38,8 @@
/* declare functions that have forward references */
-int dupmachine PROTO ((int));
-void mkxtion PROTO ((int, int));
+int dupmachine PROTO((int));
+void mkxtion PROTO((int, int));
/* add_accept - add an accepting state to a machine
@@ -47,23 +47,25 @@ void mkxtion PROTO ((int, int));
* accepting_number becomes mach's accepting number.
*/
-void add_accept (mach, accepting_number)
- int mach, accepting_number;
+void
+add_accept(mach, accepting_number)
+ int mach, accepting_number;
{
- /* Hang the accepting number off an epsilon state. if it is associated
- * with a state that has a non-epsilon out-transition, then the state
- * will accept BEFORE it makes that transition, i.e., one character
- * too soon.
+ /*
+ * Hang the accepting number off an epsilon state. if it is
+ * associated with a state that has a non-epsilon out-transition,
+ * then the state will accept BEFORE it makes that transition, i.e.,
+ * one character too soon.
*/
if (transchar[finalst[mach]] == SYM_EPSILON)
accptnum[finalst[mach]] = accepting_number;
else {
- int astate = mkstate (SYM_EPSILON);
+ int astate = mkstate(SYM_EPSILON);
accptnum[astate] = accepting_number;
- (void) link_machines (mach, astate);
+ (void) link_machines(mach, astate);
}
}
@@ -79,15 +81,16 @@ void add_accept (mach, accepting_number)
* num - the number of copies of singl to be present in newsng
*/
-int copysingl (singl, num)
- int singl, num;
+int
+copysingl(singl, num)
+ int singl, num;
{
- int copy, i;
+ int copy, i;
- copy = mkstate (SYM_EPSILON);
+ copy = mkstate(SYM_EPSILON);
for (i = 1; i <= num; ++i)
- copy = link_machines (copy, dupmachine (singl));
+ copy = link_machines(copy, dupmachine(singl));
return copy;
}
@@ -95,41 +98,43 @@ int copysingl (singl, num)
/* dumpnfa - debugging routine to write out an nfa */
-void dumpnfa (state1)
- int state1;
+void
+dumpnfa(state1)
+ int state1;
{
- int sym, tsp1, tsp2, anum, ns;
+ int sym, tsp1, tsp2, anum, ns;
- fprintf (stderr,
- _
- ("\n\n********** beginning dump of nfa with start state %d\n"),
- state1);
+ fprintf(stderr,
+ _
+ ("\n\n********** beginning dump of nfa with start state %d\n"),
+ state1);
- /* We probably should loop starting at firstst[state1] and going to
+ /*
+ * We probably should loop starting at firstst[state1] and going to
* lastst[state1], but they're not maintained properly when we "or"
- * all of the rules together. So we use our knowledge that the machine
- * starts at state 1 and ends at lastnfa.
+ * all of the rules together. So we use our knowledge that the
+ * machine starts at state 1 and ends at lastnfa.
*/
/* for ( ns = firstst[state1]; ns <= lastst[state1]; ++ns ) */
for (ns = 1; ns <= lastnfa; ++ns) {
- fprintf (stderr, _("state # %4d\t"), ns);
+ fprintf(stderr, _("state # %4d\t"), ns);
sym = transchar[ns];
tsp1 = trans1[ns];
tsp2 = trans2[ns];
anum = accptnum[ns];
- fprintf (stderr, "%3d: %4d, %4d", sym, tsp1, tsp2);
+ fprintf(stderr, "%3d: %4d, %4d", sym, tsp1, tsp2);
if (anum != NIL)
- fprintf (stderr, " [%d]", anum);
+ fprintf(stderr, " [%d]", anum);
- fprintf (stderr, "\n");
+ fprintf(stderr, "\n");
}
- fprintf (stderr, _("********** end of dump\n"));
+ fprintf(stderr, _("********** end of dump\n"));
}
@@ -150,30 +155,30 @@ void dumpnfa (state1)
* states accessible by the arrays firstst and lastst
*/
-int dupmachine (mach)
- int mach;
+int
+dupmachine(mach)
+ int mach;
{
- int i, init, state_offset;
- int state = 0;
- int last = lastst[mach];
+ int i, init, state_offset;
+ int state = 0;
+ int last = lastst[mach];
for (i = firstst[mach]; i <= last; ++i) {
- state = mkstate (transchar[i]);
+ state = mkstate(transchar[i]);
if (trans1[i] != NO_TRANSITION) {
- mkxtion (finalst[state], trans1[i] + state - i);
+ mkxtion(finalst[state], trans1[i] + state - i);
if (transchar[i] == SYM_EPSILON &&
trans2[i] != NO_TRANSITION)
- mkxtion (finalst[state],
- trans2[i] + state - i);
+ mkxtion(finalst[state],
+ trans2[i] + state - i);
}
-
accptnum[state] = accptnum[i];
}
if (state == 0)
- flexfatal (_("empty machine in dupmachine()"));
+ flexfatal(_("empty machine in dupmachine()"));
state_offset = state - i + 1;
@@ -198,103 +203,102 @@ int dupmachine (mach)
* context has variable length.
*/
-void finish_rule (mach, variable_trail_rule, headcnt, trailcnt,
- pcont_act)
- int mach, variable_trail_rule, headcnt, trailcnt, pcont_act;
+void
+finish_rule(mach, variable_trail_rule, headcnt, trailcnt,
+ pcont_act)
+ int mach, variable_trail_rule, headcnt, trailcnt, pcont_act;
{
- char action_text[MAXLINE];
+ char action_text[MAXLINE];
- add_accept (mach, num_rules);
+ add_accept(mach, num_rules);
- /* We did this in new_rule(), but it often gets the wrong
- * number because we do it before we start parsing the current rule.
+ /*
+ * We did this in new_rule(), but it often gets the wrong number
+ * because we do it before we start parsing the current rule.
*/
rule_linenum[num_rules] = linenum;
- /* If this is a continued action, then the line-number has already
+ /*
+ * If this is a continued action, then the line-number has already
* been updated, giving us the wrong number.
*/
if (continued_action)
--rule_linenum[num_rules];
- /* If the previous rule was continued action, then we inherit the
+ /*
+ * If the previous rule was continued action, then we inherit the
* previous newline flag, possibly overriding the current one.
*/
if (pcont_act && rule_has_nl[num_rules - 1])
rule_has_nl[num_rules] = true;
- snprintf (action_text, sizeof(action_text), "case %d:\n", num_rules);
- add_action (action_text);
+ snprintf(action_text, sizeof(action_text), "case %d:\n", num_rules);
+ add_action(action_text);
if (rule_has_nl[num_rules]) {
- snprintf (action_text, sizeof(action_text), "/* rule %d can match eol */\n",
- num_rules);
- add_action (action_text);
+ snprintf(action_text, sizeof(action_text), "/* rule %d can match eol */\n",
+ num_rules);
+ add_action(action_text);
}
-
-
if (variable_trail_rule) {
rule_type[num_rules] = RULE_VARIABLE;
if (performance_report > 0)
- fprintf (stderr,
- _
- ("Variable trailing context rule at line %d\n"),
- rule_linenum[num_rules]);
+ fprintf(stderr,
+ _
+ ("Variable trailing context rule at line %d\n"),
+ rule_linenum[num_rules]);
variable_trailing_context_rules = true;
- }
-
- else {
+ } else {
rule_type[num_rules] = RULE_NORMAL;
if (headcnt > 0 || trailcnt > 0) {
- /* Do trailing context magic to not match the trailing
- * characters.
+ /*
+ * Do trailing context magic to not match the
+ * trailing characters.
*/
- char *scanner_cp = "YY_G(yy_c_buf_p) = yy_cp";
- char *scanner_bp = "yy_bp";
+ char *scanner_cp = "YY_G(yy_c_buf_p) = yy_cp";
+ char *scanner_bp = "yy_bp";
add_action
- ("*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */\n");
+ ("*yy_cp = YY_G(yy_hold_char); /* undo effects of setting up yytext */\n");
if (headcnt > 0) {
if (rule_has_nl[num_rules]) {
- snprintf (action_text, sizeof(action_text),
- "YY_LINENO_REWIND_TO(%s + %d);\n", scanner_bp, headcnt);
- add_action (action_text);
+ snprintf(action_text, sizeof(action_text),
+ "YY_LINENO_REWIND_TO(%s + %d);\n", scanner_bp, headcnt);
+ add_action(action_text);
}
- snprintf (action_text, sizeof(action_text), "%s = %s + %d;\n",
- scanner_cp, scanner_bp, headcnt);
- add_action (action_text);
- }
-
- else {
+ snprintf(action_text, sizeof(action_text), "%s = %s + %d;\n",
+ scanner_cp, scanner_bp, headcnt);
+ add_action(action_text);
+ } else {
if (rule_has_nl[num_rules]) {
- snprintf (action_text, sizeof(action_text),
- "YY_LINENO_REWIND_TO(yy_cp - %d);\n", trailcnt);
- add_action (action_text);
+ snprintf(action_text, sizeof(action_text),
+ "YY_LINENO_REWIND_TO(yy_cp - %d);\n", trailcnt);
+ add_action(action_text);
}
-
- snprintf (action_text, sizeof(action_text), "%s -= %d;\n",
- scanner_cp, trailcnt);
- add_action (action_text);
+ snprintf(action_text, sizeof(action_text), "%s -= %d;\n",
+ scanner_cp, trailcnt);
+ add_action(action_text);
}
add_action
- ("YY_DO_BEFORE_ACTION; /* set up yytext again */\n");
+ ("YY_DO_BEFORE_ACTION; /* set up yytext again */\n");
}
}
- /* Okay, in the action code at this point yytext and yyleng have
- * their proper final values for this rule, so here's the point
- * to do any user action. But don't do it for continued actions,
- * as that'll result in multiple YY_RULE_SETUP's.
+ /*
+ * Okay, in the action code at this point yytext and yyleng have
+ * their proper final values for this rule, so here's the point to do
+ * any user action. But don't do it for continued actions, as
+ * that'll result in multiple YY_RULE_SETUP's.
*/
if (!continued_action)
- add_action ("YY_RULE_SETUP\n");
+ add_action("YY_RULE_SETUP\n");
- line_directive_out ((FILE *) 0, 1);
+ line_directive_out((FILE *) 0, 1);
}
@@ -314,8 +318,9 @@ void finish_rule (mach, variable_trail_rule, headcnt, trailcnt,
* FIRST is set to new by the operation. last is unmolested.
*/
-int link_machines (first, last)
- int first, last;
+int
+link_machines(first, last)
+ int first, last;
{
if (first == NIL)
return last;
@@ -324,10 +329,10 @@ int link_machines (first, last)
return first;
else {
- mkxtion (finalst[first], last);
+ mkxtion(finalst[first], last);
finalst[first] = finalst[last];
- lastst[first] = MAX (lastst[first], lastst[last]);
- firstst[first] = MIN (firstst[first], firstst[last]);
+ lastst[first] = MAX(lastst[first], lastst[last]);
+ firstst[first] = MIN(firstst[first], firstst[last]);
return first;
}
@@ -341,8 +346,9 @@ int link_machines (first, last)
* The "beginning" states are the epsilon closure of the first state
*/
-void mark_beginning_as_normal (mach)
- int mach;
+void
+mark_beginning_as_normal(mach)
+ int mach;
{
switch (state_type[mach]) {
case STATE_NORMAL:
@@ -354,16 +360,16 @@ void mark_beginning_as_normal (mach)
if (transchar[mach] == SYM_EPSILON) {
if (trans1[mach] != NO_TRANSITION)
- mark_beginning_as_normal (trans1[mach]);
+ mark_beginning_as_normal(trans1[mach]);
if (trans2[mach] != NO_TRANSITION)
- mark_beginning_as_normal (trans2[mach]);
+ mark_beginning_as_normal(trans2[mach]);
}
break;
default:
- flexerror (_
- ("bad state type in mark_beginning_as_normal()"));
+ flexerror(_
+ ("bad state type in mark_beginning_as_normal()"));
break;
}
}
@@ -383,10 +389,11 @@ void mark_beginning_as_normal (mach)
* more mkbranch's. Compare with mkor()
*/
-int mkbranch (first, second)
- int first, second;
+int
+mkbranch(first, second)
+ int first, second;
{
- int eps;
+ int eps;
if (first == NO_TRANSITION)
return second;
@@ -394,10 +401,10 @@ int mkbranch (first, second)
else if (second == NO_TRANSITION)
return first;
- eps = mkstate (SYM_EPSILON);
+ eps = mkstate(SYM_EPSILON);
- mkxtion (eps, first);
- mkxtion (eps, second);
+ mkxtion(eps, first);
+ mkxtion(eps, second);
return eps;
}
@@ -411,10 +418,11 @@ int mkbranch (first, second)
* new - a new state which matches the closure of "state"
*/
-int mkclos (state)
- int state;
+int
+mkclos(state)
+ int state;
{
- return mkopt (mkposcl (state));
+ return mkopt(mkposcl(state));
}
@@ -432,24 +440,25 @@ int mkclos (state)
* 2. mach is destroyed by the call
*/
-int mkopt (mach)
- int mach;
+int
+mkopt(mach)
+ int mach;
{
- int eps;
+ int eps;
- if (!SUPER_FREE_EPSILON (finalst[mach])) {
- eps = mkstate (SYM_EPSILON);
- mach = link_machines (mach, eps);
+ if (!SUPER_FREE_EPSILON(finalst[mach])) {
+ eps = mkstate(SYM_EPSILON);
+ mach = link_machines(mach, eps);
}
-
- /* Can't skimp on the following if FREE_EPSILON(mach) is true because
+ /*
+ * Can't skimp on the following if FREE_EPSILON(mach) is true because
* some state interior to "mach" might point back to the beginning
* for a closure.
*/
- eps = mkstate (SYM_EPSILON);
- mach = link_machines (eps, mach);
+ eps = mkstate(SYM_EPSILON);
+ mach = link_machines(eps, mach);
- mkxtion (mach, finalst[mach]);
+ mkxtion(mach, finalst[mach]);
return mach;
}
@@ -469,10 +478,11 @@ int mkopt (mach)
* the number of epsilon states needed
*/
-int mkor (first, second)
- int first, second;
+int
+mkor(first, second)
+ int first, second;
{
- int eps, orend;
+ int eps, orend;
if (first == NIL)
return second;
@@ -481,34 +491,32 @@ int mkor (first, second)
return first;
else {
- /* See comment in mkopt() about why we can't use the first
- * state of "first" or "second" if they satisfy "FREE_EPSILON".
+ /*
+ * See comment in mkopt() about why we can't use the first
+ * state of "first" or "second" if they satisfy
+ * "FREE_EPSILON".
*/
- eps = mkstate (SYM_EPSILON);
+ eps = mkstate(SYM_EPSILON);
- first = link_machines (eps, first);
+ first = link_machines(eps, first);
- mkxtion (first, second);
+ mkxtion(first, second);
- if (SUPER_FREE_EPSILON (finalst[first]) &&
+ if (SUPER_FREE_EPSILON(finalst[first]) &&
accptnum[finalst[first]] == NIL) {
orend = finalst[first];
- mkxtion (finalst[second], orend);
- }
-
- else if (SUPER_FREE_EPSILON (finalst[second]) &&
- accptnum[finalst[second]] == NIL) {
+ mkxtion(finalst[second], orend);
+ } else if (SUPER_FREE_EPSILON(finalst[second]) &&
+ accptnum[finalst[second]] == NIL) {
orend = finalst[second];
- mkxtion (finalst[first], orend);
- }
-
- else {
- eps = mkstate (SYM_EPSILON);
+ mkxtion(finalst[first], orend);
+ } else {
+ eps = mkstate(SYM_EPSILON);
- first = link_machines (first, eps);
+ first = link_machines(first, eps);
orend = finalst[first];
- mkxtion (finalst[second], orend);
+ mkxtion(finalst[second], orend);
}
}
@@ -525,20 +533,19 @@ int mkor (first, second)
* new - a machine matching the positive closure of "state"
*/
-int mkposcl (state)
- int state;
+int
+mkposcl(state)
+ int state;
{
- int eps;
+ int eps;
- if (SUPER_FREE_EPSILON (finalst[state])) {
- mkxtion (finalst[state], state);
+ if (SUPER_FREE_EPSILON(finalst[state])) {
+ mkxtion(finalst[state], state);
return state;
- }
-
- else {
- eps = mkstate (SYM_EPSILON);
- mkxtion (eps, state);
- return link_machines (state, eps);
+ } else {
+ eps = mkstate(SYM_EPSILON);
+ mkxtion(eps, state);
+ return link_machines(state, eps);
}
}
@@ -555,31 +562,30 @@ int mkposcl (state)
* if "ub" is INFINITE_REPEAT then "new" matches "lb" or more occurrences of "mach"
*/
-int mkrep (mach, lb, ub)
- int mach, lb, ub;
+int
+mkrep(mach, lb, ub)
+ int mach, lb, ub;
{
- int base_mach, tail, copy, i;
+ int base_mach, tail, copy, i;
- base_mach = copysingl (mach, lb - 1);
+ base_mach = copysingl(mach, lb - 1);
if (ub == INFINITE_REPEAT) {
- copy = dupmachine (mach);
- mach = link_machines (mach,
- link_machines (base_mach,
- mkclos (copy)));
- }
-
- else {
- tail = mkstate (SYM_EPSILON);
+ copy = dupmachine(mach);
+ mach = link_machines(mach,
+ link_machines(base_mach,
+ mkclos(copy)));
+ } else {
+ tail = mkstate(SYM_EPSILON);
for (i = lb; i < ub; ++i) {
- copy = dupmachine (mach);
- tail = mkopt (link_machines (copy, tail));
+ copy = dupmachine(mach);
+ tail = mkopt(link_machines(copy, tail));
}
mach =
- link_machines (mach,
- link_machines (base_mach, tail));
+ link_machines(mach,
+ link_machines(base_mach, tail));
}
return mach;
@@ -602,32 +608,32 @@ int mkrep (mach, lb, ub)
* that it admittedly is)
*/
-int mkstate (sym)
- int sym;
+int
+mkstate(sym)
+ int sym;
{
if (++lastnfa >= current_mns) {
if ((current_mns += MNS_INCREMENT) >= maximum_mns)
- lerrif (_
- ("input rules are too complicated (>= %d NFA states)"),
-current_mns);
+ lerrif(_
+ ("input rules are too complicated (>= %d NFA states)"),
+ current_mns);
++num_reallocs;
- firstst = reallocate_integer_array (firstst, current_mns);
- lastst = reallocate_integer_array (lastst, current_mns);
- finalst = reallocate_integer_array (finalst, current_mns);
+ firstst = reallocate_integer_array(firstst, current_mns);
+ lastst = reallocate_integer_array(lastst, current_mns);
+ finalst = reallocate_integer_array(finalst, current_mns);
transchar =
- reallocate_integer_array (transchar, current_mns);
- trans1 = reallocate_integer_array (trans1, current_mns);
- trans2 = reallocate_integer_array (trans2, current_mns);
+ reallocate_integer_array(transchar, current_mns);
+ trans1 = reallocate_integer_array(trans1, current_mns);
+ trans2 = reallocate_integer_array(trans2, current_mns);
accptnum =
- reallocate_integer_array (accptnum, current_mns);
+ reallocate_integer_array(accptnum, current_mns);
assoc_rule =
- reallocate_integer_array (assoc_rule, current_mns);
+ reallocate_integer_array(assoc_rule, current_mns);
state_type =
- reallocate_integer_array (state_type, current_mns);
+ reallocate_integer_array(state_type, current_mns);
}
-
firstst[lastnfa] = lastnfa;
finalst[lastnfa] = lastnfa;
lastst[lastnfa] = lastnfa;
@@ -638,7 +644,8 @@ current_mns);
assoc_rule[lastnfa] = num_rules;
state_type[lastnfa] = current_state_type;
- /* Fix up equivalence classes base on this transition. Note that any
+ /*
+ * Fix up equivalence classes base on this transition. Note that any
* character which has its own transition gets its own equivalence
* class. Thus only characters which are only in character classes
* have a chance at being in the same equivalence class. E.g. "a|b"
@@ -648,21 +655,20 @@ current_mns);
*/
if (sym < 0) {
- /* We don't have to update the equivalence classes since
- * that was already done when the ccl was created for the
- * first time.
+ /*
+ * We don't have to update the equivalence classes since that
+ * was already done when the ccl was created for the first
+ * time.
*/
- }
-
- else if (sym == SYM_EPSILON)
+ } else if (sym == SYM_EPSILON)
++numeps;
else {
- check_char (sym);
+ check_char(sym);
if (useecs)
/* Map NUL's to csize. */
- mkechar (sym ? sym : csize, nextecm, ecgroup);
+ mkechar(sym ? sym : csize, nextecm, ecgroup);
}
return lastnfa;
@@ -679,15 +685,16 @@ current_mns);
* stateto - the state to which the transition is to be made
*/
-void mkxtion (statefrom, stateto)
- int statefrom, stateto;
+void
+mkxtion(statefrom, stateto)
+ int statefrom, stateto;
{
if (trans1[statefrom] == NO_TRANSITION)
trans1[statefrom] = stateto;
else if ((transchar[statefrom] != SYM_EPSILON) ||
- (trans2[statefrom] != NO_TRANSITION))
- flexfatal (_("found too many transitions in mkxtion()"));
+ (trans2[statefrom] != NO_TRANSITION))
+ flexfatal(_("found too many transitions in mkxtion()"));
else { /* second out-transition for an epsilon state */
++eps2;
@@ -697,23 +704,23 @@ void mkxtion (statefrom, stateto)
/* new_rule - initialize for a new rule */
-void new_rule ()
+void
+new_rule()
{
if (++num_rules >= current_max_rules) {
++num_reallocs;
current_max_rules += MAX_RULES_INCREMENT;
- rule_type = reallocate_integer_array (rule_type,
- current_max_rules);
- rule_linenum = reallocate_integer_array (rule_linenum,
- current_max_rules);
- rule_useful = reallocate_integer_array (rule_useful,
- current_max_rules);
- rule_has_nl = reallocate_bool_array (rule_has_nl,
- current_max_rules);
+ rule_type = reallocate_integer_array(rule_type,
+ current_max_rules);
+ rule_linenum = reallocate_integer_array(rule_linenum,
+ current_max_rules);
+ rule_useful = reallocate_integer_array(rule_useful,
+ current_max_rules);
+ rule_has_nl = reallocate_bool_array(rule_has_nl,
+ current_max_rules);
}
-
if (num_rules > MAX_RULE)
- lerrif (_("too many rules (> %d)!"), MAX_RULE);
+ lerrif(_("too many rules (> %d)!"), MAX_RULE);
rule_linenum[num_rules] = linenum;
rule_useful[num_rules] = false;