summaryrefslogtreecommitdiff
path: root/tests/TEMPLATE
diff options
context:
space:
mode:
authorWill Estes <wlestes@users.sourceforge.net>2001-05-18 17:22:22 +0000
committerWill Estes <wlestes@users.sourceforge.net>2001-05-18 17:22:22 +0000
commitdc3a30a46cb3a42fc0a858dfa243a96112c8e551 (patch)
tree3bfc63b1584ca1f53f299b84d39b3ebe8ddc2811 /tests/TEMPLATE
parent756defa0610404257cb8a1c8ef513365a6674789 (diff)
add john millaway's test directory
Diffstat (limited to 'tests/TEMPLATE')
-rw-r--r--tests/TEMPLATE/Makefile.in66
-rw-r--r--tests/TEMPLATE/parser.y38
-rw-r--r--tests/TEMPLATE/scanner.l29
-rw-r--r--tests/TEMPLATE/test.input2
4 files changed, 135 insertions, 0 deletions
diff --git a/tests/TEMPLATE/Makefile.in b/tests/TEMPLATE/Makefile.in
new file mode 100644
index 0000000..df0534e
--- /dev/null
+++ b/tests/TEMPLATE/Makefile.in
@@ -0,0 +1,66 @@
+# Makefile.in for a single TEST.
+#
+# By default this Makefile will build the target "$(TESTNAME)"
+# from the sources "scanner.l" and "parser.y".
+#
+# $(TESTNAME) is supplied by the calling Makefile.
+# "parser.y" is not necessary. You may delete this file
+# if you do not require a parser.
+# "scanner.l" is necessary. It should build "scanner.c".
+#
+
+@SET_MAKE@
+
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@ -I. -I"@srcdir@" -I..
+DEFS = @DEFS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+SHELL = /bin/sh
+srcdir = @srcdir@
+VPATH = @srcdir@
+LN_S = @LN_S@
+YACC = @YACC@
+CC = @CC@
+AR = ar
+RANLIB = @RANLIB@
+YACC = @YACC@
+
+# Edit these if necessary for your specific test.
+TESTNAME = TEMPLATE
+FLEX = ../../flex
+YFLAGS = --defines --output-file="parser.c" --name-prefix="test"
+OBJS = scanner.o # parser.o
+
+# Force YACC to be bison (autoconf generates 'bison -y')
+YACC = @BISON@
+
+all: $(TESTNAME)
+
+$(TESTNAME): $(OBJS)
+ $(CC) $(CFLAGS) -o $(TESTNAME) $(OBJS) $(LDFLAGS) $(LIBS)
+
+scanner.c: $(srcdir)/scanner.l
+ $(FLEX) $(srcdir)/scanner.l
+
+scanner.o: scanner.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c scanner.c
+
+parser.c: $(srcdir)/parser.y
+ $(YACC) $(YFLAGS) $(srcdir)/parser.y
+
+parser.o: parser.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c parser.c
+
+test: check
+
+check: $(TESTNAME)
+ @echo "EXECUTING TEST: '$(TESTNAME)'"
+ ./$(TESTNAME) < $(srcdir)/test.input
+
+distclean: clean
+ rm -f Makefile
+
+clean:
+ rm -f scanner.o scanner.c parser.o parser.c parser.h parser.h $(TESTNAME)
+
diff --git a/tests/TEMPLATE/parser.y b/tests/TEMPLATE/parser.y
new file mode 100644
index 0000000..4fefe2d
--- /dev/null
+++ b/tests/TEMPLATE/parser.y
@@ -0,0 +1,38 @@
+/* A dummy template parser to build "parser.c" and "parser.h".
+ How to compile:
+ bison --defines --output-file="parser.c" --name-prefix="test" parser.y
+ */
+%{
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+
+#define YYERROR_VERBOSE 1 /* For debugging. */
+/* #define YYPARSE_PARAM scanner */ /* For pure bison parser. */
+/* #define YYLEX_PARAM scanner */ /* For reentrant flex. */
+
+
+int yyerror(char* msg);
+extern int testlex();
+
+%}
+
+%%
+
+rule: ;
+
+%%
+
+int yyerror(char* msg) {
+ fprintf(stderr,"%s\n",msg);
+ return 0;
+}
+
+/*
+int
+main ( int argc, char** argv )
+{
+ yyparse ();
+ return 0;
+}
+*/
diff --git a/tests/TEMPLATE/scanner.l b/tests/TEMPLATE/scanner.l
new file mode 100644
index 0000000..01bd259
--- /dev/null
+++ b/tests/TEMPLATE/scanner.l
@@ -0,0 +1,29 @@
+%{
+/* A template scanner file to build "scanner.c". */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+/*#include "parser.h" */
+
+%}
+
+%option 8bit outfile="scanner.c" prefix="test"
+%option nounput nomain noyywrap
+%option warn
+
+
+%%
+
+. { }
+
+%%
+
+int
+main ( int argc, char** argv )
+{
+ yyin = stdin;
+ yyout = stdout;
+ yylex();
+ printf("TEST RETURNING OK.\n");
+ return 0;
+}
diff --git a/tests/TEMPLATE/test.input b/tests/TEMPLATE/test.input
new file mode 100644
index 0000000..7288a40
--- /dev/null
+++ b/tests/TEMPLATE/test.input
@@ -0,0 +1,2 @@
+0000 foo 1111 foo 0000 bar
+0000 foo 1111 foo 0000 bar