44 Commits
Author SHA1 Message Date
Eric S. Raymond 585889745c Clean up the indentation and brace usage in the skeleton file.
It was in a mix of several different styles tht made it hard
to read.  I've massaged it all ibto K&R with tabs and mandatory
braces.  No logic changes.
2020-09-27 14:26:29 -04:00
Will Estes f8fd9731d4 build: set dependency info involving cpp-skel.h 2020-09-26 20:09:29 -04:00
Eric S. Raymond 695cab8a1e Fold documentation on how to write bac ends into the Texinfo manual 2020-09-26 20:08:02 -04:00
Eric S. Raymond c842b49f83 Finish the retargeting patch series with a couple of small fixups.
Pull the C mode setting for M4_YYL_BASE into m4.

Use if/then/else extension of m4_ifdef to simplify how yy_flex_debug
is set.  In the process, fix a bug introduced earlier in this patchest
where yy_flex_debug initialization was inverted.

Remove unused skel breakpoints and renumber those left.

Diffs have only commenmt and whitespace changes *except* for the
corrected initialzation of yy_flex_debug.

#40 in the retargeting patch series
2020-09-25 18:09:44 -04:00
Eric S. Raymond 8521281aef indent_puts and friends go away, they're no longer needed.
I did some indentation of the end-of-file case statements with tabs to
make the generated code a bit more readable.  So there are trivial
whitespace diffs in generated code.

#39 in the retargeting patch series
2020-09-25 15:40:03 -04:00
Eric S. Raymond 219db78e6a Last procedural-code generation in C goes to m4.
Diffs are comments and whiespace, as usual.

#38 in the retargeting patch series
2020-09-25 15:26:06 -04:00
Eric S. Raymond efeb6ef019 m4ize the code for handling NUL transitions.
Finally, scavenge trailing skel breakpoints that are no
longer used, as theey no longer carry information.

Diffs in generated code are all comments and whitesoace, as usual

#37 in the retargeting patch series
2020-09-24 20:40:47 -04:00
Eric S. Raymond 31b751703f Chase down some methodization details missed earlier.
No generated-code diffs from this change.

#36 in the retargeting patch series
2020-09-24 06:52:27 -04:00
Eric S. Raymond d7cb3bf631 Dump the state of the m4 conditionals near start of generated code.
Of course, this produces exactly that in diffs.

#35 in the retargeting patch series
2020-09-24 05:14:05 -04:00
Eric S. Raymond 5cb26ac3f9 Conditionalization of the debug flag moves to m4.
Turned out to be mildly trick because %if/%endif pairs have push/pop
behavior rather than combining.

In generated code, the location of the debug declarations moves,
and that's all.

#34 in the retargeting patch series
2020-09-23 22:21:03 -04:00
Eric S. Raymond c9ade3f92b Methodize whether fullspd mode can use a pointer table.
Presently only C can do this.  Otherwise we fall through to storing
numeric indices for a tiny loss of performance.

No generated-code changes from this.

#33 in the retargeting patch series
2020-09-23 19:49:31 -04:00
Eric S. Raymond ca94d99782 m4ize code generation associated with skel breakpoint 11.0.
Moves one table initializer in the generated code, but doesn't alter
it.

Leaves one FIXME. The computation of M4_YYL_BASE really ought to be
done in m4, but for some unknown reason I couldn't beat it into
dping the right thing.  Do be revisited, bu right now finishing
off the last bits of code generation is more important.

#32 in the retargeting patch series
2020-09-23 19:00:56 -04:00
Eric S. Raymond d45bd0692e Code formerly generated at skel breakpoint 8.0 goes to m4.
No generated-code diffs from this change.

#31 in the retargeting patch series
2020-09-23 19:00:56 -04:00
Eric S. Raymond 2eb82096a4 Move code generation of YY_DO_BEFORE_ACTION to m4.
Generated-code diffs are blank lines with ] continuations and
shifted %% commends made by skel breakpoint directives.  I could garbage
collect those, but I plan to do that all at once in a commit of its
own for clarity's sake.

#30 in the retargeting patch series
2020-09-23 19:00:56 -04:00
Eric S. Raymond d694cb8d3f Push C-generated code for YYINPUT to the m4 skeleton.
Diffs in generated code are trivial, a couple of
blank lines with continuations due to % directives.

#29 in the retargeting patch series
2020-09-23 11:24:11 -04:00
Eric S. Raymond 9cfe5b9b09 All the M4_MODE settings now live in one place where they can be audited.
No changes in generated code.

#28 in the retargeting patch series
2020-09-23 10:50:07 -04:00
Eric S. Raymond 0f2a58a818 Partial m4ization of nultrans code.
Also, remove two insertion points in the skel file
that are no longer used because we're now using m4
conditionals instead.

In the generated C, two magic comments from the insertion points go
away.

#27 in the retargeting patch series
2020-09-23 10:20:48 -04:00
Eric S. Raymond b101188a76 Push the definition of struct yy_trans_info out to m4.
Required defining a new method table entry and shuffling the order in
which things are generated a bit, but the generated-code diffs are all
trivial.  Some comments from the previous C code are now in the
skeleton.

#26 in the retargeting patch series
2020-09-22 20:52:58 -04:00
Eric S. Raymond d5574c7387 Banish gcc warnings so errors won't get lost in the clutter. 2020-09-22 18:44:26 -04:00
Eric S. Raymond feeba9873f Tie up loose ends in the abstraction of table initializer syntax...
...and case statements.  Add guidance to backend.adoc.  This is the
"eventually" promised in the comment on #10 of this series.

No diffs in generated code.

#25 in the retargeting patch series
2020-09-22 12:52:32 -04:00
Eric S. Raymond 9a501a4238 Replace last use of gen_next_compressed_state*( with equivalent m4...
...and then inline the code of gen_NUL_trans() at its callsite.  This
contains all remaining procedural code generation in make_tables(),
on the way to moving it to m4.

Generated code diffs are like those of #20 and #22, for the same
reasons.  They add comments, whitespace changes, and uses of the
YY_NUL_EC and YY+JAMSTATE macros equivalent to the old numeric
literals.

#24 in the retargeting patch series
2020-09-22 11:52:50 -04:00
Eric S. Raymond e7b3a67adf Code to do back-up for compressed tables and set up yy_cp goes to m4.
Also, move the yymatch label to the skeleton. Remove an unused
prototype. And fix a typo.

In generated C, comment and whitespace changes only.

#23 in the retargeting patch series
2020-09-22 10:59:30 -04:00
Eric S. Raymond 01f4aaddd9 gen_next_state(true) becomes m4 code.
As with patch #20 in this series, the changes in generated code fall in the classes:

1. Addition of comments.  I elected to copy the comments from the
   generator functions into their corresponding m4 macros in hopes of
   making the generated code less nasty to read.

2. Lines like "if ( yy_current_state >= 12 )" changing so the numeric
   literal is replaced by YY_JAMSTATE + 1. This was a consequence of the
   change in #15 to simplify the C code generators so they could be
   translated into static nacros.

3. "YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : YY_NUL_EC);:
   being replaced by "YY_CHAR yy_c = (*yy_cp ?
   *(yy_ec+YY_SC_TO_UI(*yy_cp)) : YY_NUL_EC);" The strange way of
   indexing yy_ec avoids a syntactic collision with the use of [] as
   m4 quotes.

The gen_next_state(false) case was translated to m4 at patch #20

#22 in the retargeting patch series
2020-09-22 10:51:23 -04:00
Eric S. Raymond e6fa974cd7 gen_bu_action() becomes m4 code.
Also, two GEN_START_STATE calls get inlined in the skeleton file.

Changes in generated C from the tests are all comments and whitespace.

#21 in the retargeting patch series
2020-09-22 06:08:10 -04:00
Eric S. Raymond 30788806b9 gen_next_match() becomes m4 code.
To verify this patch, notice that the non-whitespace changes in the
generated C from the tests are of only three kinds:

1. Addition of comments.  I elected to copy the comments from the
generator functions into their corresponding m4 macros in hopes of
making the generated code less nasty to read.

2. Lines like "if ( yy_current_state >= 12 )" changing so the numeric
literal is replaced by YY_JAMSTATE + 1. This was a consequence of the
change in #15 to simplify the C code generators so they could be
translated into static nacros.

3. "YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]" being replaced by
"YY_CHAR yy_c = *(yy_ec+YY_SC_TO_UI(*yy_cp));".  The strange way of indexing yy_ec
avoids a syntactic collision with the use of [] as m4 quotes.

#20 in the retargeting patch series
2020-09-22 04:47:05 -04:00
Eric S. Raymond 6711981a2d gen_backing_up() becomes an m4 macro.
Generated-code changes consist of whitespace and a comment.

Thus patch also fixes the computation of two guard symbols
that weren't actually used yet, prospectively introduced in
patch #15 of this series. At the time I wrote that I didn't
understand what num_backing_up was doing and failed to
translate it properly.

#19 in the retargeting patch series
2020-09-22 03:16:04 -04:00
Eric S. Raymond abe63d33d1 Push code generation for some housekeeping from gen.c to m4.
The pieces are BOL checking, yylineno updating, and YY_RULE_SETUP
generation.

No generated code changes at all from this.

#18 in the retargeting patch series
2020-09-22 01:32:40 -04:00
Eric S. Raymond feac8a6abf Clean up a couple of methodization loose ends.
Generated-code differences are trivial whitespace.

#17 in the retargeting patch series
2020-09-22 00:14:56 -04:00
Eric S. Raymond 2ab6a3baf7 Move debug code generation from C to m4.
Differences in generated code are trivial. Some integer
literals turn into symbol expressions as a side effect
of the previous patch.

#16 in the retargeting patch series
2020-09-21 23:04:50 -04:00
Eric S. Raymond 90bf7c7bcb Create m4 symbols for things that used to be generated as int literals.
Changes the generated C sources from the tests, but only by making
them easier to read.  In future patches this is going to make them
easier to compare by eyeball as well.

#15 in the retargeting patch series
2020-09-21 22:01:41 -04:00
Eric S. Raymond f858b63e23 Turn gen_start_state() into an M4 macro.
This is the first patch in the retargeting series to substantively
modify the skeleton file.  (The only previous one to touch it just
renamed a mode switch.)

Adds some comments and whitespace to the generated code in the tests,
but produces no logic changes.

#14 in the retargeting patch series
2020-09-21 17:11:29 -04:00
Eric S. Raymond 5f41ac5a99 Create a TESTOPTS variable that can be used to pass options to flex in testing.
Presently this is used to pass -L, making it easier to compare changes
in generared C code cross revisions.

To perform such comparisons, do this at a base (before) revision:

# Make generated code
make clean; (cd tests; make clean); make check

# Save a smashot of it
rm -fr snapshot && mkdir snapshot && cp tests/*.c snapshot

Then rebuild at the later revision and do this:

# Compare gemerated code to snapshot
do diff -b -B -u $x tests/`basename $x`; done

#13 in the retargeting patch series
2020-09-21 10:35:18 -04:00
Eric S. Raymond cd01f7ff4e Remove a redundant macro guard setting....
...and clean up some comments.

Removal should have happened in #11 when the
guard symbol was renamed.

#12 in the retargeting patch series
2020-09-21 00:45:47 -04:00
Eric S. Raymond cdb639cd7b Add code to initialize the macro conditional symbols we'll need.
These aren't used yet.  They will be as we push code feneration out
of gen.c into the epansion of the m4 skeleton.

This is the first revision to touch the C skeleton file, changing
M4_YY_USES_REJECT to M4_MODE_USES_REJECT for uniformity with the other
mode switches.

C code generated from the tests is still unchanged at this revision.

#11 in the retargeting patch series
2020-09-21 00:21:42 -04:00
Eric S. Raymond ef4f78f43b Continue methodization, with some target-language-specific formats...
...and one additional method.

This almost finushes off all language-specfic detauks outside of
gen.c.  The one exception is just below the comment "add terminator
for initialization" in dfa.c; we'll get to this eventually.

#10 in the retargeting patch series
2020-09-21 00:05:05 -04:00
Eric S. Raymond c0ca7faab9 Two member name changes in the method table.
Cosmetic change,

#9 in the retargeting patch series
2020-09-20 23:17:00 -04:00
Eric S. Raymond e58cdd1de0 Start a HOWTO on writing target-language back ends.
#8 in the retargeting patch series
2020-09-20 22:38:31 -04:00
Eric S. Raymond 673f2caf34 Methodize generation of C initializers for automaton tables.
A large patch, but conceptually simple. Takes a bunch of functions and
callsites that knew details of C initializer and declaration syntax
and moves them into methods in the C backend table.

This is a pure refactoring step.  At this point in the patch series,
not only do all tests pass but nothing in the lex-generated C code
from the tests has changed.

#7 in the retargeting patch series
2020-09-20 21:55:07 -04:00
Eric S. Raymond 2cce209b58 The C/C++ back end moves to its own source file.
Someday, there might be go-backend.c etc.

#6 in the retargeting patch series
2020-09-20 20:52:01 -04:00
Eric S. Raymond bb9f458eb1 Generated skel data is now stuffed in an array in the C/C++ back end.
This means it's possible to have multiple language-specific skel
files.  All go through the same double m4 macroexpansion.

#5 in the retargeting patch series
2020-09-20 20:52:01 -04:00
Eric S. Raymond f754c608ff Pull the format for error-tracking lines into the method table.
#4 in the retargeting patch series.
2020-09-20 18:36:39 -04:00
Eric S. Raymond f1bfe65b3d Create a method table for the C back end,
#3 in the retargeting patch series.
2020-09-20 18:36:39 -04:00
Eric S. Raymond a05e39ae47 Factor out the wrap function for C/C++ parser generation.
#2 in the retargeting patch series.
2020-09-20 18:36:39 -04:00
Eric S. Raymond f0161f217e Refactoring step - separate output generation from option processing.
#1 in the retargeting patch series.
2020-09-20 18:36:39 -04:00
13 changed files with 2674 additions and 2688 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ MAINTAINERCLEANFILES = flex.1
CLEANFILES = *.aux *.cp *.cps *.fn *.fns *.hk *.hks *.ky *.log \
*.op *.ops *.pg *.toc *.tp *.tps *.vr *.vrs
flex.1: $(top_srcdir)/configure.ac $(top_srcdir)/src/flex.skl $(top_srcdir)/src/options.c $(top_srcdir)/src/options.h | $(FLEX)
flex.1: $(top_srcdir)/configure.ac $(top_srcdir)/src/cpp-flex.skl $(top_srcdir)/src/options.c $(top_srcdir)/src/options.h | $(FLEX)
$(HELP2MAN) --name='$(PACKAGE_NAME)' --section=1 \
--source='The Flex Project' --manual='Programming' \
--output=$@ $(FLEX) \
+119 -9
View File
@@ -192,7 +192,7 @@ FAQ
* How can I build a two-pass scanner?::
* How do I match any string not matched in the preceding rules?::
* I am trying to port code from AT&T lex that uses yysptr and yysbuf.::
* Is there a way to make flex treat NULL like a regular character?::
* Is there a way to make flex treat NUL like a regular character?::
* Whenever flex can not match the input it says "flex scanner jammed".::
* Why doesn't flex have non-greedy operators like perl does?::
* Memory leak - 16386 bytes allocated by malloc.::
@@ -269,6 +269,7 @@ Appendices
* Bison Bridge::
* M4 Dependency::
* Common Patterns::
* Adding More Target Languages
Indices
@@ -734,7 +735,7 @@ if X is @samp{a}, @samp{b}, @samp{f}, @samp{n}, @samp{r}, @samp{t}, or
@samp{v}, then the ANSI-C interpretation of @samp{\x}. Otherwise, a
literal @samp{X} (used to escape operators such as @samp{*})
@cindex NULL character in patterns, syntax of
@cindex NUL character in patterns, syntax of
@item \0
a NUL character (ASCII code 0)
@@ -5148,10 +5149,10 @@ the version of flex that was used to create the serialized tables.
@item th_name[]
Contains the name of this table set. The default is @samp{yytables},
and is prefixed accordingly, e.g., @samp{footables}. Must be NULL-terminated.
and is prefixed accordingly, e.g., @samp{footables}. Must be NUL-terminated.
@item th_pad64[]
Zero or more NULL bytes, padding the entire header to the next 64-bit boundary
Zero or more NUL bytes, padding the entire header to the next 64-bit boundary
as calculated from the beginning of the header.
@end table
@@ -5239,7 +5240,7 @@ The table data. This array may be a one- or two-dimensional array, of type
@code{td_flags}, @code{td_hilen}, and @code{td_lolen} fields.
@item td_pad64[]
Zero or more NULL bytes, padding the entire table to the next 64-bit boundary as
Zero or more NUL bytes, padding the entire table to the next 64-bit boundary as
calculated from the beginning of this table.
@end table
@@ -5447,7 +5448,7 @@ publish them here.
* How can I build a two-pass scanner?::
* How do I match any string not matched in the preceding rules?::
* I am trying to port code from AT&T lex that uses yysptr and yysbuf.::
* Is there a way to make flex treat NULL like a regular character?::
* Is there a way to make flex treat NUL like a regular character?::
* Whenever flex can not match the input it says "flex scanner jammed".::
* Why doesn't flex have non-greedy operators like perl does?::
* Memory leak - 16386 bytes allocated by malloc.::
@@ -6060,8 +6061,8 @@ what they're doing, and then replace @code{input()} with an appropriate definiti
@code{YY_INPUT}. You shouldn't need to (and must not) replace
@code{flex}'s @code{unput()} function.
@node Is there a way to make flex treat NULL like a regular character?
@unnumberedsec Is there a way to make flex treat NULL like a regular character?
@node Is there a way to make flex treat NUL like a regular character?
@unnumberedsec Is there a way to make flex treat NUL like a regular character?
Yes, @samp{\0} and @samp{\x00} should both do the trick. Perhaps you have an ancient
version of @code{flex}. The latest release is version @value{VERSION}.
@@ -7697,6 +7698,7 @@ to declare local variables.
@end example
@c TODO: Evaluate this faq.
@c Note that the file is now named cpp-flex.skl
@node unnamed-faq-87
@unnumberedsec unnamed-faq-87
@example
@@ -8166,6 +8168,7 @@ See @ref{Top, , , bison, the GNU Bison Manual}.
* Bison Bridge::
* M4 Dependency::
* Common Patterns::
* Retargeting Flex::
@end menu
@node Makefiles and Flex, Bison Bridge, Appendices, Appendices
@@ -8412,7 +8415,7 @@ removing such sequences from your code.
@code{m4} is only required at the time you run @code{flex}. The generated
scanner is ordinary C or C++, and does @emph{not} require @code{m4}.
@node Common Patterns, ,M4 Dependency, Appendices
@node Common Patterns,Retargeting Flex,M4 Dependency, Appendices
@section Common Patterns
@cindex patterns, common
@@ -8560,6 +8563,113 @@ to appear in a URI, including spaces and control characters. See
@end table
@node Retargeting Flex, ,Common Patterns, Appendices
@section Retargeting Flex
@cindex retargeting
@cindex language independence
This appendix describes how to add support for a new target language
to Flex.
The flex code has been factored to isolate knowledge of the specifics
of each target language from the logic for building the lexer state
tables.
The only assumption that is absolutely baked into all of Flex is that
the bodies of initializers for arrays of integers consist of decimal
numeric literals separated by commas (and optional whitespace).
Otherwise, knowledge of each target langage's syntax lives in two
places: (1) a table of language-specific syntax-generator methods,
and (2) A language-specific skeleton file.
For example: The methods for the C and C++ back end live in a source
file named @file{cpp_backend.c} (so named because both languages use the C
preprocessor), and in a skeleton file named @file{cpp-flex.skl}.
All the code that accesses language-specific code generators goes
through a global pointer named "backend" to a method table. The
results of these generators are used to fill in some parts of the
language-specific skeleton file and conditionalize others.
Read the definition of struct backend_t in @file{src/flexdefs.h}, and
attached comments, to get a feel for the methods. Don't worry
about understandng table generator names at first.
To write support for a language, you'll want to do the following
steps:
@enumerate
@item
Clone one of the existing back-end/skeleton pairs. If the language
you are supporting is named @var{foo}, you should create files named
@file{foo_backend.c} and @file{foo-flex.skl}.
@item
Add @file{foo_backend.c} to COMMON_SOURCES in @file{src/Makefile.am}. Add the
name of your skeleton file to EXTRA_DIST.
@item
Add a production to @file{src/Makefile.am} parallel to the one that
produces @file{cpp-skel.h}. Your objective is to make a string list
initializer from your skeleton file that can be linked with flex and
is pointed at by the skel nember of your language back end.
@item
Add some logic to @file{main.c} that enables the new back end with a
new command-line option. Following this step you should be
able to run Flex on a specification and get code out in the
language of whatever back end you cloned.
@item
The interesting part: mutate your new back end and skeleton so they
produce code in your desired target langage.
@item
Add a test suite for your back end. You should be able to clone
one of the existing sets of test loads to get good coverage. Note
that is highly unlikely your back end will be accepted into the
flex distribution without a test suite.
@end enumerate
Syntactically C-like languages such as Go, Rust, and Java should be easy
targets. Almost anything generally descended from Algol shouldn't be
much more difficult; this certainly includes the whole
Pascal/Modula/Oberon family.
A hint about the interesting part:
@itemize
@item
Don't bother supporting non-reentrant parser generation.
The interface of original Lex with all those globals hanging out
needs to be supported in C for backwards compatibility, but
there is no need to carry it forward.
@end itemize
The following assumptions in the code might trip you up and
require fixes outside a back end.
@enumerate
@item
The item separator in data initializers is a comma.
@item
The language has a case-arm syntax that looks like
a (possibly empty) prefix, followed by a value
expression, followed by a colon.
@item
Either case arms can be stacked as in C; that is, there is
an implicit fallthrough if the case arm has no code. Or,
there is an explicit fallthrough keyword that enables this,
as in Go.
@end enumerate
By putting a @code{yyterminate()} call in the fallthrough member
and a null pointer in the endcase member, you could handle
languages like Pascal.
@node Indices, , Appendices, Top
@unnumbered Indices
+1 -1
View File
@@ -8,6 +8,6 @@ libfl.pc
parse.c
parse.h
scan.c
skel.c
cpp-skel.h
stage1scan.[cl]
stage1flex
+9 -6
View File
@@ -46,6 +46,7 @@ flex_SOURCES = \
$(COMMON_SOURCES)
nodist_flex_SOURCES = \
cpp-skel.h \
stage1scan.c
flex_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS)
@@ -53,6 +54,7 @@ flex_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS)
COMMON_SOURCES = \
buf.c \
ccl.c \
cpp_backend.c \
dfa.c \
ecs.c \
filter.c \
@@ -70,7 +72,6 @@ COMMON_SOURCES = \
scanflags.c \
scanopt.c \
scanopt.h \
skel.c \
sym.c \
tables.c \
tables.h \
@@ -88,16 +89,18 @@ include_HEADERS = \
FlexLexer.h
EXTRA_DIST = \
flex.skl \
cpp-flex.skl \
mkskel.sh \
gettext.h
CLEANFILES = stage1scan.c stage1flex$(EXEEXT)
CLEANFILES = stage1scan.c stage1flex$(EXEEXT) cpp-skel.h
MAINTAINERCLEANFILES = skel.c
MAINTAINERCLEANFILES = c9pp-skel.h
skel.c: flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c
$(SHELL) $(srcdir)/mkskel.sh $(srcdir) $(m4) $(VERSION) > $@.tmp
flex-cpp_backend.$(OBJEXT): cpp-skel.h
cpp-skel.h: cpp-flex.skl mkskel.sh flexint_shared.h tables_shared.h tables_shared.c
$(SHELL) $(srcdir)/mkskel.sh cpp $(srcdir) $(m4) $(VERSION) > $@.tmp
mv -f $@.tmp $@
if ENABLE_BOOTSTRAP
File diff suppressed because it is too large Load Diff
+639
View File
@@ -0,0 +1,639 @@
/* flex - tool to generate fast lexical analyzers */
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
/* This code is derived from software contributed to Berkeley by */
/* Vern Paxson. */
/* The United States Government has rights in this work pursuant */
/* to contract no. DE-AC03-76SF00098 between the United States */
/* Department of Energy and the University of California. */
/* This file is part of flex. */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* 1. Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* Neither the name of the University nor the names of its contributors */
/* may be used to endorse or promote products derived from this software */
/* without specific prior written permission. */
/* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
/* PURPOSE. */
#include "flexdef.h"
/* Code specific to the C/C++ back end starts here */
static const char *cpp_suffix (void)
{
char *suffix;
if (C_plus_plus)
suffix = "cc";
else
suffix = "c";
return suffix;
}
/* cpp_prolog - make rules prolog specific to cpp-using languages.
*
* If you don't ship this, you will effectively be assuming that your
* parsers are always reentrant, always allow reject, always have a
* yywrap() method, have a debug member in the wrapper class, and are
* interactive. This eliminates most of the boilerplate in the C/C++
* scanner prolog. It means such parsers will be a bit larger and
* slower than C/C++ ones, but since we're not running on 1987's
* hardware we officially do not care.
*
* A detail to beware of: If you're not issuing this prologue, you may
* want to write your own definition of YY_CHAR in your skel
* file. It's a typedef to an unsigned octet in C/C++, but if your
* target language has a Unicode code-point type like Go's 'rune' is
* may be appropriate.
*/
static void cpp_prolog (void)
{
static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;";
static char yy_nostdinit[] =
"FILE *yyin = NULL, *yyout = NULL;";
if (!do_yywrap) {
if (!C_plus_plus) {
if (reentrant)
out_str ("\n#define %swrap(yyscanner) (/*CONSTCOND*/1)\n", prefix);
else
out_str ("\n#define %swrap() (/*CONSTCOND*/1)\n", prefix);
}
outn ("#define YY_SKIP_YYWRAP");
}
if (ddebug)
outn ("\n#define FLEX_DEBUG");
OUT_BEGIN_CODE ();
outn ("typedef flex_uint8_t YY_CHAR;");
OUT_END_CODE ();
if (C_plus_plus) {
outn ("#define yytext_ptr yytext");
if (interactive)
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");
}
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);
}
OUT_END_CODE ();
}
OUT_BEGIN_CODE ();
if (fullspd)
outn ("typedef const struct yy_trans_info *yy_state_type;");
else if (!C_plus_plus)
outn ("typedef int yy_state_type;");
OUT_END_CODE ();
if (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 ();
}
if (C_plus_plus) {
outn ("\n#include <FlexLexer.h>");
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);
}
}
else {
/* 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 {
if (reentrant) {
outn ("#define yytext_ptr yytext_r");
}
else {
outn ("extern char *yytext;");
outn("#ifdef yytext_ptr");
outn("#undef yytext_ptr");
outn("#endif");
outn ("#define yytext_ptr yytext");
}
}
if (yyclass)
flexerror (_
("%option yyclass only meaningful for C++ scanners"));
}
}
static void cpp_epilog (void)
{
#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",
"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",
"const",
"yyextra",
"yyfree",
"yyget_debug",
"yyget_extra",
"yyget_in",
"yyget_leng",
"yyget_column",
"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_column",
"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,
"#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))
lerr (_("error creating header file %s"),
headerfilename);
fflush (header_out);
fclose (header_out);
#endif
}
static const char *cpp_yy_int_aligned(void)
{
return long_align ? "long int" : "short int";
}
static void cpp_comment(const char *txt)
{
out_str("/* [[%s]] */\n", txt);
}
static const char *cpp_get_int16_decl (void)
{
return (gentables)
? "static const flex_int16_t %s[%d] =\n { 0,\n"
: "static const flex_int16_t * %s = 0;\n";
}
static const char *cpp_get_int32_decl (void)
{
return (gentables)
? "static const flex_int32_t %s[%d] =\n { 0,\n"
: "static const flex_int32_t * %s = 0;\n";
}
static const char *cpp_get_state_decl (void)
{
return (gentables)
? "static const yy_state_type %s[%d] =\n { 0,\n"
: "static const yy_state_type * %s = 0;\n";
}
static const char *cpp_get_yy_char_decl (void)
{
return (gentables)
? "static const YY_CHAR %s[%d] =\n { 0,\n"
: "static const YY_CHAR * %s = 0;\n";
}
static void cpp_ntod(size_t num_full_table_rows)
// Generate nxt table for ntod
{
buf_prints (&yydmap_buf,
"\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n",
long_align ? "flex_int32_t" : "flex_int16_t");
/* Unless -Ca, declare it "short" because it's a real
* long-shot that that won't be large enough.
*/
if (gentables)
out_str_dec
("static const %s yy_nxt[][%d] =\n {\n",
long_align ? "flex_int32_t" : "flex_int16_t",
num_full_table_rows);
else {
out_dec ("#undef YY_NXT_LOLEN\n#define YY_NXT_LOLEN (%d)\n", num_full_table_rows);
out_str ("static const %s *yy_nxt =0;\n",
long_align ? "flex_int32_t" : "flex_int16_t");
}
}
static void cpp_mkeoltbl()
// Make end-of-line-table - only used when yylinemo tracking is on
{
buf_prints (&yydmap_buf,
"\t{YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(%s)},\n",
"flex_int32_t");
}
static void cpp_geneoltbl(size_t sz)
// Generate end-of-line-transitions - only used when yylineno tracking is on
{
outn ("/* Table of booleans, true if rule could match eol. */");
out_str_dec (cpp_get_int32_decl (), "yy_rule_can_match_eol", sz);
}
static void cpp_mkctbl (size_t sz)
// Make full-speed compressed transition table
{
buf_prints (&yydmap_buf,
"\t{YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(%s)},\n",
(sz >= INT16_MAX
|| long_align) ? "flex_int32_t" : "flex_int16_t");
}
static void cpp_mkssltbl (void)
// Make start_state_list table
{
buf_prints (&yydmap_buf,
"\t{YYTD_ID_START_STATE_LIST, (void**)&yy_start_state_list, sizeof(%s)},\n",
"struct yy_trans_info*");
}
static void cpp_gen_yy_trans(size_t sz)
// Table of verify for transition and offset to next state. (sic)
{
if (gentables)
out_dec ("static const struct yy_trans_info yy_transition[%d] =\n {\n", sz);
else
outn ("static const struct yy_trans_info *yy_transition = 0;");
}
static void cpp_start_state_list(size_t sz)
// Start initializer for table of pointers to start state
{
/* Table of pointers to start states. */
if (gentables)
out_dec ("static const struct yy_trans_info *yy_start_state_list[%d] =\n", sz);
else
outn ("static const struct yy_trans_info **yy_start_state_list =0;");
}
static void cpp_mkecstbl(void)
// Make equivalence-class tables
{
buf_prints (&yydmap_buf,
"\t{YYTD_ID_EC, (void**)&yy_ec, sizeof(%s)},\n",
"YY_CHAR");
}
static void cpp_mkftbl(void)
// Make full table
{
buf_prints (&yydmap_buf,
"\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n",
long_align ? "flex_int32_t" : "flex_int16_t");
}
static void cpp_gentabs_acclist(void)
// Generate accept list initializer
{
buf_prints (&yydmap_buf,
"\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n",
long_align ? "flex_int32_t" : "flex_int16_t");
}
static void cpp_gentabs_accept(void)
// Generate accept table initializer
{
buf_prints (&yydmap_buf,
"\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n",
long_align ? "flex_int32_t" : "flex_int16_t");
}
static void cpp_gentabs_yy_meta(void)
// Generate yy_meta table initializer
{
buf_prints (&yydmap_buf,
"\t{YYTD_ID_META, (void**)&yy_meta, sizeof(%s)},\n",
"YY_CHAR");
}
static void cpp_gentabs_yy_base(void)
// Generate yy_meta base initializer
{
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");
}
static void cpp_gentabs_yy_def(size_t total_states)
// Generate yy_def initializer
{
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");
}
static void cpp_gentabs_yy_nxt(size_t total_states)
// Generate yy_nxt initializer
{
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");
}
static void cpp_gentabs_yy_chk(size_t total_states)
// Generate yy_chk initializer
{
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");
}
static void cpp_nultrans(int fullspd)
// Generate nulltrans initializer
{
// Making this a backend method may be overzealous.
// How many other languages have to sprcial-case NUL
// because it's a string terminator?
buf_prints (&yydmap_buf,
"\t{YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(%s)},\n",
(fullspd) ? "struct yy_trans_info*" :
"flex_int32_t");
}
static const char *cpp_trans_offset_type(int total_table_size)
{
return (total_table_size >= INT16_MAX || long_align) ?
"flex_int32_t" : "flex_int16_t";
}
const char *cpp_skel[] = {
#include "cpp-skel.h"
0,
};
/* This backend is only accessed through this method table */
struct flex_backend_t cpp_backend = {
.suffix = cpp_suffix,
.prolog = cpp_prolog,
.skel = cpp_skel,
.epilog = cpp_epilog,
.yy_int_aligned = cpp_yy_int_aligned,
.trace_fmt = "#line %d \"%s\"\n",
.int_define_fmt = "#define %s %d\n",
.string_define_fmt = "#define %s %s\n",
.table_opener = " {",
.table_continuation = " },\n",
.table_closer = " };\n",
.dyad = " {%4d,%4d },",
.comment = cpp_comment,
.get_int16_decl = cpp_get_int16_decl,
.get_int32_decl = cpp_get_int32_decl,
.get_state_decl = cpp_get_state_decl,
.get_yy_char_decl = cpp_get_yy_char_decl,
.ntod = cpp_ntod,
.mkeoltbl = cpp_mkeoltbl,
.geneoltbl = cpp_geneoltbl,
.mkctbl = cpp_mkctbl,
.mkssltbl = cpp_mkssltbl,
.gen_yy_trans = cpp_gen_yy_trans,
.start_state_list = cpp_start_state_list,
.state_entry_fmt = " &yy_transition[%d],\n",
.mkecstbl = cpp_mkecstbl,
.mkftbl = cpp_mkftbl,
.gentabs_acclist = cpp_gentabs_acclist,
.gentabs_accept = cpp_gentabs_accept,
.gentabs_yy_meta = cpp_gentabs_yy_meta,
.gentabs_yy_base = cpp_gentabs_yy_base,
.gentabs_yy_def = cpp_gentabs_yy_def,
.gentabs_yy_nxt = cpp_gentabs_yy_nxt,
.gentabs_yy_chk = cpp_gentabs_yy_chk,
.nultrans = cpp_nultrans,
.trans_offset_type = cpp_trans_offset_type,
.caseprefix = "case ",
.fallthrough = NULL,
.endcase = "yyterminate();",
.c_like = 1,
};
+5 -24
View File
@@ -517,27 +517,10 @@ void ntod (void)
sizeof (flex_int32_t));
yynxt_curr = 0;
buf_prints (&yydmap_buf,
"\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n",
long_align ? "flex_int32_t" : "flex_int16_t");
/* Unless -Ca, declare it "short" because it's a real
* long-shot that that won't be large enough.
*/
if (gentables)
out_str_dec
("static const %s yy_nxt[][%d] =\n {\n",
long_align ? "flex_int32_t" : "flex_int16_t",
num_full_table_rows);
else {
out_dec ("#undef YY_NXT_LOLEN\n#define YY_NXT_LOLEN (%d)\n", num_full_table_rows);
out_str ("static const %s *yy_nxt =0;\n",
long_align ? "flex_int32_t" : "flex_int16_t");
}
backend->ntod(num_full_table_rows);
if (gentables)
outn (" {");
outn (backend->table_opener);
/* Generate 0 entries for state #0. */
for (i = 0; i < num_full_table_rows; ++i) {
@@ -547,7 +530,7 @@ void ntod (void)
dataflush ();
if (gentables)
outn (" },\n");
outn (backend->table_continuation);
}
/* Create the first states. */
@@ -700,10 +683,8 @@ void ntod (void)
yynxt_tbl->td_hilen *
yynxt_tbl->td_lolen *
sizeof (flex_int32_t));
if (gentables)
outn (" {");
outn (backend->table_opener);
/* Supply array's 0-element. */
if (ds == end_of_buffer_state) {
@@ -728,7 +709,7 @@ void ntod (void)
dataflush ();
if (gentables)
outn (" },\n");
out (backend->table_continuation);
}
else if (fullspd)
+54 -25
View File
@@ -303,6 +303,56 @@
*/
#define MAX_SHORT 32700
/* Method table describing a language-specific back end */
struct flex_backend_t {
const char *(*suffix)(void); // Generate suffix for lexer source code
void (*prolog)(void);
const char **skel;
void (*epilog)(void);
const char *(*yy_int_aligned)(void); // Generate aligned type for this back end
char *trace_fmt; // Trace message format
// Language syntax generation
char *int_define_fmt; // Format for integer constant definitions
char *string_define_fmt; // Format for string constant definitions
char *table_opener; // Open an array initializer with this
char *table_continuation; // Open an array initializer with this
char *table_closer; // How to continue a two-level initializer
char *dyad; // How to format and int[2] initializer
void (*comment)(const char *); // Wrap a comment line
const char *(*get_int16_decl)(void); // Format for declaring array initializer of int16s
const char *(*get_int32_decl)(void); // Format for declaring array initializer of int32s
const char *(*get_state_decl)(void); // Format for declaring array initializer of state values
const char *(*get_yy_char_decl)(void); // Format for declaring array initializer of input chars
// Flex table generation
void (*ntod)(size_t); // Generate nxt table for ntod
void (*mkeoltbl)(void); // Make end-of-line table
void (*geneoltbl)(size_t); // Generate end-of-line transitions
void (*mkctbl)(size_t); // Make full-speed compressed table
void (*mkssltbl)(void); // Make start_state_list table
void (*gen_yy_trans)(size_t); // Table of verify for transition and offset to next state. (sic)
void (*start_state_list)(size_t); // Start initializer for table of pointers to start states
void (*mkftbl)(); // Make full table
const char *state_entry_fmt; // Format of state table entry
void (*mkecstbl)(void); // Make equivalence-class tables
void (*gentabs_acclist)(void); // Generate accept list initializer
void (*gentabs_accept)(void); // Generate accept table initializer
void (*gentabs_yy_meta)(void); // Generate yy_meta table initializer
void (*gentabs_yy_base)(void); // Generate yy_base table initializer
void (*gentabs_yy_def)(size_t); // Generate yy_def initializer
void (*gentabs_yy_nxt)(size_t); // Generate yy_nxt initializer
void (*gentabs_yy_chk)(size_t); // Generate yy_chk initializer
void (*nultrans)(int); // Generate nulltrans initializer
const char *(*trans_offset_type)(int); // Compute an efficient type for transition tables
char *caseprefix; // Prefix of an arm in the language's case construct
char *fallthrough; // Finish a case arm with this to fall through
char *endcase; // What to ship after all EOF-state case arms
int c_like; // Will &yy_transition[%d]," produce a pointer table entry?
};
extern bool gentables;
extern struct flex_backend_t cpp_backend;
/* Declarations for global variables. */
@@ -369,6 +419,8 @@ extern int yymore_used, reject, real_reject, continued_action, in_rule;
extern int yymore_really_used, reject_really_used;
extern int trace_hex;
extern struct flex_backend_t *backend;
/* Variables used in the flex input routines:
* datapos - characters on current output line
* dataline - number of contiguous lines of data in current data
@@ -732,34 +784,11 @@ extern void mkechar(int, int[], int[]);
extern void do_indent(void); /* indent to the current level */
/* Generate the code to keep backing-up information. */
extern void gen_backing_up(void);
/* Generate the code to perform the backing up. */
extern void gen_bu_action(void);
/* Generate full speed compressed transition table. */
extern void genctbl(void);
/* Generate the code to find the action number. */
extern void gen_find_action(void);
extern void genftbl(void); /* generate full transition table */
/* Generate the code to find the next compressed-table state. */
extern void gen_next_compressed_state(char *);
/* Generate the code to find the next match. */
extern void gen_next_match(void);
/* Generate the code to find the next state. */
extern void gen_next_state(int);
/* Generate the code to make a NUL transition. */
extern void gen_NUL_trans(void);
/* Generate the code to find the start state. */
extern void gen_start_state(void);
/* generate full transition table */
extern void genftbl(void);
/* Generate data statements for the transition tables. */
extern void gentabs(void);
+220 -1195
View File
File diff suppressed because it is too large Load Diff
+50 -371
View File
@@ -46,7 +46,6 @@ void flexinit(int, char **);
void readin(void);
void set_up_initial_allocations(void);
/* 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,
@@ -107,6 +106,8 @@ jmp_buf flex_main_jmp_buf;
bool *rule_has_nl, *ccl_has_nl;
int nlch = '\n';
struct flex_backend_t *backend;
bool tablesext, tablesverify, gentables;
char *tablesfilename=0,*tablesname=0;
struct yytbl_writer tableswr;
@@ -169,6 +170,9 @@ int flex_main (int argc, char *argv[])
readin ();
if (backend->prolog)
backend->prolog ();
skelout ();
/* %% [1.5] DFA */
ntod ();
@@ -317,15 +321,8 @@ void check_options (void)
FILE *prev_stdout;
if (!did_outfilename) {
char *suffix;
if (C_plus_plus)
suffix = "cc";
else
suffix = "c";
snprintf (outfile_path, sizeof(outfile_path), outfile_template,
prefix, suffix);
prefix, backend->suffix());
outfilename = outfile_path;
}
@@ -457,42 +454,44 @@ void check_options (void)
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");
buf_strdefine (&userdef_buf, "YY_INT_ALIGNED", backend->yy_int_aligned());
/* 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;
/* Define the start condition macros. */
{
struct Buf tmpbuf;
buf_init(&tmpbuf, sizeof(char));
for (i = 1; i <= lastsc; i++) {
char *str, *fmt = backend->int_define_fmt;
size_t strsz;
strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2;
str = malloc(strsz);
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);
}
strsz = strlen(fmt) + strlen(scname[i]) + (size_t)(1 + ceil (log10(i))) + 2;
str = malloc(strsz);
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. */
/* This is where we begin writing to the file. */
/* Dump the %top code. */
if( top_buf.elts)
outn((char*) top_buf.elts);
/* 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. */
/* 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. */
if (gen_line_dirs)
outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
/* Place a bogus line directive, it will be fixed in the filter. */
if (gen_line_dirs && backend->trace_fmt) {
char buf2[4096];
snprintf(buf2, sizeof(buf2), backend->trace_fmt, 0, "M4_YY_OUTFILE_NAME");
outn(buf2);
}
/* Dump the user defined preproc directives. */
if (userdef_buf.elts)
@@ -526,193 +525,8 @@ void flexend (int exit_status)
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",
"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",
"const",
"yyextra",
"yyfree",
"yyget_debug",
"yyget_extra",
"yyget_in",
"yyget_leng",
"yyget_column",
"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_column",
"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,
"#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))
lerr (_("error creating header file %s"),
headerfilename);
fflush (header_out);
fclose (header_out);
#endif
if (backend->epilog)
backend->epilog();
if (exit_status != 0 && outfile_created) {
if (ferror (stdout))
@@ -1275,24 +1089,16 @@ void flexinit (int argc, char **argv)
{
/* arg is "symbol" or "symbol=definition". */
char *def;
char buf2[4096];
for (def = arg;
*def != '\0' && *def != '='; ++def) ;
*def != '\0' && *def != '='; ++def)
continue;
if (*def == '\0')
def = "1";
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,
(int) (def - arg));
buf_strappend (&userdef_buf, " ");
buf_strappend (&userdef_buf,
def + 1);
buf_strappend (&userdef_buf, "\n");
}
snprintf(buf2, sizeof(buf2), backend->string_define_fmt, arg, def);
buf_strappend (&userdef_buf, buf2);
}
break;
@@ -1474,6 +1280,8 @@ void flexinit (int argc, char **argv)
lastprot = 1;
set_up_initial_allocations ();
backend = &cpp_backend;
}
@@ -1481,10 +1289,6 @@ void flexinit (int argc, char **argv)
void readin (void)
{
static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;";
static char yy_nostdinit[] =
"FILE *yyin = NULL, *yyout = NULL;";
line_directive_out(NULL, 1);
if (yyparse ()) {
@@ -1594,131 +1398,6 @@ void readin (void)
("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 (!do_yywrap) {
if (!C_plus_plus) {
if (reentrant)
out_str ("\n#define %swrap(yyscanner) (/*CONSTCOND*/1)\n", prefix);
else
out_str ("\n#define %swrap() (/*CONSTCOND*/1)\n", prefix);
}
outn ("#define YY_SKIP_YYWRAP");
}
if (ddebug)
outn ("\n#define FLEX_DEBUG");
OUT_BEGIN_CODE ();
outn ("typedef flex_uint8_t YY_CHAR;");
OUT_END_CODE ();
if (C_plus_plus) {
outn ("#define yytext_ptr yytext");
if (interactive)
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");
}
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);
}
OUT_END_CODE ();
}
OUT_BEGIN_CODE ();
if (fullspd)
outn ("typedef const struct yy_trans_info *yy_state_type;");
else if (!C_plus_plus)
outn ("typedef int yy_state_type;");
OUT_END_CODE ();
if (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 ();
}
if (C_plus_plus) {
outn ("\n#include <FlexLexer.h>");
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);
}
}
else {
/* 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 {
if (reentrant) {
outn ("#define yytext_ptr yytext_r");
}
else {
outn ("extern char *yytext;");
outn("#ifdef yytext_ptr");
outn("#undef yytext_ptr");
outn("#endif");
outn ("#define yytext_ptr yytext");
}
}
if (yyclass)
flexerror (_
("%option yyclass only meaningful for C++ scanners"));
}
if (useecs)
numecs = cre8ecs (nextecm, ecgroup, csize);
else
@@ -1732,7 +1411,6 @@ void readin (void)
ccl2ecl ();
}
/* set_up_initial_allocations - allocate memory for internal tables */
void set_up_initial_allocations (void)
@@ -1863,3 +1541,4 @@ void usage (void)
backing_name, "flex", outfile_path, "flex");
}
+10 -10
View File
@@ -260,7 +260,7 @@ void dataend (void)
dataflush ();
/* add terminator for initialization; { for vi */
outn (" } ;\n");
outn (backend->table_closer);
}
dataline = 0;
datapos = 0;
@@ -343,7 +343,6 @@ void line_directive_out (FILE *output_file, int do_infile)
{
char directive[MAXLINE*2], filename[MAXLINE];
char *s1, *s2, *s3;
static const char line_fmt[] = "#line %d \"%s\"\n";
if (!gen_line_dirs)
return;
@@ -366,11 +365,12 @@ void line_directive_out (FILE *output_file, int do_infile)
*s2 = '\0';
if (do_infile)
snprintf (directive, sizeof(directive), line_fmt, linenum, filename);
else {
snprintf (directive, sizeof(directive), line_fmt, 0, filename);
}
if (backend->trace_fmt)
if (do_infile)
snprintf (directive, sizeof(directive), backend->trace_fmt, linenum, filename);
else {
snprintf (directive, sizeof(directive), backend->trace_fmt, 0, filename);
}
/* If output_file is nil then we should put the directive in
* the accumulated actions.
@@ -702,11 +702,11 @@ void skelout (void)
/* Loop pulling lines either from the skelfile, if we're using
* one, or from the skel[] array.
* one, or from the selected back end's skel[] array.
*/
while (skelfile ?
(fgets (buf, MAXLINE, skelfile) != NULL) :
((buf = (char *) skel[skel_ind++]) != 0)) {
((buf = (char *) backend->skel[skel_ind++]) != 0)) {
if (skelfile)
chomp (buf);
@@ -827,7 +827,7 @@ void transition_struct_out (int element_v, int element_n)
if (!gentables)
return;
out_dec2 (" {%4d,%4d },", element_v, element_n);
out_dec2 (backend->dyad, element_v, element_n);
datapos += TRANS_STRUCT_PRINT_LENGTH;
+7 -14
View File
@@ -21,18 +21,14 @@
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
if test ! $# = 3; then
echo 'Usage: mkskel.sh srcdir m4 version' >&2
if test ! $# = 4; then
echo 'Usage: mkskel.sh lang srcdir m4 version' >&2
exit 1
fi
echo '/* File created from flex.skl via mkskel.sh */
#include "flexdef.h"
const char *skel[] = {'
srcdir=$1
m4=$2
VERSION=$3
lang=$1
srcdir=$2
m4=$3
VERSION=$4
case $VERSION in
*[!0-9.]*) echo 'Invalid version number' >&2; exit 1;;
esac
@@ -40,7 +36,7 @@ IFS=.
set $VERSION
sed 's/4_/a4_/g
s/m4preproc_/m4_/g
' "$srcdir/flex.skl" |
' "$srcdir/${lang}-flex.skl" |
"$m4" -P -I "$srcdir" "-DFLEX_MAJOR_VERSION=$1" \
"-DFLEX_MINOR_VERSION=$2" \
"-DFLEX_SUBMINOR_VERSION=$3" |
@@ -49,6 +45,3 @@ s/m4_/m4preproc_/g
s/a4_/4_/g
s/[\\"]/\\&/g
s/[^\r]*/ "&",/'
echo ' 0
};'
+16 -14
View File
@@ -334,13 +334,15 @@ pthread_pthread_LDADD = @LIBPTHREAD@
# specify how to process .l files in order to test the flex built by make all
TESTOPTS = -L
FLEX = $(top_builddir)/src/flex
.l.c: $(FLEX)
$(AM_V_LEX)$(FLEX) -o $@ $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) -o $@ $<
.ll.cc: $(FLEX)
$(AM_V_LEX)$(FLEX) -+ -o $@ $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) -+ -o $@ $<
bison_nr_main.$(OBJEXT): bison_nr_parser.h bison_nr_scanner.h
bison_nr_scanner.$(OBJEXT): bison_nr_parser.h
@@ -367,7 +369,7 @@ bison_yylval_scanner.h: bison_yylval_scanner.c
# so we explicitly sayhow, using the .lll suffix for the lex input file
.lll.cc: $(FLEX)
$(AM_V_LEX)$(FLEX) -o $@ $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) -o $@ $<
header_nr_main.$(OBJEXT): header_nr_scanner.h
@@ -402,16 +404,16 @@ multiple_scanners_r_2.h: multiple_scanners_r_2.c
@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) $<; else :; fi
posixly_correct.c: posixly_correct.l $(FLEX)
$(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) -o $@ $<
$(AM_V_LEX)POSIXLY_CORRECT=1 $(FLEX) $(TESTOPTS) -o $@ $<
reject_nr.reject.c: reject.l4 $(FLEX)
$(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -o $@ $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -o $@ $<
reject_nr.reject$(EXEEXT): reject_nr.reject.$(OBJEXT)
$(AM_V_CCLD)$(LINK) $^
reject_r.reject.c: reject.l4 $(FLEX)
$(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape --reentrant -o $@ $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape --reentrant -o $@ $<
reject_r.reject.$(OBJEXT): reject_r.reject.c
$(AM_V_CC)$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $<
@@ -420,7 +422,7 @@ reject_r.reject$(EXEEXT): reject_r.reject.$(OBJEXT)
$(AM_V_CCLD)$(LINK) $^
reject_ver.table.c: reject.l4 $(FLEX)
$(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -o $@ --tables-verify --tables-file=$(basename $@).tables $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -o $@ --tables-verify --tables-file=$(basename $@).tables $<
reject_ver.table.$(OBJEXT): reject_ver.table.c
$(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
@@ -429,7 +431,7 @@ reject_ver.table$(EXEEXT): reject_ver.table.$(OBJEXT)
$(AM_V_CCLD)$(LINK) $^
reject_ser.table.c: reject.l4 $(FLEX)
$(AM_V_LEX)$(FLEX) -o $@ --unsafe-no-m4-sect3-escape --tables-file=$(basename $@).tables $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) -o $@ --unsafe-no-m4-sect3-escape --tables-file=$(basename $@).tables $<
reject_ser.table.$(OBJEXT): reject_ser.table.c
$(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
@@ -463,13 +465,13 @@ OPT_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh
AM_OPT_LOG_FLAGS = -d $(srcdir) -i $(srcdir)/tableopts.txt -r
tableopts_opt_nr%.c: tableopts.l4 $(FLEX)
$(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) $(*:_F=F) -o $@ $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) $(*:_F=F) -o $@ $<
tableopts_opt_nr%.$(OBJEXT): tableopts_opt_nr%.c
$(AM_V_CC)$(COMPILE) -c -o $@ $<
tableopts_opt_r%.c: tableopts.l4 $(FLEX)
$(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --reentrant $(subst _F,F,$*) -o $@ $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --reentrant $(subst _F,F,$*) -o $@ $<
tableopts_opt_r%.$(OBJEXT): tableopts_opt_r%.c
$(AM_V_CC)$(COMPILE) -DTEST_IS_REENTRANT -c -o $@ $<
@@ -478,13 +480,13 @@ SER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh
AM_SER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t
tableopts_ser_nr%.c: tableopts.l4 $(FLEX)
$(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $(subst _F,F,$*) -o $@ $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ser_nr$*.ser.tables" $(subst _F,F,$*) -o $@ $<
tableopts_ser_nr%.$(OBJEXT): tableopts_ser_nr%.c
$(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
tableopts_ser_r%.c: tableopts.l4 $(FLEX)
$(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $(subst _F,F,$*) -o $@ $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ser_r$*.ser.tables" $(subst _F,F,$*) -o $@ $<
tableopts_ser_r%.$(OBJEXT): tableopts_ser_r%.c
$(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $<
@@ -493,7 +495,7 @@ VER_LOG_COMPILER = $(SHELL) $(srcdir)/testwrapper.sh
AM_VER_LOG_FLAGS = -d $(builddir) -i $(srcdir)/tableopts.txt -r -t
tableopts_ver_nr%.c: tableopts.l4 $(FLEX)
$(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $(subst _F,F,$*) -o $@ $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) --tables-file="tableopts_ver_nr$*.ver.tables" --tables-verify $(subst _F,F,$*) -o $@ $<
tableopts_ver_nr%.$(OBJEXT): tableopts_ver_nr%.c
$(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -c -o $@ $<
@@ -502,7 +504,7 @@ tableopts_ver_nr%.ver$(EXEEXT): tableopts_ver_nr%.$(OBJEXT)
$(AM_V_CCLD)$(LINK) -o $@ $^
tableopts_ver_r%.c: tableopts.l4 $(FLEX)
$(AM_V_LEX)$(FLEX) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $(subst _F,F,$*) -o $@ $<
$(AM_V_LEX)$(FLEX) $(TESTOPTS) --unsafe-no-m4-sect3-escape -P $(subst -,_,$(basename $(*F))) -R --tables-file="tableopts_ver_r$*.ver.tables" --tables-verify $(subst _F,F,$*) -o $@ $<
tableopts_ver_r%.$(OBJEXT): tableopts_ver_r%.c
$(AM_V_CC)$(COMPILE) -DTEST_HAS_TABLES_EXTERNAL -DTEST_IS_REENTRANT -c -o $@ $<