Created get/set functions for yy_flex_debug.
Defined prefixes for new yy_flex_debug symbols.
Added tests/ for yy_flex_debug.
tests/test-yyextra/Makefile
tests/test-lineno-nr/Makefile
tests/test-lineno-r/Makefile
+tests/test-debug-r/Makefile
+tests/test-debug-nr/Makefile
)
-/* -*-C-*- */
+%# -*-C-*- vi: set ft=c:
/* A lexical scanner generated by flex */
%# Lines in this skeleton starting with a '%' character are "control lines"
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
+#include <stdbool.h>
/* end standard C headers. */
%+
/* begin standard C++ headers. */
#define yyleng YY_G(yyleng_r)
#define yytext YY_G(yytext_r)
#define yylineno YY_G(yylineno_r)
+#define yy_flex_debug YY_G(yy_flex_debug_r)
int yylex_init YY_PROTO((yyscan_t* scanner));
int yylex_destroy YY_PROTO((yyscan_t scanner));
char* yy_last_accepting_cpos;
int yylineno_r;
+ bool yy_flex_debug_r;
#ifdef YY_TEXT_IS_ARRAY
char yytext_r[YYLMAX];
}
#endif /* !YY_NO_SET_OUT */
+
+#ifndef YY_NO_GET_DEBUG
+#ifdef YY_USE_PROTOS
+bool yyget_debug( YY_ONLY_ARG )
+#else
+bool yyget_debug( YY_ONLY_ARG )
+ YY_DECL_LAST_ARG
+#endif
+{
+ return yy_flex_debug;
+}
+#endif /* !YY_NO_GET_DEBUG */
+
+#ifndef YY_NO_SET_DEBUG
+#ifdef YY_USE_PROTOS
+void yyset_debug(bool bdebug YY_LAST_ARG )
+#else
+void yyset_debug( bdebug YY_LAST_ARG )
+ bool bdebug;
+ YY_DECL_LAST_ARG
+#endif
+{
+ yy_flex_debug = bdebug ;
+}
+#endif /* !YY_NO_SET_DEBUG */
+
+
/* Accessor methods for yylval and yylloc */
#ifdef YY_REENTRANT_BISON_PURE
if ( ddebug )
{ /* Spit out table mapping rules to line numbers. */
- if ( ! C_plus_plus )
+ if ( ! C_plus_plus && ! reentrant )
{
indent_puts( "extern int yy_flex_debug;" );
indent_puts( "int yy_flex_debug = 1;\n" );
GEN_PREFIX( "leng" );
GEN_PREFIX( "in" );
GEN_PREFIX( "out" );
+ GEN_PREFIX( "_flex_debug" );
outn( "#endif" );
GEN_PREFIX( "_create_buffer" );
GEN_PREFIX( "_delete_buffer" );
GEN_PREFIX( "_scan_buffer" );
GEN_PREFIX( "_scan_string" );
GEN_PREFIX( "_scan_bytes" );
- GEN_PREFIX( "_flex_debug" );
GEN_PREFIX( "_init_buffer" );
GEN_PREFIX( "_flush_buffer" );
GEN_PREFIX( "_load_buffer_state" );
GEN_PREFIX( "restart" );
GEN_PREFIX( "lex_init" );
GEN_PREFIX( "lex_destroy" );
+ GEN_PREFIX( "get_debug" );
+ GEN_PREFIX( "set_debug" );
GEN_PREFIX( "get_extra" );
GEN_PREFIX( "set_extra" );
GEN_PREFIX( "get_in" );
fprintf(header_out,"#undef YY_MORE_ADJ\n");
fprintf(header_out,"#undef YY_NEED_STRLEN\n");
fprintf(header_out,"#undef YY_NEW_FILE\n");
+ fprintf(header_out,"#undef YY_NO_GET_DEBUG\n");
fprintf(header_out,"#undef YY_NO_GET_EXTRA\n");
fprintf(header_out,"#undef YY_NO_GET_IN\n");
fprintf(header_out,"#undef YY_NO_GET_LENG\n");
fprintf(header_out,"#undef YY_NO_SCAN_BUFFER\n");
fprintf(header_out,"#undef YY_NO_SCAN_BYTES\n");
fprintf(header_out,"#undef YY_NO_SCAN_STRING\n");
+ fprintf(header_out,"#undef YY_NO_SET_DEBUG\n");
fprintf(header_out,"#undef YY_NO_SET_EXTRA\n");
fprintf(header_out,"#undef YY_NO_SET_IN\n");
fprintf(header_out,"#undef YY_NO_SET_LINENO\n");
yy_scan_bytes ACTION_IFDEF("YY_NO_SCAN_BYTES", ! option_sense);
yy_scan_string ACTION_IFDEF("YY_NO_SCAN_STRING", ! option_sense);
+ yyget_debug ACTION_IFDEF("YY_NO_GET_DEBUG", ! option_sense);
+ yyset_debug ACTION_IFDEF("YY_NO_SET_DEBUG", ! option_sense);
yyget_extra ACTION_IFDEF("YY_NO_GET_EXTRA", ! option_sense);
yyset_extra ACTION_IFDEF("YY_NO_SET_EXTRA", ! option_sense);
yyget_leng ACTION_IFDEF("YY_NO_GET_LENG", ! option_sense);
create-test
SUBDIRS = \
+ test-debug-nr \
+ test-debug-r \
test-lineno-r \
test-lineno-nr \
TEMPLATE \
--- /dev/null
+Makefile
+Makefile.in
+parser.c
+parser.h
+scanner.c
+TEMPLATE
+OUTPUT
+.deps
+test-debug-nr
--- /dev/null
+# 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.
+
+BISON = @BISON@
+FLEX = $(top_builddir)/flex
+
+EXTRA_DIST = scanner.l test.input
+CLEANFILES = scanner.c scanner.h test-debug-nr OUTPUT $(OBJS)
+OBJS = scanner.o
+
+INCLUDES = -I $(srcdir) -I $(top_srcdir) -I $(top_builddir) -I .
+#LDFLAGS = $(top_srcdir)/libfl.a
+
+testname = test-debug-nr
+
+scanner.c: $(srcdir)/scanner.l
+ $(FLEX) $(LFLAGS) $<
+
+$(testname)$(EXEEXT): $(OBJS)
+ $(CC) -o $@ $(OBJS) $(LDFLAGS)
+
+test: $(testname)$(EXEEXT)
+ ./$(testname)$(EXEEXT) < $(srcdir)/test.input
+
+.c.o:
+ $(CC) -c -o $@ $(INCLUDES) $<
--- /dev/null
+/*
+ * 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.
+ */
+
+%{
+/* A template scanner file to build "scanner.c". */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+
+%}
+
+%option 8bit outfile="scanner.c" prefix="test"
+%option nounput nomain noyywrap
+%option warn debug
+
+%%
+.+ { }
+\n { }
+%%
+
+int
+main ( int argc, char** argv )
+{
+ yyin = stdin;
+ yyout = stdout;
+ yy_flex_debug = 1;
+ yylex();
+ printf("TEST RETURNING OK.\n");
+ return 0;
+}
--- /dev/null
+Any input will do for this test.
+We are only testing if it actually runs in debug mode.
--- /dev/null
+Makefile
+Makefile.in
+parser.c
+parser.h
+scanner.c
+TEMPLATE
+OUTPUT
+.deps
+test-debug-r
--- /dev/null
+# 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.
+
+BISON = @BISON@
+FLEX = $(top_builddir)/flex
+
+EXTRA_DIST = scanner.l test.input
+CLEANFILES = scanner.c test-debug-r OUTPUT $(OBJS)
+OBJS = scanner.o
+
+INCLUDES = -I $(srcdir) -I $(top_srcdir) -I $(top_builddir) -I .
+#LDFLAGS = $(top_srcdir)/libfl.a
+
+testname = test-debug-r
+
+scanner.c: $(srcdir)/scanner.l
+ $(FLEX) $(LFLAGS) $<
+
+$(testname)$(EXEEXT): $(OBJS)
+ $(CC) -o $@ $(OBJS) $(LDFLAGS)
+
+test: $(testname)$(EXEEXT)
+ ./$(testname)$(EXEEXT) < $(srcdir)/test.input
+
+.c.o:
+ $(CC) -c -o $@ $(INCLUDES) $<
--- /dev/null
+/*
+ * 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.
+ */
+
+%{
+/* A template scanner file to build "scanner.c". */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+
+%}
+
+%option 8bit outfile="scanner.c" prefix="test"
+%option nounput nomain noyywrap
+%option warn debug reentrant
+
+%%
+.+ { }
+\n { }
+%%
+
+int main (int argc, char** argv )
+{
+ yyscan_t lexer;
+ yylex_init( &lexer );
+ yyset_out ( stdout,lexer);
+ yyset_in ( stdin, lexer);
+
+ /* Just see if the next line compiles. */
+ testset_debug (testget_debug(lexer), lexer);
+
+ while( yylex(lexer) )
+ {
+ }
+ yylex_destroy( lexer );
+ printf("TEST RETURNING OK.\n");
+ return 0;
+}
--- /dev/null
+Any input will do for this test.
+We are only testing if it actually runs in debug mode.