#!/usr/bin/env perl eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' & eval 'exec perl -w -S $0 $argv:q' if 0; # ****************************************************************** # Author: Chad Elliott # Date: 2/16/2006 # ****************************************************************** # ****************************************************************** # Pragma Section # ****************************************************************** use strict; use FileHandle; use FindBin; use File::Spec; use File::Basename; my $basePath = $FindBin::Bin; if ($^O eq 'VMS') { $basePath = File::Spec->rel2abs(dirname($0)) if ($basePath eq ''); $basePath = VMS::Filespec::unixify($basePath); } $basePath = dirname($basePath); unshift(@INC, $basePath . '/modules'); require ProjectCreator; require TemplateParser; # ****************************************************************** # Data Section # ****************************************************************** my %keywords; my %arrow_op; my $ifmod = 0; my $formod = 0; my $cmod = 50; my %keycolors = (0 => [160, 32, 240], 1 => [255, 50, 50], 2 => [50, 50, 255], ); my $version = '1.3'; # ****************************************************************** # Subroutine Section # ****************************************************************** sub setup_keywords { ## Get the main MPC keywords my $keywords = ProjectCreator::getKeywords(); foreach my $key (keys %$keywords) { $keywords{$key} = 0; } ## Get the pseudo template variables my $pjc = new ProjectCreator(); $keywords = $pjc->get_command_subs(); foreach my $key (keys %$keywords) { $keywords{$key} = 0; } ## Get the template function names $keywords = TemplateParser::getKeywords(); foreach my $key (keys %$keywords) { $keywords{$key} = 0; } ## Get the template parser arrow operator keys $keywords = TemplateParser::getArrowOp(); foreach my $key (keys %$keywords) { $arrow_op{$key} = 0; } ## These TemplateParser keywords need special values so ## that the color coding will recognize these as different ## from the rest of the keywords foreach my $key ('if', 'else', 'endif') { $keywords{$key} = 1; } foreach my $key ('foreach', 'forfirst', 'fornotfirst', 'fornotlast', 'forlast', 'endfor') { $keywords{$key} = 2; } } sub convert_to_html { my $line = shift; $line =~ s/&/&/g; $line =~ s//>/g; $line =~ s/"/"/g; $line =~ s/ / /g; $line =~ s/\t/        /g; $line =~ s/\n/
/; return $line; } sub usageAndExit { print "highlight_template.pl v$version\n", "Usage: ", basename($0), "