#
# src/tools/check_keywords.pl
+my $errors = 0;
my $path;
+sub error(@) {
+ print STDERR @_;
+ $errors = 1;
+}
+
if (@ARGV) {
$path = $ARGV[0];
shift @ARGV;
$bare_kword = $kword;
$bare_kword =~ s/_P$//;
if ($bare_kword le $prevkword) {
- print "'$bare_kword' after '$prevkword' in $kcat list is misplaced";
+ error "'$bare_kword' after '$prevkword' in $kcat list is misplaced";
+ $errors = 1;
}
$prevkword = $bare_kword;
}
# Check that the list is in alphabetical order
if ($kwstring le $prevkwstring) {
- print "'$kwstring' after '$prevkwstring' in kwlist.h is misplaced";
+ error "'$kwstring' after '$prevkwstring' in kwlist.h is misplaced";
}
$prevkwstring = $kwstring;
# Check that the keyword string is valid: all lower-case ASCII chars
if ($kwstring !~ /^[a-z_]*$/) {
- print "'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars";
+ error "'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars";
}
# Check that the keyword name is valid: all upper-case ASCII chars
if ($kwname !~ /^[A-Z_]*$/) {
- print "'$kwname' is not a valid keyword name, must be all upper-case ASCII chars";
+ error "'$kwname' is not a valid keyword name, must be all upper-case ASCII chars";
}
# Check that the keyword string matches keyword name
$bare_kwname = $kwname;
$bare_kwname =~ s/_P$//;
if ($bare_kwname ne uc($kwstring)) {
- print "keyword name '$kwname' doesn't match keyword string '$kwstring'";
+ error "keyword name '$kwname' doesn't match keyword string '$kwstring'";
}
# Check that the keyword is present in the grammar
%kwhash = %{$kwhashes{$kwcat_id}};
if (!(%kwhash)) {
- #print "Unknown kwcat_id: $kwcat_id";
+ #error "Unknown kwcat_id: $kwcat_id";
} else {
if (!($kwhash{$kwname})) {
- print "'$kwname' not present in $kwcat_id section of gram.y";
+ error "'$kwname' not present in $kwcat_id section of gram.y";
} else {
# Remove it from the hash, so that we can complain at the end
# if there's keywords left that were not found in kwlist.h
%kwhash = %{$kwhashes{$kwcat_id}};
for my $kw ( keys %kwhash ) {
- print "'$kw' found in gram.y $kwcat category, but not in kwlist.h"
+ error "'$kw' found in gram.y $kwcat category, but not in kwlist.h"
}
}
+
+exit $errors;