summaryrefslogtreecommitdiffstats
path: root/contrib/gperf/tests
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-09-10 13:48:14 +0000
committerpeter <peter@FreeBSD.org>1996-09-10 13:48:14 +0000
commit6cfe3ae61b383acc12d75bc595be2ab185d5586c (patch)
treefcddaf1b0d2794e9b555d2efd1246544e39a39ce /contrib/gperf/tests
downloadFreeBSD-src-6cfe3ae61b383acc12d75bc595be2ab185d5586c.zip
FreeBSD-src-6cfe3ae61b383acc12d75bc595be2ab185d5586c.tar.gz
Import the FSF release of gperf-2.1a, used in the build of gcc-2.7.2.1
(to be imported soon).
Diffstat (limited to 'contrib/gperf/tests')
-rw-r--r--contrib/gperf/tests/Makefile65
-rw-r--r--contrib/gperf/tests/ada.gperf63
-rw-r--r--contrib/gperf/tests/adapredefined.gperf54
-rw-r--r--contrib/gperf/tests/c++.gperf49
-rw-r--r--contrib/gperf/tests/c-parse.gperf56
-rw-r--r--contrib/gperf/tests/c.gperf32
-rw-r--r--contrib/gperf/tests/gpc.gperf48
-rw-r--r--contrib/gperf/tests/gplus.gperf76
-rw-r--r--contrib/gperf/tests/modula2.gperf40
-rw-r--r--contrib/gperf/tests/modula3.gperf106
-rw-r--r--contrib/gperf/tests/pascal.gperf36
-rw-r--r--contrib/gperf/tests/test.c32
12 files changed, 657 insertions, 0 deletions
diff --git a/contrib/gperf/tests/Makefile b/contrib/gperf/tests/Makefile
new file mode 100644
index 0000000..b7796d5
--- /dev/null
+++ b/contrib/gperf/tests/Makefile
@@ -0,0 +1,65 @@
+# Copyright (C) 1989 Free Software Foundation, Inc.
+# written by Douglas C. Schmidt (schmidt@ics.uci.edu)
+#
+# This file is part of GNU GPERF.
+#
+# GNU GPERF is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 1, or (at your option)
+# any later version.
+#
+# GNU GPERF is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU GPERF; see the file COPYING. If not, write to
+# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+GPERF = gperf
+CC = gcc
+
+all: test
+
+test:
+ @echo "performing some tests of the perfect hash generator"
+ $(CC) -c -O test.c
+ $(GPERF) -p -c -l -S1 -C -o c.gperf > cinset.c
+ $(CC) -O -o cout cinset.c test.o
+ @echo "testing ANSI C reserved words, all items should be found in the set"
+ ./cout -v < c.gperf
+ $(GPERF) -k1,4,'$$' ada.gperf > adainset.c
+# double '$$' is only there since make gets confused; program wants only 1 '$'
+ $(CC) -O -o aout adainset.c test.o
+ @echo "testing Ada reserved words,all items should be found in the set"
+ ./aout -v < ada.gperf
+ $(GPERF) -p -D -S1 -k1,'$$' -s 2 -o adapredefined.gperf > preinset.c
+ $(CC) -O -o preout preinset.c test.o
+ @echo "testing Ada predefined words, all items should be found in the set"
+ ./preout -v < adapredefined.gperf
+ $(GPERF) -k1,2,'$$' -o modula3.gperf > m3inset.c
+ $(CC) -O -o m3out m3inset.c test.o
+ @echo "testing Modula3 reserved words, all items should be found in the set"
+ ./m3out -v < modula3.gperf
+ $(GPERF) -o -S1 -p < pascal.gperf > pinset.c
+ $(CC) -O -o pout pinset.c test.o
+ @echo "testing Pascal reserved words, all items should be found in the set"
+ ./pout -v < pascal.gperf
+ $(GPERF) -o -S2 -j1 -D -p -t < c++.gperf > c++inset.c
+ $(CC) -O -o c++out c++inset.c test.o
+ @echo "testing C++ reserved words, all items should be found in the set"
+ tail -47 c++.gperf | ./c++out -v
+# these next 5 are demos that show off the generated code
+ $(GPERF) -p -j1 -g -o -t -N is_reserved_word -k1,3,'$$' c-parse.gperf
+ $(GPERF) -n -k1-8 -l modula2.gperf
+ $(GPERF) -p -j 1 -o -a -g -t -k1,4,$$ gplus.gperf
+ $(GPERF) -D -p -t < c-parse.gperf
+ $(GPERF) -g -o -j1 -t -p -N is_reserved_word gpc.gperf
+# prints out the help message
+ -$(GPERF) -h
+ @echo "only if, do, for, case, goto, else, while, and return should be found "
+ ./aout -v < c.gperf
+
+clean:
+ -rm -f *.o core *~ *inset.c *out #*#
diff --git a/contrib/gperf/tests/ada.gperf b/contrib/gperf/tests/ada.gperf
new file mode 100644
index 0000000..332bdc7
--- /dev/null
+++ b/contrib/gperf/tests/ada.gperf
@@ -0,0 +1,63 @@
+else
+exit
+terminate
+type
+raise
+range
+reverse
+declare
+end
+record
+exception
+not
+then
+return
+separate
+select
+digits
+renames
+subtype
+elsif
+function
+for
+package
+procedure
+private
+while
+when
+new
+entry
+delay
+case
+constant
+at
+abort
+accept
+and
+delta
+access
+abs
+pragma
+array
+use
+out
+do
+others
+of
+or
+all
+limited
+loop
+null
+task
+in
+is
+if
+rem
+mod
+begin
+body
+xor
+goto
+generic
+with
diff --git a/contrib/gperf/tests/adapredefined.gperf b/contrib/gperf/tests/adapredefined.gperf
new file mode 100644
index 0000000..875be69
--- /dev/null
+++ b/contrib/gperf/tests/adapredefined.gperf
@@ -0,0 +1,54 @@
+boolean
+character
+constraint_error
+false
+float
+integer
+natural
+numeric_error
+positive
+program_error
+storage_error
+string
+tasking_error
+true
+address
+aft
+base
+callable
+constrained
+count
+delta
+digits
+emax
+epsilon
+first
+firstbit
+fore
+image
+large
+last
+lastbit
+length
+machine_emax
+machine_emin
+machine_mantissa
+machine_overflows
+machine_radix
+machine_rounds
+mantissa
+pos
+position
+pred
+range
+safe_emax
+safe_large
+safe_small
+size
+small
+storage_size
+succ
+terminated
+val
+value
+width
diff --git a/contrib/gperf/tests/c++.gperf b/contrib/gperf/tests/c++.gperf
new file mode 100644
index 0000000..d09b13b
--- /dev/null
+++ b/contrib/gperf/tests/c++.gperf
@@ -0,0 +1,49 @@
+struct resword {char *name;};
+%%
+asm
+auto
+break
+case
+catch
+char
+class
+const
+continue
+default
+delete
+do
+double
+else
+enum
+extern
+float
+for
+friend
+goto
+if
+inline
+int
+long
+new
+operator
+overload
+private
+protected
+public
+register
+return
+short
+signed
+sizeof
+static
+struct
+switch
+template
+this
+typedef
+union
+unsigned
+virtual
+void
+volatile
+while
diff --git a/contrib/gperf/tests/c-parse.gperf b/contrib/gperf/tests/c-parse.gperf
new file mode 100644
index 0000000..f886f58
--- /dev/null
+++ b/contrib/gperf/tests/c-parse.gperf
@@ -0,0 +1,56 @@
+%{
+/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf */
+%}
+struct resword { char *name; short token; enum rid rid; };
+%%
+__alignof, ALIGNOF, NORID
+__alignof__, ALIGNOF, NORID
+__asm, ASM, NORID
+__asm__, ASM, NORID
+__attribute, ATTRIBUTE, NORID
+__attribute__, ATTRIBUTE, NORID
+__const, TYPE_QUAL, RID_CONST
+__const__, TYPE_QUAL, RID_CONST
+__inline, SCSPEC, RID_INLINE
+__inline__, SCSPEC, RID_INLINE
+__signed, TYPESPEC, RID_SIGNED
+__signed__, TYPESPEC, RID_SIGNED
+__typeof, TYPEOF, NORID
+__typeof__, TYPEOF, NORID
+__volatile, TYPE_QUAL, RID_VOLATILE
+__volatile__, TYPE_QUAL, RID_VOLATILE
+asm, ASM, NORID
+auto, SCSPEC, RID_AUTO
+break, BREAK, NORID
+case, CASE, NORID
+char, TYPESPEC, RID_CHAR
+const, TYPE_QUAL, RID_CONST
+continue, CONTINUE, NORID
+default, DEFAULT, NORID
+do, DO, NORID
+double, TYPESPEC, RID_DOUBLE
+else, ELSE, NORID
+enum, ENUM, NORID
+extern, SCSPEC, RID_EXTERN
+float, TYPESPEC, RID_FLOAT
+for, FOR, NORID
+goto, GOTO, NORID
+if, IF, NORID
+inline, SCSPEC, RID_INLINE
+int, TYPESPEC, RID_INT
+long, TYPESPEC, RID_LONG
+register, SCSPEC, RID_REGISTER
+return, RETURN, NORID
+short, TYPESPEC, RID_SHORT
+signed, TYPESPEC, RID_SIGNED
+sizeof, SIZEOF, NORID
+static, SCSPEC, RID_STATIC
+struct, STRUCT, NORID
+switch, SWITCH, NORID
+typedef, SCSPEC, RID_TYPEDEF
+typeof, TYPEOF, NORID
+union, UNION, NORID
+unsigned, TYPESPEC, RID_UNSIGNED
+void, TYPESPEC, RID_VOID
+volatile, TYPE_QUAL, RID_VOLATILE
+while, WHILE, NORID
diff --git a/contrib/gperf/tests/c.gperf b/contrib/gperf/tests/c.gperf
new file mode 100644
index 0000000..8672d6c
--- /dev/null
+++ b/contrib/gperf/tests/c.gperf
@@ -0,0 +1,32 @@
+if
+do
+int
+for
+case
+char
+auto
+goto
+else
+long
+void
+enum
+float
+short
+union
+break
+while
+const
+double
+static
+extern
+struct
+return
+sizeof
+switch
+signed
+typedef
+default
+unsigned
+continue
+register
+volatile
diff --git a/contrib/gperf/tests/gpc.gperf b/contrib/gperf/tests/gpc.gperf
new file mode 100644
index 0000000..8fb469e
--- /dev/null
+++ b/contrib/gperf/tests/gpc.gperf
@@ -0,0 +1,48 @@
+%{
+/* ISO Pascal 7185 reserved words.
+ *
+ * For GNU Pascal compiler (GPC) by jtv@hut.fi
+ *
+ * run this through the Doug Schmidt's gperf program
+ * with command
+ * gperf -g -o -j1 -t -p -N is_reserved_word
+ *
+ */
+%}
+struct resword { char *name; short token; short iclass;};
+%%
+And, AND, PASCAL_ISO
+Array, ARRAY, PASCAL_ISO
+Begin, BEGIN_, PASCAL_ISO
+Case, CASE, PASCAL_ISO
+Const, CONST, PASCAL_ISO
+Div, DIV, PASCAL_ISO
+Do, DO, PASCAL_ISO
+Downto, DOWNTO, PASCAL_ISO
+Else, ELSE, PASCAL_ISO
+End, END, PASCAL_ISO
+File, FILE_, PASCAL_ISO
+For, FOR, PASCAL_ISO
+Function, FUNCTION, PASCAL_ISO
+Goto, GOTO, PASCAL_ISO
+If, IF, PASCAL_ISO
+In, IN, PASCAL_ISO
+Label, LABEL, PASCAL_ISO
+Mod, MOD, PASCAL_ISO
+Nil, NIL, PASCAL_ISO
+Not, NOT, PASCAL_ISO
+Of, OF, PASCAL_ISO
+Or, OR, PASCAL_ISO
+Packed, PACKED, PASCAL_ISO
+Procedure, PROCEDURE, PASCAL_ISO
+Program,PROGRAM,PASCAL_ISO
+Record, RECORD, PASCAL_ISO
+Repeat, REPEAT, PASCAL_ISO
+Set, SET, PASCAL_ISO
+Then, THEN, PASCAL_ISO
+To, TO, PASCAL_ISO
+Type, TYPE, PASCAL_ISO
+Until, UNTIL, PASCAL_ISO
+Var, VAR, PASCAL_ISO
+While, WHILE, PASCAL_ISO
+With, WITH, PASCAL_ISO
diff --git a/contrib/gperf/tests/gplus.gperf b/contrib/gperf/tests/gplus.gperf
new file mode 100644
index 0000000..4a93315
--- /dev/null
+++ b/contrib/gperf/tests/gplus.gperf
@@ -0,0 +1,76 @@
+%{
+/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$ gplus.gperf */
+%}
+struct resword { char *name; short token; enum rid rid;};
+%%
+__alignof, ALIGNOF, NORID
+__alignof__, ALIGNOF, NORID
+__asm, ASM, NORID
+__asm__, ASM, NORID
+__attribute, ATTRIBUTE, NORID
+__attribute__, ATTRIBUTE, NORID
+__const, TYPE_QUAL, RID_CONST
+__const__, TYPE_QUAL, RID_CONST
+__inline, SCSPEC, RID_INLINE
+__inline__, SCSPEC, RID_INLINE
+__signed, TYPESPEC, RID_SIGNED
+__signed__, TYPESPEC, RID_SIGNED
+__typeof, TYPEOF, NORID
+__typeof__, TYPEOF, NORID
+__volatile, TYPE_QUAL, RID_VOLATILE
+__volatile__, TYPE_QUAL, RID_VOLATILE
+all, ALL, NORID /* Extension */,
+except, EXCEPT, NORID /* Extension */,
+exception, AGGR, RID_EXCEPTION /* Extension */,
+raise, RAISE, NORID /* Extension */,
+raises, RAISES, NORID /* Extension */,
+reraise, RERAISE, NORID /* Extension */,
+try, TRY, NORID /* Extension */,
+asm, ASM, NORID,
+auto, SCSPEC, RID_AUTO,
+break, BREAK, NORID,
+case, CASE, NORID,
+catch, CATCH, NORID,
+char, TYPESPEC, RID_CHAR,
+class, AGGR, RID_CLASS,
+const, TYPE_QUAL, RID_CONST,
+continue, CONTINUE, NORID,
+default, DEFAULT, NORID,
+delete, DELETE, NORID,
+do, DO, NORID,
+double, TYPESPEC, RID_DOUBLE,
+dynamic, DYNAMIC, NORID,
+else, ELSE, NORID,
+enum, ENUM, NORID,
+extern, SCSPEC, RID_EXTERN,
+float, TYPESPEC, RID_FLOAT,
+for, FOR, NORID,
+friend, SCSPEC, RID_FRIEND,
+goto, GOTO, NORID,
+if, IF, NORID,
+inline, SCSPEC, RID_INLINE,
+int, TYPESPEC, RID_INT,
+long, TYPESPEC, RID_LONG,
+new, NEW, NORID,
+operator, OPERATOR, NORID,
+overload, OVERLOAD, NORID,
+private, PRIVATE, NORID,
+protected, PROTECTED, NORID,
+public, PUBLIC, NORID,
+register, SCSPEC, RID_REGISTER,
+return, RETURN, NORID,
+short, TYPESPEC, RID_SHORT,
+signed, TYPESPEC, RID_SIGNED,
+sizeof, SIZEOF, NORID,
+static, SCSPEC, RID_STATIC,
+struct, AGGR, RID_RECORD,
+switch, SWITCH, NORID,
+this, THIS, NORID,
+typedef, SCSPEC, RID_TYPEDEF,
+typeof, TYPEOF, NORID,
+union, AGGR, RID_UNION,
+unsigned, TYPESPEC, RID_UNSIGNED,
+virtual, SCSPEC, RID_VIRTUAL,
+void, TYPESPEC, RID_VOID,
+volatile, TYPE_QUAL, RID_VOLATILE,
+while, WHILE, NORID,
diff --git a/contrib/gperf/tests/modula2.gperf b/contrib/gperf/tests/modula2.gperf
new file mode 100644
index 0000000..5ef9c75
--- /dev/null
+++ b/contrib/gperf/tests/modula2.gperf
@@ -0,0 +1,40 @@
+AND
+ARRAY
+BEGIN
+BY
+CASE
+CONST
+DEFINITION
+DIV
+DO
+ELSE
+ELSIF
+END
+EXIT
+EXPORT
+FOR
+FROM
+IF
+IMPLEMENTATION
+IMPORT
+IN
+LOOP
+MOD
+MODULE
+NOT
+OF
+OR
+POINTER
+PROCEDURE
+QUALIFIED
+RECORD
+REPEAT
+RETURN
+SET
+THEN
+TO
+TYPE
+UNTIL
+VAR
+WHILE
+WITH
diff --git a/contrib/gperf/tests/modula3.gperf b/contrib/gperf/tests/modula3.gperf
new file mode 100644
index 0000000..d024346
--- /dev/null
+++ b/contrib/gperf/tests/modula3.gperf
@@ -0,0 +1,106 @@
+AND
+ARRAY
+BEGIN
+BITS
+BY
+CASE
+CONST
+DIV
+DO
+ELSE
+ELSIF
+END
+EVAL
+EXCEPT
+EXCEPTION
+EXIT
+EXPORTS
+FINALLY
+FOR
+FROM
+IF
+IMPORT
+INTERFACE
+IN
+INLINE
+LOCK
+METHODS
+MOD
+MODULE
+NOT
+OBJECT
+OF
+OR
+PROCEDURE
+RAISES
+READONLY
+RECORD
+REF
+REPEAT
+RETURN
+SET
+THEN
+TO
+TRY
+TYPE
+TYPECASE
+UNSAFE
+UNTIL
+UNTRACED
+VALUE
+VAR
+WHILE
+WITH
+and
+array
+begin
+bits
+by
+case
+const
+div
+do
+else
+elsif
+end
+eval
+except
+exception
+exit
+exports
+finally
+for
+from
+if
+import
+interface
+in
+inline
+lock
+methods
+mod
+module
+not
+object
+of
+or
+procedure
+raises
+readonly
+record
+ref
+repeat
+return
+set
+then
+to
+try
+type
+typecase
+unsafe
+until
+untraced
+value
+var
+while
+with
diff --git a/contrib/gperf/tests/pascal.gperf b/contrib/gperf/tests/pascal.gperf
new file mode 100644
index 0000000..fed3fbb
--- /dev/null
+++ b/contrib/gperf/tests/pascal.gperf
@@ -0,0 +1,36 @@
+with
+array
+and
+function
+case
+var
+const
+until
+then
+set
+record
+program
+procedure
+or
+packed
+not
+nil
+label
+in
+repeat
+of
+goto
+forward
+for
+while
+file
+else
+downto
+do
+div
+to
+type
+end
+mod
+begin
+if
diff --git a/contrib/gperf/tests/test.c b/contrib/gperf/tests/test.c
new file mode 100644
index 0000000..528e2fa
--- /dev/null
+++ b/contrib/gperf/tests/test.c
@@ -0,0 +1,32 @@
+/*
+ Tests the generated perfect has function.
+ The -v option prints diagnostics as to whether a word is in
+ the set or not. Without -v the program is useful for timing.
+*/
+
+#include <stdio.h>
+
+#define MAX_LEN 80
+
+#ifdef __STDC__
+int in_word_set (char *, unsigned int);
+int
+main (int argc, char *argv[])
+#else
+int
+main (argc, argv)
+ int argc;
+ char *argv[];
+#endif
+{
+ int verbose = argc > 1 ? 1 : 0;
+ char buf[MAX_LEN];
+
+ while (gets (buf))
+ if (in_word_set (buf, strlen (buf)) && verbose)
+ printf ("in word set %s\n", buf);
+ else if (verbose)
+ printf ("NOT in word set %s\n", buf);
+
+ return 0;
+}
OpenPOWER on IntegriCloud