diff options
author | John Millaway <john43@users.sourceforge.net> | 2002-09-13 21:54:02 +0000 |
---|---|---|
committer | John Millaway <john43@users.sourceforge.net> | 2002-09-13 21:54:02 +0000 |
commit | 1c8a5f9d3f46fc35292723e0e600a0eb98e206b5 (patch) | |
tree | 81728aa8156adee049c7e2d3c60c7512d34caf90 /tests | |
parent | 1f0b3a5efb035501bad92519d46f4015ab540dfd (diff) | |
download | flex-git-1c8a5f9d3f46fc35292723e0e600a0eb98e206b5.tar.gz |
Created test for reject.
Handled reject-triggered tables in serialization.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/test-reject/.cvsignore | 9 | ||||
-rw-r--r-- | tests/test-reject/Makefile.am | 72 | ||||
-rw-r--r-- | tests/test-reject/scanner.l | 77 | ||||
-rw-r--r-- | tests/test-reject/test.input | 2 | ||||
-rw-r--r-- | tests/test-table-opts/Makefile.am | 3 |
6 files changed, 163 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 19a168a..95e3405 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,6 +26,7 @@ noinst_SCRIPTS = \ create-test SUBDIRS = \ + test-reject \ test-bison-nr \ test-c++-basic \ test-posixly-correct \ diff --git a/tests/test-reject/.cvsignore b/tests/test-reject/.cvsignore new file mode 100644 index 0000000..6c2de30 --- /dev/null +++ b/tests/test-reject/.cvsignore @@ -0,0 +1,9 @@ +Makefile +Makefile.in +parser.c +parser.h +scanner.c +TEMPLATE +OUTPUT +.deps +test-reject-* diff --git a/tests/test-reject/Makefile.am b/tests/test-reject/Makefile.am new file mode 100644 index 0000000..424ddbc --- /dev/null +++ b/tests/test-reject/Makefile.am @@ -0,0 +1,72 @@ +# 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 parser.y test.input +CLEANFILES = scanner.c test-reject-* OUTPUT $(OBJS) +OBJS = test-reject-nr.o test-reject-r.o test-reject-ver.o \ + test-reject-ser.o + +INCLUDES = -I $(srcdir) -I $(top_srcdir) -I $(top_builddir) -I . +#LDFLAGS = $(top_srcdir)/libfl.a +#LFLAGS = --header="scanner.h" +#YFLAGS = --defines --output=parser.c + +tests = test-reject-nr$(EXEEXT) test-reject-r$(EXEEXT) \ + test-reject-ser$(EXEEXT) test-reject-ver$(EXEEXT) +testname = test-reject + +test-reject-nr.c: $(srcdir)/scanner.l + $(FLEX) -o $@ $(LFLAGS) $< + +test-reject-ver.c: $(srcdir)/scanner.l + $(FLEX) -o $@ --tables-verify --tables-file=`basename $@ .c`.tables $(LFLAGS) $< + +test-reject-ser.c: $(srcdir)/scanner.l + $(FLEX) -o $@ --tables-file=`basename $@ .c`.tables $(LFLAGS) $< + +test-reject-r.c: $(srcdir)/scanner.l + $(FLEX) --reentrant -o $@ $(LFLAGS) $< + +test-reject-nr$(EXEEXT): test-reject-nr.o + $(CC) -o $@ $(LDFLAGS) $< $(LOADLIBES) + +test-reject-ver$(EXEEXT): test-reject-ver.o + $(CC) -o $@ $(LDFLAGS) $< $(LOADLIBES) + +test-reject-ser$(EXEEXT): test-reject-ser.o + $(CC) -o $@ $(LDFLAGS) $< $(LOADLIBES) + +test-reject-r$(EXEEXT): test-reject-r.o + $(CC) -o $@ $(LDFLAGS) $< $(LOADLIBES) + +$(testname)$(EXEEXT): $(OBJS) + +test: $(tests) + ./$(testname)-nr$(EXEEXT) < $(srcdir)/test.input + ./$(testname)-r$(EXEEXT) < $(srcdir)/test.input + ./$(testname)-ver$(EXEEXT) $(testname)-ver.tables < $(srcdir)/test.input + ./$(testname)-ser$(EXEEXT) $(testname)-ser.tables < $(srcdir)/test.input + +.c.o: + $(CC) -c -o $@ $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< diff --git a/tests/test-reject/scanner.l b/tests/test-reject/scanner.l new file mode 100644 index 0000000..a093ae4 --- /dev/null +++ b/tests/test-reject/scanner.l @@ -0,0 +1,77 @@ +/* + * 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> +#include <stdlib.h> +#include "config.h" + +%} + +%option 8bit prefix="test" +%option nounput nomain noyywrap +%option warn reject + + +%% + +. { REJECT; } +.|\n ; + +%% + +int main ( int argc, char** argv ) +{ + FILE* fp = NULL; + void *yyscanner=0; +#ifdef YY_REENTRANT + yylex_init(&yyscanner); +#endif +#ifdef YY_TABLES_EXTERNAL + if((fp = fopen(argv[1],"r"))== NULL) + yy_fatal_error("could not open tables file for reading" YY_CALL_LAST_ARG); + + if(yytables_load(fp YY_CALL_LAST_ARG) < 0) + yy_fatal_error("yytables_load returned < 0" YY_CALL_LAST_ARG); + if(YY_TABLES_VERIFY) + exit(0); +#endif + + if(argc > 2){ + if((fp = fopen(argv[2],"r"))== NULL) + yy_fatal_error("could not open input file for reading" YY_CALL_LAST_ARG); + yyin = fp; + } + while(yylex(YY_CALL_ONLY_ARG) != 0) + ; + +#ifdef YY_TABLES_EXTERNAL + yytables_destroy(YY_CALL_ONLY_ARG); +#endif + yylex_destroy(YY_CALL_ONLY_ARG); + + if(argc < 0) /* silence the compiler */ + yyscanner = (void*)fp; + + return 0; +} diff --git a/tests/test-reject/test.input b/tests/test-reject/test.input new file mode 100644 index 0000000..7288a40 --- /dev/null +++ b/tests/test-reject/test.input @@ -0,0 +1,2 @@ +0000 foo 1111 foo 0000 bar +0000 foo 1111 foo 0000 bar diff --git a/tests/test-table-opts/Makefile.am b/tests/test-table-opts/Makefile.am index b500c85..97d8b21 100644 --- a/tests/test-table-opts/Makefile.am +++ b/tests/test-table-opts/Makefile.am @@ -63,7 +63,8 @@ sertables := $(addsuffix .tables,$(sertests)) alltables := $(addsuffix .tables,$(alltests)) EXTRA_DIST = scanner.l test.input -CLEANFILES = scanner.c OUTPUT test-*.o test-*.c test-*.tables core $(alltests) +CLEANFILES = scanner.c OUTPUT test-*.o test-*.c test-*.tables \ + all-ser.tables core $(alltests) INCLUDES = -I $(srcdir) -I $(top_srcdir) -I $(top_builddir) -I . test: test-table-opts |