summaryrefslogtreecommitdiff
path: root/Docs/Support
diff options
context:
space:
mode:
authorunknown <jcole@tetra.spaceapes.com>2001-10-18 21:50:25 -0500
committerunknown <jcole@tetra.spaceapes.com>2001-10-18 21:50:25 -0500
commitffff4af264f222d9eb85c11a03c7829b8b4a157f (patch)
tree1437675fbcbf284bd939e000f3425af802061609 /Docs/Support
parent3a31f3bcebd70b39c564b31c1eb84d651233b745 (diff)
downloadmariadb-git-ffff4af264f222d9eb85c11a03c7829b8b4a157f.tar.gz
Oops, didn't actually commit the script.
Diffstat (limited to 'Docs/Support')
-rwxr-xr-xDocs/Support/update-reserved-words.pl81
1 files changed, 81 insertions, 0 deletions
diff --git a/Docs/Support/update-reserved-words.pl b/Docs/Support/update-reserved-words.pl
new file mode 100755
index 00000000000..a93d63f678f
--- /dev/null
+++ b/Docs/Support/update-reserved-words.pl
@@ -0,0 +1,81 @@
+#!/usr/bin/perl
+
+print STDERR "Scanning lex.h for symbols..\n";
+open LEX, "<../sql/lex.h";
+while($line = <LEX>) {
+ if($line =~ /\{\s+\"([A-Z_]+)\",\s+SYM\(([A-Z_]+)\)/) {
+ $words{$2} = $1;
+ } elsif($line =~ /sql_functions/) {
+ last;
+ };
+};
+close LEX;
+
+print STDERR "Scanning sql_yacc.yy for non-reserved words...\n";
+open YACC, "<../sql/sql_yacc.yy";
+while(<YACC> !~ /^keyword:/) {};
+while(($line = <YACC>) =~ /[\s|]+([A-Z_]+)/) {
+ delete $words{$1};
+};
+close YACC;
+
+
+$list = sprintf("\@c Reserved word list updated %s by %s.\n".
+ "\@c To regenerate, use Support/update-reserved-words.pl.\n\n",
+ &pretty_date, $ENV{USER});
+
+
+print STDERR "Copying reserved words to an array...\n";
+foreach(keys %words) { push @words, $words{$_}; };
+
+print STDERR "Sorting array...\n";
+@words = sort @words;
+
+printf STDERR "There are %i reserved words.\n", scalar @words;
+
+@pre = ("\@item", "\@tab", " \@tab", "\@tab");
+@post = ("", "\n", "", "\n");
+
+for($i=0; $word = shift(@words); $i++) {
+ $list .= sprintf "%s %-30s %s", $pre[$i%4], "\@code\{$word\}", $post[$i%4];
+}; $list .= "\n";
+
+open OLD, "<manual.texi";
+open NEW, ">manual-tmp.texi";
+
+print STDERR "Copying beginning of manual.texi...\n";
+while(($line = <OLD>) !~ /START_OF_RESERVED_WORDS/) { print NEW $line; };
+print NEW "\@c START_OF_RESERVED_WORDS\n\n";
+print STDERR "Inserting list of reserved words...\n";
+print NEW "\@multitable \@columnfractions .25 .25 .25 .25\n";
+print NEW $list;
+print NEW "\@end multitable\n";
+print STDERR "Skipping over old list...\n";
+while(($line = <OLD>) !~ /END_OF_RESERVED_WORDS/) {};
+print NEW "\n\@c END_OF_RESERVED_WORDS\n";
+print STDERR "Copying end of manual.texi...\n";
+while($line = <OLD>) { print NEW $line; };
+
+close OLD;
+close NEW;
+
+print STDERR "Moving manual-tmp.texi to manual.texi...\n";
+unlink "manual.texi";
+rename "manual-tmp.texi", "manual.texi";
+
+print STDERR "Reserved word list updated successfully!\n";
+
+sub pretty_date {
+ @time = ($time = shift)?((localtime($time))[0..6]):((localtime)[0..6]);
+
+ ($sec, $min, $hour, $mday, $mon, $year, $wday) = @time;
+ $wday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$wday];
+ $mon = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon];
+ $year += 1900;
+
+ $pretty = sprintf("%s %s %2i %02i:%02i:%02i %i",
+ $wday, $mon, $mday, $hour, $min, $sec, $year);
+
+ return $pretty;
+};
+