1 # gen-omegascript-vim: generate vim syntax mode for OmegaScript
3 # Copyright (C) 2009 Olly Betts
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 2 of the
8 # License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 my ($srcdir, $version) = @ARGV;
23 open Q, "$srcdir/query.cc" or die $!;
27 next unless /^T\((\w+),\s*(\w+),\s*(\w+)/;
28 push @noparam, $1 if $2 eq '0';
29 push @param, $1 if $3 ne '0';
33 my $noparam = join(' ', @noparam);
34 my $param = join(' ', @param);
36 open I, "$srcdir/extra/omegascript.vim.in" or die $!;
37 mkdir('extra', 0755) unless $srcdir eq '.' || -d 'extra';
38 open O, '>', 'extra/omegascript.vim.tmp' or die $!;
40 s/\@([A-Z_]+)\@/var($1)/eg;
45 rename 'extra/omegascript.vim.tmp', 'extra/omegascript.vim';
49 return $version if ($v eq 'VERSION');
50 return $param if ($v eq 'OMEGASCRIPT_PARAM');
51 return $noparam if ($v eq 'OMEGASCRIPT_NO_PARAM');
52 die "Unknown replacement token \@$v\@\n";