Debian Codegraph @

tests/jstest3.gperf

raw
1 struct js_keyword {
2 const char * name;
3 int token;
4 }
5 %%
6 abstract, 1
7 boolean, 2
8 break, 3
9 byte, 4
10 case, 5
11 catch, 6
12 char, 7
13 class, 8
14 const, 9
15 continue, 10
16 default, 11
17 do, 12
18 double, 13
19 else, 14
20 extends, 15
21 false, 16
22 final, 17
23 finally, 18
24 float, 19
25 for, 20
26 function, 21
27 goto, 22
28 if, 23
29 implements, 24
30 import, 25
31 in, 26
32 instanceof, 27
33 int, 28
34 interface, 29
35 long, 30
36 native, 31
37 new, 32
38 null, 33
39 package, 34
40 private, 35
41 protected, 36
42 public, 37
43 return, 38
44 short, 39
45 static, 40
46 super, 41
47 switch, 42
48 synchronized, 43
49 this, 44
50 throw, 45
51 throws, 46
52 transient, 47
53 true, 48
54 try, 49
55 var, 50
56 void, 51
57 while, 52
58 with, 53
59 %%
60 #include <stdlib.h>
61 #include <string.h>
62 static const char* testdata[] = {
63 "bogus",
64 "abstract",
65 "boolean",
66 "break",
67 "byte",
68 "case",
69 "catch",
70 "char",
71 "class",
72 "const",
73 "continue",
74 "default",
75 "do",
76 "double",
77 "else",
78 "extends",
79 "false",
80 "final",
81 "finally",
82 "float",
83 "for",
84 "function",
85 "goto",
86 "if",
87 "implements",
88 "import",
89 "in",
90 "instanceof",
91 "int",
92 "interface",
93 "long",
94 "native",
95 "new",
96 "null",
97 "package",
98 "private",
99 "protected",
100 "public",
101 "return",
102 "short",
103 "static",
104 "super",
105 "switch",
106 "synchronized",
107 "this",
108 "throw",
109 "throws",
110 "transient",
111 "true",
112 "try",
113 "var",
114 "void",
115 "while",
116 "with"
117 };
118 int main ()
119 {
120 int i;
121 for (i = 0; i < sizeof(testdata)/sizeof(testdata[0]); i++)
122 {
123 #ifdef CPLUSPLUS_TEST
124 const struct js_keyword * resword = Perfect_Hash::in_word_set(testdata[i],strlen(testdata[i]));
125 #else
126 const struct js_keyword * resword = in_word_set(testdata[i],strlen(testdata[i]));
127 #endif
128 if (i > 0)
129 {
130 if (!resword)
131 exit (1);
132 if (strcmp(testdata[i],resword->name))
133 exit (1);
134 }
135 else
136 {
137 if (resword)
138 exit (1);
139 }
140 }
141 return 0;
142 }