From 5420790356f87786f964bc0c33aa47bd344b3125 Mon Sep 17 00:00:00 2001 From: John Millaway Date: Thu, 22 Aug 2002 01:11:07 +0000 Subject: [PATCH] Removed core of yylex_destroy from c++ scanner -- hack! Added -lstdc++ to LDFLAGS (should we have to do this??) --- flex.skl | 4 ++++ tests/test-c++-basic/Makefile.am | 7 +++---- tests/test-c++-basic/scanner.l | 14 ++++++-------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/flex.skl b/flex.skl index 7af8c62..a81f1ec 100644 --- a/flex.skl +++ b/flex.skl @@ -553,6 +553,7 @@ struct yyguts_t static int yy_init_globals YY_PARAMS(( YY_PROTO_ONLY_ARG )); %e +%c These go in the .c file only. /* This must go here because YYSTYPE and YYLSTYPE are included * from bison output in section 1.*/ #ifdef YY_REENTRANT_BISON_PURE @@ -561,6 +562,7 @@ static int yy_init_globals YY_PARAMS(( YY_PROTO_ONLY_ARG )); # define yylloc YY_G(yylloc_r) # endif #endif /* YY_REENTRANT_BISON_PURE */ +%e #endif /* end if YY_REENTRANT */ @@ -1968,6 +1970,7 @@ int yylex_init( ptr_yy_globals ) /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy YYFARGS0(void) { +%- SNIP! this currently causes conflicts with the c++ scanner /* Destroy the current (main) buffer. */ yy_delete_buffer( YY_G(yy_current_buffer) YY_CALL_LAST_ARG ); YY_G(yy_current_buffer) = NULL; @@ -1989,6 +1992,7 @@ int yylex_destroy YYFARGS0(void) /* Destroy the main struct (reentrant only). */ yyfree ( yyscanner YY_CALL_LAST_ARG ); #endif +%* return 0; } diff --git a/tests/test-c++-basic/Makefile.am b/tests/test-c++-basic/Makefile.am index ad57cf7..9044eae 100644 --- a/tests/test-c++-basic/Makefile.am +++ b/tests/test-c++-basic/Makefile.am @@ -23,13 +23,12 @@ BISON = @BISON@ FLEX = $(top_builddir)/flex EXTRA_DIST = scanner.l test.input -CLEANFILES = scanner.c scanner.h parser.c parser.h test-c++-basic OUTPUT $(OBJS) -OBJS = scanner.o # parser.o +CLEANFILES = scanner.cpp scanner.h test-c++-basic OUTPUT $(OBJS) +OBJS = scanner.o INCLUDES = -I $(srcdir) -I $(top_srcdir) -I $(top_builddir) -I . -#LDFLAGS = $(top_srcdir)/libfl.a LFLAGS = -+ -#YFLAGS = --defines --output=parser.c +LDFLAGS = -lstdc++ testname = test-c++-basic diff --git a/tests/test-c++-basic/scanner.l b/tests/test-c++-basic/scanner.l index 4955acb..48baf00 100644 --- a/tests/test-c++-basic/scanner.l +++ b/tests/test-c++-basic/scanner.l @@ -23,15 +23,13 @@ %{ -#include -#include #include "config.h" %} %option 8bit outfile="scanner.cpp" prefix="test" %option nounput nomain noyywrap -%option warn +%option warn c++ %% @@ -43,11 +41,11 @@ int main(void); int -main () +main (void) { - yyin = stdin; - yyout = stdout; - yylex(); - printf("TEST RETURNING OK.\n"); + yyFlexLexer f; + f.switch_streams(&std::cin, &std::cout); + f.yylex(); + std::cout << "TEST RETURNING OK." << std::endl; return 0; } -- 2.40.0