diff options
author | John Millaway <john43@users.sourceforge.net> | 2003-03-19 21:53:34 +0000 |
---|---|---|
committer | John Millaway <john43@users.sourceforge.net> | 2003-03-19 21:53:34 +0000 |
commit | 80004429349b1b86a4f0567e9e82cf66719dff49 (patch) | |
tree | c2c8971e0a462b2a9db78130706466656239d6f1 | |
parent | 449378b8690982e635663b1297eef5060b3e5b1c (diff) |
Start conditions now generated in a single place.
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | buf.c | 11 | ||||
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | flex.skl | 6 | ||||
-rw-r--r-- | flexdef.h | 2 | ||||
-rw-r--r-- | main.c | 19 | ||||
-rw-r--r-- | sym.c | 3 |
7 files changed, 37 insertions, 7 deletions
@@ -68,8 +68,6 @@ ** token-type and token buffer support -** put start conditions in the header - ** check if we still need to #undef macros at the end of a header * C++ @@ -66,6 +66,17 @@ struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s) return buf; } +/** Append the contents of @a src to @a dest. + * @param @a dest the destination buffer + * @param @a dest the source buffer + * @return @a dest + */ +struct Buf *buf_concat(struct Buf* dest, const struct Buf* src) +{ + buf_append(dest, src->elts, src->nelts); + return dest; +} + /* Appends n characters in str to buf. */ struct Buf *buf_strnappend (buf, str, n) diff --git a/configure.in b/configure.in index 821596a..2a684b2 100644 --- a/configure.in +++ b/configure.in @@ -60,6 +60,7 @@ else fi dnl checks for libraries +AC_CHECK_LIB(m, log) dnl checks for header files @@ -642,6 +642,10 @@ static void yy_fatal_error YY_PARAMS(( yyconst char msg[] M4_YY_PROTO_LAST_ARG ) %% [4.0] data tables for the DFA and the user's section 1 definitions go here %ok-for-header +m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]]) +M4_YY_SC_DEFS +m4_ifdef( [[M4_YY_IN_HEADER]], [[#endif]]) + /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. @@ -3079,6 +3083,8 @@ int main () #undef yy_set_bol #undef yy_new_buffer #undef yy_set_interactive +#undef yytext_ptr +#undef YY_DO_BEFORE_ACTION #ifdef YY_DECL_IS_OURS #undef YY_DECL_IS_OURS @@ -46,6 +46,7 @@ #include <setjmp.h> #include <ctype.h> #include <string.h> +#include <math.h> #endif #ifdef HAVE_LIMITS_H #include <limits.h> @@ -1082,6 +1083,7 @@ extern void buf_init PROTO ((struct Buf * buf, size_t elem_size)); extern void buf_destroy PROTO ((struct Buf * buf)); extern struct Buf *buf_append PROTO ((struct Buf * buf, const void *ptr, int n_elem)); +extern struct Buf *buf_concat PROTO((struct Buf* dest, const struct Buf* src)); extern struct Buf *buf_strappend PROTO ((struct Buf *, const char *str)); extern struct Buf *buf_strnappend PROTO ((struct Buf *, const char *str, int nchars)); @@ -419,6 +419,22 @@ void check_options () buf_strdefine (&userdef_buf, "YY_INT_ALIGNED", long_align ? "long int" : "short int"); + /* Define the start condition macros. */ + { + struct Buf tmpbuf; + buf_init(&tmpbuf, sizeof(char)); + for (i = 1; i <= lastsc; i++) { + char *str, *fmt = "#define %s %d\n"; + + str = (char*)flex_alloc(strlen(fmt) + strlen(scname[i]) + (int)(1 + log(i)/log(2)) + 2); + sprintf(str, fmt, scname[i], i - 1); + buf_strappend(&tmpbuf, str); + free(str); + } + buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts); + buf_destroy(&tmpbuf); + } + /* Dump the m4 definitions. */ buf_print_strings(&m4defs_buf, stdout); m4defs_buf.nelts = 0; /* memory leak here. */ @@ -467,8 +483,7 @@ void flexend (exit_status) fprintf (header_out, "#undef INITIAL\n#define INITIAL 0\n"); for (i = 2; i <= lastsc; i++) - fprintf (header_out, "#define %s %d\n", scname[i], - i - 1); + fprintf (header_out, "#define %s %d\n", scname[i], i - 1); fprintf (header_out, "#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n"); @@ -243,9 +243,6 @@ void scinstal (str, xcluflg) int xcluflg; { - /* Generate start condition definition, for use in BEGIN et al. */ - action_define (str, lastsc); - if (++lastsc >= current_max_scs) scextend (); |