Serialization code (Tables API) is complete.
** revisit the C++ API. We get requests to make it more complete.
-* Tables API
-
-** verify that new macros/functions work with %option header-file
-
* build system
** use bootstrapper
/* Unload the tables from memory. */
int yytables_destroy YY_PARAMS ((YY_PROTO_ONLY_ARG));
+%not-for-header
/** Describes a mapping from a serialized table id to its deserialized state in
* this scanner. This is the bridge between our "generic" deserialization code
};
%tables-serialization-code-end structures and prototypes
+%ok-for-header
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
@cindex serialization
@cindex memory, serialized tables
-@strong{This feature is currently under development.
-It should be considered alpha quality.}
@anchor{serialization}
A @code{flex} scanner has the ability to save the DFA tables to a file, and
load them runtime when needed. The motivation for this feature is to reduce
if (do_yywrap)
GEN_PREFIX ("wrap");
+ if (tablesext){
+ GEN_PREFIX ("tables_fload");
+ GEN_PREFIX ("tables_destroy");
+ GEN_PREFIX ("TABLES_NAME");
+ }
+
outn ("");
}
#endif
+#ifndef YYTABLES_TYPES
+#define YYTABLES_TYPES
/** Possible values for td_id field. Each one corresponds to a
* scanner table of the same name.
*/
uint32_t td_lolen; /**< num elements in lowest dimension array */
void *td_data; /**< table data */
};
+#endif
/** Extract corresponding data size_t from td_flags */
#ifndef YYTDFLAGS2BYTES
:sizeof(int32_t)))
#endif
+#ifdef FLEX_SCANNER
+%not-for-header
+#endif
yyskel_static int32_t yytbl_calc_total_len (const struct yytbl_data *tbl);
+#ifdef FLEX_SCANNER
+%ok-for-header
+#endif
/* vim:set noexpandtab cindent tabstop=8 softtabstop=0 shiftwidth=8 textwidth=0: */
main ( int argc, char** argv )
{
int S1_ok=1, S2_ok=1;
+ FILE * fp;
YY_BUFFER_STATE buff1, buff2;
yyscan_t scan1, scan2;
S1_lex_init(&scan1);
S2_lex_init(&scan2);
+ if((fp = fopen("scanner-1.tables","r")) == 0){
+ fprintf(stderr,"Could not open scanner-1.tables.\n");
+ exit(1);
+ }
+ if(S1_tables_fload(fp,scan1) != 0){
+ fprintf(stderr,"Could not load scanner-1.tables.\n");
+ exit(1);
+ }
+ fclose(fp);
+
+ if((fp = fopen("scanner-2.tables","r")) == 0){
+ fprintf(stderr,"Could not open scanner-2.tables.\n");
+ exit(1);
+ }
+ if(S2_tables_fload(fp,scan2) != 0){
+ fprintf(stderr,"Could not load scanner-2.tables.\n");
+ exit(1);
+ }
+ fclose(fp);
+
S1_set_out(stdout,scan1);
S2_set_out(S1_get_out(scan1),scan2);
S1__delete_buffer(buff1, scan1);
S2__delete_buffer(buff2, scan2);
+ S1_tables_destroy(scan1);
+ S2_tables_destroy(scan2);
+
S1_lex_destroy(scan1);
S2_lex_destroy(scan2);
printf("TEST RETURNING OK.\n");
%option 8bit outfile="scanner-1.c" prefix="S1_"
%option nounput nomain noyywrap noyy_top_state
%option warn stack reentrant
+%option tables-file="scanner-1.tables"
%x ON
%x OFF
%option 8bit outfile="scanner-2.c" prefix="S2_"
%option nounput nomain noyywrap
%option warn stack reentrant noyy_top_state
+%option tables-file="scanner-2.tables"
%x OFF
%x ON