|
7 | 7 | #
|
8 | 8 | # src/tools/check_keywords.pl
|
9 | 9 |
|
| 10 | +my$errors = 0; |
10 | 11 | my$path;
|
11 | 12 |
|
| 13 | +suberror(@) { |
| 14 | +printSTDERR@_; |
| 15 | +$errors = 1; |
| 16 | +} |
| 17 | + |
12 | 18 | if (@ARGV) {
|
13 | 19 | $path =$ARGV[0];
|
14 | 20 | shift@ARGV;
|
|
102 | 108 | $bare_kword =$kword;
|
103 | 109 | $bare_kword =~s/_P$//;
|
104 | 110 | if ($bare_kwordle$prevkword) {
|
105 |
| -print"'$bare_kword' after '$prevkword' in$kcat list is misplaced"; |
| 111 | + error"'$bare_kword' after '$prevkword' in$kcat list is misplaced"; |
| 112 | +$errors = 1; |
106 | 113 | }
|
107 | 114 | $prevkword =$bare_kword;
|
108 | 115 | }
|
|
141 | 148 |
|
142 | 149 | # Check that the list is in alphabetical order
|
143 | 150 | if ($kwstringle$prevkwstring) {
|
144 |
| -print"'$kwstring' after '$prevkwstring' in kwlist.h is misplaced"; |
| 151 | +error"'$kwstring' after '$prevkwstring' in kwlist.h is misplaced"; |
145 | 152 | }
|
146 | 153 | $prevkwstring =$kwstring;
|
147 | 154 |
|
148 | 155 | # Check that the keyword string is valid: all lower-case ASCII chars
|
149 | 156 | if ($kwstring !~/^[a-z_]*$/) {
|
150 |
| -print"'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars"; |
| 157 | +error"'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars"; |
151 | 158 | }
|
152 | 159 |
|
153 | 160 | # Check that the keyword name is valid: all upper-case ASCII chars
|
154 | 161 | if ($kwname !~/^[A-Z_]*$/) {
|
155 |
| -print"'$kwname' is not a valid keyword name, must be all upper-case ASCII chars"; |
| 162 | +error"'$kwname' is not a valid keyword name, must be all upper-case ASCII chars"; |
156 | 163 | }
|
157 | 164 |
|
158 | 165 | # Check that the keyword string matches keyword name
|
159 | 166 | $bare_kwname =$kwname;
|
160 | 167 | $bare_kwname =~s/_P$//;
|
161 | 168 | if ($bare_kwnameneuc($kwstring)) {
|
162 |
| -print"keyword name '$kwname' doesn't match keyword string '$kwstring'"; |
| 169 | +error"keyword name '$kwname' doesn't match keyword string '$kwstring'"; |
163 | 170 | }
|
164 | 171 |
|
165 | 172 | # Check that the keyword is present in the grammar
|
166 | 173 | %kwhash = %{$kwhashes{$kwcat_id}};
|
167 | 174 |
|
168 | 175 | if (!(%kwhash)){
|
169 |
| -#print "Unknown kwcat_id: $kwcat_id"; |
| 176 | +#error "Unknown kwcat_id: $kwcat_id"; |
170 | 177 | }else {
|
171 | 178 | if (!($kwhash{$kwname})) {
|
172 |
| -print"'$kwname' not present in$kwcat_id section of gram.y"; |
| 179 | +error"'$kwname' not present in$kwcat_id section of gram.y"; |
173 | 180 | }else {
|
174 | 181 | # Remove it from the hash, so that we can complain at the end
|
175 | 182 | # if there's keywords left that were not found in kwlist.h
|
|
185 | 192 | %kwhash = %{$kwhashes{$kwcat_id}};
|
186 | 193 |
|
187 | 194 | formy$kw (keys%kwhash ) {
|
188 |
| -print"'$kw' found in gram.y$kwcat category, but not in kwlist.h" |
| 195 | +error"'$kw' found in gram.y$kwcat category, but not in kwlist.h" |
189 | 196 | }
|
190 | 197 | }
|
| 198 | + |
| 199 | +exit$errors; |