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
# define yylloc YY_G(yylloc_r)
# endif
#endif /* YY_REENTRANT_BISON_PURE */
+%e
#endif /* end if YY_REENTRANT */
/* 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;
/* Destroy the main struct (reentrant only). */
yyfree ( yyscanner YY_CALL_LAST_ARG );
#endif
+%*
return 0;
}
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
%{
-#include <stdio.h>
-#include <stdlib.h>
#include "config.h"
%}
%option 8bit outfile="scanner.cpp" prefix="test"
%option nounput nomain noyywrap
-%option warn
+%option warn c++
%%
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;
}