diff options
author | Will Estes <wlestes@users.sourceforge.net> | 2002-10-01 15:10:12 +0000 |
---|---|---|
committer | Will Estes <wlestes@users.sourceforge.net> | 2002-10-01 15:10:12 +0000 |
commit | 6dabf511dbfb72eb8659676f409c0695517e256b (patch) | |
tree | 30babc35401d291559a70598df75002d953e5b12 /tests | |
parent | eda701b30d2f0ddfdbb9bb9e589327f29415d51d (diff) | |
download | flex-git-6dabf511dbfb72eb8659676f409c0695517e256b.tar.gz |
test c++ with multiple scanners
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/test-c++-multiple-scanners/.cvsignore | 7 | ||||
-rw-r--r-- | tests/test-c++-multiple-scanners/Makefile.am | 52 | ||||
-rw-r--r-- | tests/test-c++-multiple-scanners/main.cpp | 54 | ||||
-rw-r--r-- | tests/test-c++-multiple-scanners/scanner-1.l | 44 | ||||
-rw-r--r-- | tests/test-c++-multiple-scanners/scanner-2.l | 43 | ||||
-rw-r--r-- | tests/test-c++-multiple-scanners/test.input | 1 |
7 files changed, 203 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 09308c3..5d200b1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,6 +26,7 @@ noinst_SCRIPTS = \ create-test DIST_SUBDIRS = \ + test-c++-multiple-scanners \ test-reject \ test-bison-nr \ test-c++-basic \ @@ -61,6 +62,7 @@ DIST_SUBDIRS = \ test-table-opts SUBDIRS = \ + test-c++-multiple-scanners \ test-reject \ test-bison-nr \ test-c++-basic \ diff --git a/tests/test-c++-multiple-scanners/.cvsignore b/tests/test-c++-multiple-scanners/.cvsignore new file mode 100644 index 0000000..ed9376c --- /dev/null +++ b/tests/test-c++-multiple-scanners/.cvsignore @@ -0,0 +1,7 @@ +Makefile +Makefile.in +scanner-1.cpp +scanner-2.cpp +OUTPUT +.deps +test-c++-multiple-scanners diff --git a/tests/test-c++-multiple-scanners/Makefile.am b/tests/test-c++-multiple-scanners/Makefile.am new file mode 100644 index 0000000..66b98c0 --- /dev/null +++ b/tests/test-c++-multiple-scanners/Makefile.am @@ -0,0 +1,52 @@ +# 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-1.l scanner-2.l main.cpp +CLEANFILES = scanner-1.cpp scanner-1.h test-c++-multiple-scanners OUTPUT $(OBJS) scanner-2.cpp scanner-2.h +OBJS = scanner-1.o scanner-2.o main.o + +AM_CXXFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_builddir) +#LDFLAGS = $(top_srcdir)/libfl.a +#YFLAGS = --defines --output=parser.c + +testname = test-c++-multiple-scanners + +scanner-1.cpp: $(srcdir)/scanner-1.l + $(FLEX) -+ $(LFLAGS) --header=scanner-1.h $< + +scanner-2.cpp: $(srcdir)/scanner-2.l + $(FLEX) -+ $(LFLAGS) --header=scanner-2.h $< + +$(testname)$(EXEEXT): $(OBJS) + $(CXX) -o $@ $(LDFLAGS) $(OBJS) $(LOADLIBES) + +test: $(testname)$(EXEEXT) + $(builddir)/$(testname)$(EXEEXT) < $(srcdir)/test.input + +.cpp.o: + $(CXX) -c -o $@ $(AM_CXXFLAGS) $(CPPFLAGS) $(CXXFLAGS) $< + +main.o: scanner-1.h scanner-2.h +scanner-1.h: scanner-1.cpp +scanner-2.h: scanner-2.cpp diff --git a/tests/test-c++-multiple-scanners/main.cpp b/tests/test-c++-multiple-scanners/main.cpp new file mode 100644 index 0000000..aa89949 --- /dev/null +++ b/tests/test-c++-multiple-scanners/main.cpp @@ -0,0 +1,54 @@ +/* + * 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 <stdio.h> + +#undef yyFlexLexer +#define yyFlexLexer S1_FlexLexer +#include <FlexLexer.h> + +#undef yyFlexLexer +#define yyFlexLexer S2_FlexLexer +#include <FlexLexer.h> + +int +main ( int argc, char** argv ) +{ + int S1_ok=1, S2_ok=1; + S1_FlexLexer* S1 = new S1_FlexLexer; + S2_FlexLexer* S2 = new S2_FlexLexer; + + // scan simultaneously. + while(S1_ok || S2_ok) + { + if (S1_ok) + S1_ok = S1->yylex(); + if (S2_ok) + S2_ok = S2->yylex(); + } + printf("TEST RETURNING OK.\n"); + return 0; +} + + +/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */ diff --git a/tests/test-c++-multiple-scanners/scanner-1.l b/tests/test-c++-multiple-scanners/scanner-1.l new file mode 100644 index 0000000..38cc5d7 --- /dev/null +++ b/tests/test-c++-multiple-scanners/scanner-1.l @@ -0,0 +1,44 @@ + // 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 "config.h" + +%} + +%option 8bit outfile="scanner-1.cpp" prefix="S1_" +%option nounput nomain noyywrap +%option warn stack noyy_top_state + +%x ON +%x OFF +%% +<INITIAL>{ +on yy_push_state(ON); return 10; +off yy_push_state(OFF); return 11; +.|\n return 12; +} +<ON>.|\n yy_pop_state(); return 13; + +<OFF>.|\n yy_pop_state(); return 14; + +%% + diff --git a/tests/test-c++-multiple-scanners/scanner-2.l b/tests/test-c++-multiple-scanners/scanner-2.l new file mode 100644 index 0000000..db84402 --- /dev/null +++ b/tests/test-c++-multiple-scanners/scanner-2.l @@ -0,0 +1,43 @@ + // 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 "config.h" + +%} + +%option 8bit outfile="scanner-2.cpp" prefix="S2_" +%option nounput nomain noyywrap +%option warn stack noyy_top_state + +%x OFF +%x ON +%% +<INITIAL>{ +on yy_push_state(ON); return 3; +off yy_push_state(OFF); return 4; +.|\n return 5; +} +<ON>.|\n yy_pop_state(); return 6; + +<OFF>.|\n yy_pop_state(); return 7; +%% + diff --git a/tests/test-c++-multiple-scanners/test.input b/tests/test-c++-multiple-scanners/test.input new file mode 100644 index 0000000..08498fa --- /dev/null +++ b/tests/test-c++-multiple-scanners/test.input @@ -0,0 +1 @@ +foo on bar off |