#!/usr/bin/perl -w
#        Copyright (c) 1999 by Peter Palfrader.                      #
#        do what you want & It's not my fault                        #

use strict;
use Data::Dumper;


my @nix;
my $dummy;


my %params;

$params{modes} = 0;


my @lang =
(
    'plain',
    'ada',
    'c',
    'c++',
    'html',
    'java',
    'js',
    'make',
    'pas',
    'perl',
    'sql',
    'awk',
    'm4',
    'groff'
);

my %lang;

for (@lang)
  {
      $params{langmode} = $_;
      $lang{$_} = {
		   'names' => [ $_ ],
		   'extensions' => [],
		   'regex' => [],
		   'patterns' => &parse_config_part( &get_config_file(\@nix, \%params) , $dummy, $dummy)
		  };
  };


print Data::Dumper->Dump( [ \%lang ] ) ;
exit;






################################################################################
####################### get_config_lines #######################################
################################################################################
sub get_config_lines
  {
    #in : \@lines
    #in : metaquoted $langmode
    #in : $modes

    #returns config file as string

   my @lines = @{shift()};
    my ($lm, $modes) = @_;
    my $result = "";


    if ($modes)
      {
	for (@lines)
	  {
	    $_ =~ s/\n|\r//g;
	    $_ =~ s/^[ \t]*(.*)[ \t]*/$1/; #remove beginning and trailing spaces / tabs
	    print "    ".$_."\n" if (substr($_,0,1) eq "[");
	  }
      } 
    else 
      {
	  my $waiting = 1;
	  for (@lines)
	    {
		if ($waiting)
		  {
		      $_ =~ s/\n|\r//g;
		      $_ =~ s/^[ \t]*(.*)[ \t]*/$1/; #remove beginning and trailing spaces / tabs
		      if ($_ =~ m/^\[(.*?[, ])?$lm([, ].*?)?\]/i)
			{$waiting = 0;};
		  }
		else
		  {
		      $_ =~ s/\n|\r//g;
		      $_ =~ s/^[ \t]*(.*)[ \t]*/$1/; #remove beginning and trailing spaces / tabs
		      last if (substr($_,0,1) eq "["); #new language mode
		      
		      if (($_ ne "")&&(substr($_, 0, 1) ne "#"))
			{
			    $_ =~ /^(.*)$/;    # untaint input
			    $result .= $1."\n";
			}
		  }
	    };
      };
    
    return $result;
};

################################################################################
####################### get_one_config_file ####################################
################################################################################
sub get_one_config_file
{
    #in: filename
    #in: langmode already meta quoted.
    #in: modes;
    #returns config file as string
    
    my ($filename, $langmode, $modes) = @_;

    open(FILEHANDLE, "<$filename") || return "";

    my @lines = <FILEHANDLE>;
    my $result = get_config_lines(\@lines, $langmode, $modes);
    close FILEHANDLE;
    
    return $result;
};

################################################################################
####################### get_config_file ########################################
################################################################################
sub get_config_file
{
    #in : @config_files
    #in : %params
    #returns config file as string
    
    my @CONFIG_FILES = @{shift()};
    my %PARAMS       = %{shift()};


    #Apply language mode
    my $result = "";

    if ($PARAMS{'modes'})
      {
	  print "\n\nDefined language modes:\n";
	  print "-----------------------\n";
	  print "(You may use any of the names seperated\n";
	  print "by commas to refer to a certain mode.)\n\n";
      };
    
    for (@CONFIG_FILES)
      {
	  print "in file $_:\n" if $PARAMS{'modes'};

	  $result = &get_one_config_file($_, quotemeta($PARAMS{'langmode'}), $PARAMS{'modes'});
	  if ($result ne "") {last;};
      };

    if ($result eq "")
      {
	  print "in default database:\n" if $PARAMS{'modes'};
	  
	  my @lines = split(/\n/,&get_default_database);
	  $result = &get_config_lines(\@lines, quotemeta($PARAMS{'langmode'}), $PARAMS{'modes'});
      }
    
    if ($PARAMS{'modes'})
      {
	  print "-----------------------\n";
	  print "That's it\n\n\n";
	  exit;
      };


    if ($result eq "")
      {
		die("Given language mode '".$PARAMS{'langmode'}."' was not found in config files.\n");
      }

    return $result;
};


################################################################################
####################### parse_config_part ######################################
################################################################################
sub parse_config_part
{
    #in: string: config data
    #in: string: bgcolor
    #in: string: textcolor
    #returns \@regexps
    
    my ($configdata, $bgcolor, $textcolor) = @_;

    my @regexps = ();
    my @null_array;

    while ($configdata =~ /(^[^\-].*?$)/gms) # )
	   {
	       my $us = $1;
	       my $after = substr($configdata, pos($configdata));
	       
	       if ($us =~ /^"/) #";# xemacs :)
		   {
		       my %t = ();
		       my $tmp = "";
		       my @null_array;
		       my $child_ref = \@null_array;
		       
		       $us =~ s/([ \t]*("([^"]|\\")*")[ \t]*,)//m; $tmp = $1; $tmp =~ m/("(.*[^\\])?")/; $tmp = $1; $tmp =~ s/"(.*)"/$1/g; $tmp =~ s/\\"/"/g; $t{"html1"}   = $tmp;
		       $us =~ s/([ \t]*("([^"]|\\")*")[ \t]*,)//m; $tmp = $1; $tmp =~ m/("(.*[^\\])?")/; $tmp = $1; $tmp =~ s/"(.*)"/$1/g; $tmp =~ s/\\"/"/g; $t{"html2"}   = $tmp;
             	       $us =~ s/([ \t]*("([^"]|\\")*")[ \t]*$)//m; $tmp = $1; $tmp =~ m/("(.*[^\\])?")/; $tmp = $1; $tmp =~ s/"(.*)"/$1/g; $tmp =~ s/\\"/"/g; $t{"regex"}   = $tmp;
	       
	               my $old_die = $SIG{__DIE__};
	               $SIG{'__DIE__'} = 
			  sub{
			      $SIG{'__DIE__'} = $old_die;
			      my $error = $_[0];
			      $error =~ s/ at \(eval.*?\) line .*?\./\./;
			      die('The following error occured in this regular expression: '.$error.
                                'Check your language configuration file!'."\n");
                              };
	               eval ('my $dummy = "HAllo"; $dummy =~ /(.*?)$t{"regex"}/gms');
	               $SIG{'__DIE__'} = $old_die;

            	       if ($after =~ /(^\n\-.*?($|\n[^\-]))/s)
			 {
			     $tmp = $1;
			     $tmp =~ s/^\n//;
			     $tmp =~ s/\n.$//;
			     $tmp =~ s/^-[ \t]*//mg;

			     $child_ref = &parse_config_part($tmp."\n");
			 };

              	       $t{"childregex"} = $child_ref;
	               push @regexps, \%t;
           	   }
               else
	           {
		       if ($us =~ s/^bgcolor[ \t]*=[ \t]*//i)
			 {
			     $_[1] = $us;
			 }
		       elsif ($us =~ s/^textcolor[ \t]*=[ \t]*//i)
			 {
			     $_[2] = $us;
			 }
		   };
       };

    return \@regexps;
};









################################################################################
####################### get_default_database ###################################
################################################################################
sub get_default_database
{
# last evaluated value will be returned
my $tmp = <<'EODB';
######################################################################
################################# Plain ##############################
######################################################################
[plain]
bgcolor=#ffffff
textcolor=#000000

######################################################################
################################# Ada 95 #############################
######################################################################
[ada,ada95]
bgcolor=#ffffff
textcolor=#000000
filename=\.ada$
filename=\.ad$
filename=\.ads$
filename=\.adb$
filename=\.a$

#Comments
	"<font color=\"#444444\">", "</font>", "--.*?$"
#String Literals
	"<font color=\"#008000\">", "</font>", "\".*?(\"|$)"
#Character Literals
	"<font color=\"#008000\">", "</font>", "'.'"
#Ada Attibutes
	"<strong>", "</strong>", "'[a-zA-Z][a-zA-Z_]+\b"
#Numeric Literals
	"<font color=\"#FF0000\">", "</font>", "(((2|8|10|16)#[_0-9a-fA-F]*#)|[0-9.]+)"
#Withs Pragmas Use
	"<font color=\"#0000FF\"><strong>", "</strong></font>", "\b(([wW]ith|WITH|[pP]ragma|PRAGMA|[uU]se|USE)[ \t\n\f\r]+[a-zA-Z0-9_.]+;)+\b"
#Predefined Types
	"<font color=\"#800000\"><strong>", "</strong></font>", "\b([bB]oolean|BOOLEAN|[cC]haracter|CHARACTER|[cC]ount|COUNT|[dD]uration|DURATION|[fF]loat|FLOAT|[iI]nteger|INTEGER|[lL]ong_[fF]loat|LONG_FLOAT|[lL]ong_[iI]nteger|LONG_INTEGER|[pP]riority|PRIORITY|[sS]hort_[fF]loat|SHORT_FLOAT|[sS]hort_[iI]nteger|SHORT_INTEGER|[sS]tring|STRING)\b"
#Predefined Subtypes
	"<font color=\"#800000\"><strong>", "</strong></font>", "\b([fF]ield|FIELD|[nN]atural|NATURAL|[nN]umber_[bB]ase|NUMBER_BASE|[pP]ositive|POSITIVE|[pP]riority|PRIORITY)\b"
#Reserved Words
	"<strong>", "</strong>", "\b([aA]bort|ABORT|[aA]bs|ABS|[aA]ccept|ACCEPT|[aA]ccess|ACCESS|[aA]nd|AND|[aA]rray|ARRAY|[aA][tT]|[bB]egin|BEGIN|[bB]ody|BODY|[cC]ase|CASE|[cC]onstant|CONSTANT|[dD]eclare|DECLARE|[dD]elay|DELAY|[dD]elta|DELTA|[dD]igits|DIGITS|[dD][oO]|[eE]lse|ELSE|[eE]lsif|ELSIF|[eE]nd|END|[eE]ntry|ENTRY|[eE]xception|EXCEPTION|[eE]xit|EXIT|[fF]or|FOR|[fF]unction|FUNCTION|[gG]eneric|GENERIC|[gG]oto|GOTO|[iI][fF]|[iI][nN]|[iI][sS]|[lL]imited|LIMITED|[lL]oop|LOOP|[mM]od|MOD|[nN]ew|NEW|[nN]ot|NOT|[nN]ull|NULL|[oO][fF]|[oO][rR]|[oO]thers|OTHERS|[oO]ut|OUT|[pP]ackage|PACKAGE|[pP]ragma|PRAGMA|[pP]rivate|PRIVATE|[pP]rocedure|PROCEDURE|[rR]aise|RAISE|[rR]ange|RANGE|[rR]ecord|RECORD|[rR]em|REM|[rR]enames|RENAMES|[rR]eturn|RETURN|[rR]everse|REVERSE|[sS]elect|SELECT|[sS]eparate|SEPARATE|[sS]ubtype|SUBTYPE|[tT]ask|TASK|[tT]erminate|TERMINATE|[tT]hen|THEN|[tT]ype|TYPE|[uU]se|USE|[wW]hen|WHEN|[wW]hile|WHILE|[wW]ith|WITH|[xX]or|XOR)\b"
#Ada 95 Only
	"<strong>", "</strong>", "\b([aA]bstract|ABSTRACT|[tT]agged|TAGGED|[aA]ll|ALL|[pP]rotected|PROTECTED|[aA]liased|ALIASED|[rR]equeue|REQUEUE|[uU]ntil|UNTIL)\b"
#Identifiers
	"<font color=\"#800000\">", "</font>", "\b[a-zA-Z][a-zA-Z0-9_]*\b"
#Dot All
	"<font color=\"#800000\"><strong>", "</strong></font>", "\.[aA][lL][lL]\b"


######################################################################
################################# C ##################################
######################################################################
[c]
bgcolor=#ffffff
textcolor=#000000
filename=\.c$
filename=\.h$

#comment
	"<font color=\"#444444\">", "</font>", "/\*.*?\*/"
#string
	"<font color=\"#008000\">", "</font>", "((\"\")|(\"\\\\\")|(\"[^\"\\]\")|(\"[^\"].*?[^\\]\"))"
	#esc character
	-	"<font color=\"#77dd77\">", "</font>", "\\."
#preprocessor line
	"<font color=\"#0000FF\">", "</font>", "^[ \t]*#.*?$"
	#string
	-	"<font color=\"#008000\">", "</font>", "((\"\")|(\"\\\\\")|(\"[^\"\\]\")|(\"[^\"].*?[^\\]\"))"
		#esc character
		--	"<font color=\"#77dd77\">", "</font>", "\\."
        #<files>
        -      "<font color=\"#008000\">", "</font>", "<.*?>"
	#comment
	-	"<font color=\"#444444\">", "</font>", "[^/]/\*.*?\*/"
#character constant
	"<font color=\"#008000\">", "</font>", "'(\\)?.'"
	#esc character
	-	"<font color=\"#77dd77\">", "</font>", "\\."
#numeric constant
	"<font color=\"#FF0000\">", "</font>", "\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\b"
#storage keyword
	"<strong>", "</strong>", "\b(const|extern|auto|register|static|unsigned|signed|volatile|char|double|float|int|long|short|void|typedef|struct|union|enum)\b"
#keyword
	"<strong>", "</strong>", "\b(return|goto|if|else|case|default|switch|break|continue|while|do|for|sizeof)\b"
#braces
	"<font color=\"#4444FF\"><strong>", "</strong></font>", "[\{\}]"
#symbols
	"<font color=\"#4444FF\">", "</font>", "([\*\-\+=:;%&\|<>\(\)\[\]!])"
#identifiers
	"<font color=\"#993333\">", "</font>", "([a-zA-Z_][a-zA-Z_0-9]*)"



######################################################################
################################# C ++ ###############################
######################################################################
[c++,cpp,cc]
bgcolor=#ffffff
textcolor=#000000
filename=\.cc$
filename=\.hh$
filename=\.C$
filename=\.H$
filename=\.i$
filename=\.cxx$

#comment
	"<font color=\"#444444\">", "</font>", "/\*.*?\*/"
#cplus comment
	"<font color=\"#444444\">", "</font>", "//.*?$"
#string
	"<font color=\"#008000\">", "</font>", "((\"\")|(\"\\\\\")|(\"[^\"\\]\")|(\"[^\"].*?[^\\]\"))"
	#esc character
	-	"<font color=\"#77dd77\">", "</font>", "\\."
#preprocessor line
	"<font color=\"#0000FF\">", "</font>", "^[ \t]*#.*?$"
	#string
	-	"<font color=\"#008000\">", "</font>", "((\"\")|(\"[^\"\\]\")|(\"[^\"].*?[^\\]\"))"
		#esc character
		--	"<font color=\"#77dd77\">", "</font>", "\\."
        #<files>
        -      "<font color=\"#008000\">", "</font>", "<.*?>"
	#comment
	-	"<font color=\"#444444\">", "</font>", "[^/]/\*.*?\*/"
	#cplus comment
	-	"<font color=\"#444444\">", "</font>", "//.*?$"
#character constant
	"<font color=\"#008000\">", "</font>", "'(\\)?.'"
	#esc character
	-	"<font color=\"#77dd77\">", "</font>", "\\."
#numeric constant
	"<font color=\"#FF0000\">", "</font>", "\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\b"
#storage keyword
	"<strong>", "</strong>", "\b(class|typename|typeid|template|friend|virtual|inline|explicit|operator|overload|public|private|protected|const|extern|auto|register|static|mutable|unsigned|signed|volatile|char|double|float|int|long|short|bool|wchar_t|void|typedef|struct|union|enum)\b"
#keyword
	"<strong>", "</strong>", "\b(new|delete|this|return|goto|if|else|case|default|switch|break|continue|while|do|for|catch|throw|sizeof|true|false|namespace|using|dynamic_cast|static_cast|reinterpret_cast)\b"
#braces
	"<font color=\"#4444FF\"><strong>", "</strong></font>", "[\{\}]"
#symbols
	"<font color=\"#4444FF\">", "</font>", "([\*\-\+=:;%&\|<>\(\)\[\]!])"
#identifiers
	"<font color=\"#993333\">", "</font>", "([a-zA-Z_][a-zA-Z_0-9]*)"


######################################################################
################################# HTML ###############################
######################################################################
[html]
bgcolor=#ffffff
textcolor=#000000
filename=\.html?$


#comment
	"<font color=\"#444444\">", "</font>", "<!--.*?-->"
#special chars
	"<font color=\"#FF0000\">", "</font>", "\&[-.a-zA-Z0-9#]*;?"
#tag
	"<font color=\"#993333\">", "</font>", "<(/|!)?[-.a-zA-Z0-9]*.*?>"
	#double quote string
	-	"<font color=\"#008000\">", "</font>", "\".*?\""
	#single quote string
	-	"<font color=\"#008000\">", "</font>", "'.*?'"
	#brackets
	-	"<font color=\"#0000aa\"><strong>", "</strong></font>", "[<>]"
	#attribute
	-	"<font color=\"#0000ff\">", "</font>", "[^'\"]+?"


######################################################################
################################# Java ###############################
######################################################################
[java]
bgcolor=#ffffff
textcolor=#000000
filename=\.java$

#doc comment
	"<font color=\"#444444\"><i>", "</i></font>", "/\*\*.*?\*/"
#comment
	"<font color=\"#444444\">", "</font>", "/\*.*?\*/"
#cplus comment
	"<font color=\"#444444\">", "</font>", "//.*?$"
#string
	"<font color=\"#008000\">", "</font>", "((\"\")|(\"\\\\\")|(\"[^\"\\]\")|(\"[^\"].*?[^\\]\"))"
	#esc character
	-	"<font color=\"#77dd77\">", "</font>", "\\."
#single quoted
	"<font color=\"#008000\">", "</font>", "'([^\\]|\\[^'])*?'"
#numeric constant
	"<font color=\"#FF0000\">", "</font>", "\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\b"
#include
	"<font color=\"#0000FF\">", "</font>", "\b(import|package)\b.*?$"
	#esc character
	-	"<font color=\"#3333FF\">", "</font>", "\\(.|\n)"
	#comment
	-	"<font color=\"#444444\">", "</font>", "[^/]/\*.*?\*/"
#storage keyword
	"<strong>", "</strong>", "\b(abstract|boolean|byte|char|class|double|extends|final|float|int|interface|long|native|private|protected|public|short|static|transient|synchronized|void|volatile|implements)\b"
#keyword
	"<strong>", "</strong>", "\b(break|case|catch|continue|default|do|else|false|finally|for|if|instanceof|new|null|return|super|switch|this|throw|throws|true|try|while)\b"
#braces and parens
	"<strong>", "</strong>", "[\{\}\(\)\[\]]"
#Identifiers
	"<font color=\"#800000\">", "</font>", "\b[a-zA-Z_][a-zA-Z0-9_]*\b"
#symbols
	"<font color=\"#4444FF\">", "</font>", "([\*\-\+=:;%&\|<>!])"


######################################################################
################################# JavaScript #########################
######################################################################
[js,javascipt]
bgcolor=#ffffff
textcolor=#000000
filename=\.js$

#comment
	"<font color=\"#444444\">", "</font>", "/\*.*?\*/"
#cplus comment
	"<font color=\"#444444\">", "</font>", "//.*?$"
#numeric constant
	"<font color=\"#FF0000\">", "</font>", "\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\b"
#events
	"<strong>", "</strong>", "\b(onAbort|onBlur|onClick|onChange|onDblClick|onDragDrop|onError|onFocus|onKeyDown|onKeyPress|onLoad|onMouseDown|onMouseMove|onMouseOut|onMouseOver|onMouseUp|onMove|onResize|onSelect|onSubmit|onUnload)\b"
#braces
	"<font color=\"#4444FF\"><strong>", "</strong></font>", "[\{\}]"
#statements
	"<strong>", "</strong>", "\b(break|continue|else|for|if|in|new|return|this|typeof|var|while|with)\b"
#function
	"<strong>", "</strong>", "function[\t ]+([a-zA-Z0-9_]+)[\t \(]+.*?[\n{]"
	#function args
	-	"<font color=\"#2040a0\">", "</font>", "\(.*?\)"
	#function name
	-	"<font color=\"#a52a2a\">", "</font>", "[\t ][a-zA-Z0-9_]+"
#built in object type
	"<font color=\"#a52a2a\"><strong>", "</strong></font>", "\b(anchor|Applet|Area|Array|button|checkbox|Date|document|elements|FileUpload|form|frame|Function|hidden|history|Image|link|location|Math|navigator|Option|password|Plugin|radio|reset|select|string|submit|text|textarea|window)\b"
#string
	"<font color=\"#008000\">", "</font>", "\".*?(\"|$)"
	#Colors
	-	"<font color=\"#4682B4\">", "</font>", "(aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|#008000|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|#[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9])"
#string
	"<font color=\"#008000\">", "</font>", "'.*?('|$)"
	#Colors
	-	"<font color=\"#4682B4\">", "</font>", "(aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|#008000|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|#[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9])"
#event capturing
	"<strong>", "</strong>", "\b(captureEvents|releaseEvents|routeEvent|handleEvent)\b.*?(\)|$)"
#predefined methods
	"<strong>", "</strong>", "\b(abs|acos|alert|anchor|asin|atan|atan2|back|big|blink|blur|bold|ceil|charAt|clear|clearTimeout|click|close|confirm|cos|escape|eval|exp|fixed|floor|focus|fontcolor|fontsize|forward|getDate|getDay|getHours|getMinutes|getMonth|getSeconds|getTime|getTimezoneOffset|getYear|go|indexOf|isNaN|italics|javaEnabled|join|lastIndexOf|link|log|max|min|open|parse|parseFloat|parseInt|pow|prompt|random|reload|replace|reset|reverse|round|scroll|select|setDate|setHours|setMinutes|setMonth|setSeconds|setTimeout|setTime|setYear|sin|small|sort|split|sqrt|strike|sub|submit|substring|sup|taint|tan|toGMTString|toLocaleString|toLowerCase|toString|toUpperCase|unescape|untaint|UTC|write|writeln)\b"
#properties
	"<font color=\"#a52a2a\"><strong>", "</strong></font>", "\b(action|alinkColor|anchors|appCodeName|appName|appVersion|bgColor|border|checked|complete|cookie|defaultChecked|defaultSelected|defaultStatus|defaultValue|description|E|elements|enabledPlugin|encoding|fgColor|filename|forms|frames|hash|height|host|hostname|href|hspace|index|lastModified|length|linkColor|links|LN2|LN10|LOG2E|LOG10E|lowsrc|method|name|opener|options|parent|pathname|PI|port|protocol|prototype|referrer|search|selected|selectedIndex|self|SQRT1_2|SQRT2|src|status|target|text|title|top|type|URL|userAgent|value|vlinkColor|vspace|width|window)\b"
#operators
	"<font color=\"#4444FF\">", "</font>", "([=;->/&|])"

######################################################################
################################# Makefile ###########################
######################################################################
[make,makefile]
bgcolor=#ffffff
textcolor=#000000
filename=^Makefile\.?
filename=^makefile\.?

#comment
	"<font color=\"#444444\">", "</font>", "#.*?$"
#Assignment
	"<font color=\"#2040a0\">", "</font>", "^( *| [ \t]*)[A-Za-z0-9_+]*[ \t]*(\+|:)?="
#Dependency Line
	"<font color=\"#8b2252\">", "</font>", "^ *([A-Za-z0-9./$(){} _%+-]|\n)*::?"
	#Dependency Target
	-	"<strong>", "</strong>", "[A-Za-z0-9./$(){} _%+-]+"
	#Dependency continuation
	-	"<font color="#000000"><strong>", "</strong></font>", "\\\n"
	#comment
	-	"<font color=\"#444444\">", "</font>", "#.*?$"
	#macro
	-	"<font color=\"#2040a0\">", "</font>", "\$([A-Za-z0-9_]|\([^)]*\)|{[^}]*})"
	#int macro
	-	"<font color=\"#4080ff\">", "</font>", "\$([<@*?%]|\$@)"
#Continuation
	"<strong>", "</strong>", "\\$"
#Macro
	"<font color=\"#2040a0\">", "</font>", "\$([A-Za-z0-9_]|\([^)]*\)|{[^}]*})"
#Internal Macro
	"<font color=\"#4080FF\">", "</font>", "\$([<@*?%]|\$@)"
#Escaped Dollar
	"<font color=\"#444444\">", "</font>", "\$\$"
#Include
	"<strong>", "</strong>", "^include[ \t]"


######################################################################
################################# Pascal #############################
######################################################################
[pas,pascal]
bgcolor=#ffffff
textcolor=#000000
filename=\.p$
filename=\.pas$

#comment1 (*    *)
	"<font color=\"#444444\">", "</font>", "\(\*.*?\*\)"
#comment1 {      }
	"<font color=\"#444444\">", "</font>", "\{.*?\}"
#string
	"<font color=\"#008000\">", "</font>", "'.*?('|$)"
#preprocessor line
	"<font color=\"#0000FF\">", "</font>", "^[ \t]*#.*?$"
	#comment1 (*    *)
	-	"<font color=\"#444444\">", "</font>", "\(\*.*?\*\)"
	#comment1 {      }
	-	"<font color=\"#444444\">", "</font>", "\{.*?\}"
#character constant
	"<font color=\"#008000\">", "</font>", "'.'"
#numeric constant
	"<font color=\"#FF0000\">", "</font>", "\b((0(x|X)[0-9a-fA-F]*)|[0-9.]+((e|E)(\+|-)?)?[0-9]*)(L|l|UL|ul|u|U|F|f)?\b"
#storage and ops
	"<strong>", "</strong>", "\b(and|AND|array|const|div|export|file|function|import|in|IN|label|mod|module|nil|not|NOT|only|or|OR|packed|pow|pragma|procedure|program|protected|qualified|record|restricted|set|type|var)\b"
#keywords
	"<strong>", "</strong>", "\b(begin|case|do|downto|else|end|for|goto|if|of|otherwise|repeat|then|to|until|while|with)\b"
#symbols
	"<font color=\"#4444FF\">", "</font>", "([\*\-\+=:;<>\(\)\[\]!]|[^/]/[^/])"
#identifiers
	"<font color=\"#993333\">", "</font>", "([a-zA-Z_][a-zA-Z_0-9.^]*[a-zA-Z_0-9]|[a-zA-Z_][a-zA-Z_0-9]*)"
	#dot, carret(sp?)
	-	"<font color=\"#4444FF\">", "</font>", "(\.|\^)+"




######################################################################
################################# Perl ###############################
######################################################################
[perl]
bgcolor=#ffffff
textcolor=#000000
filename=\.pl$
filename=\.pm$
filename=\.p5$
filename=\.pod$
regex=^\s*#\s*![^\s]*perl

#comment
	"<font color=\"#444444\">", "</font>", "#.*?$"
#variables
	"<font color=\"2040a0\">", "</font>", "[\$@%]\$?(?:{[^}]*}|[^a-zA-Z0-9_/\t\n\.,\\[\\{\\(]|[0-9]+|[a-zA-Z_][a-zA-Z0-9_]*)?"
#string; so this part realy is weird, but it works!
	"<font color=\"#008000\">", "</font>", "\"\"|\"\\\\\"|\"[^\"\\]\"|\"[^\"].*?[^\\]\""
	#esc character
	-	"<font color=\"#77dd77\">", "</font>", "\\."
	#variables
	-	"<font color=\"2040a0\">", "</font>", "[\$@%]\$?(?:{[^}]*}|[^a-zA-Z0-9_/\t\n\.,\\[\\{\\(]|[0-9]+|[a-zA-Z_][a-zA-Z0-9_]*)?"
#string; so this part realy is weird, but it works!
	"<font color=\"#008000\">", "</font>", "''|'\\\\'|'[^'\\]'|'[^'].*?[^\\]'"
	#esc character
	-	"<font color=\"#77dd77\">", "</font>", "\\."

#more strings - q// qw//
	"<font color=\"#008000\">", "</font>", "(?:\b| )(?:q|qw)(\W)(?:\\\2|[^\2\n])*\2"
	#esc character
	-	"<font color=\"#77dd77\">", "</font>", "\\."

#more strings qq// qx//
	"<font color=\"#008000\">", "</font>", "(?:\b| )(?:qq|qx)(\W)(?:\\\2|[^\2\n])*\2"
	#esc character
	-	"<font color=\"#77dd77\">", "</font>", "\\."
	#variables
	-	"<font color=\"2040a0\">", "</font>", "[\$@%]\$?(?:{[^}]*}|[^a-zA-Z0-9_/\t\n\.,\\[\\{\\(]|[0-9]+|[a-zA-Z_][a-zA-Z0-9_]*)?"

#subroutine header
	"<strong>", "</strong>", "sub[\t ]+(?:[a-zA-Z0-9_]+)[\t \n]*(?:\{|\n)"
	#subr header coloring
	-	"<font color=\"#ff0000\">", "</font>", "[\t ][a-zA-Z0-9_]+"
#ignore escaped chars
#	"", "", "\\[#"'\$msytq]"
#regex matching
	"<font color=\"#b000d0\">", "</font>", "(?:\b| )?(?:/(?:\\/|[^/\n])*(?:/[gimsox]*)|s(\W)(?:\\\2|[^\2\n])*?(\2)[^(\2)\n]*?(\2[gimsox]*))"
	"<font color=\"#b000d0\">", "</font>", "(?:\b| )(?:m|qq?|tr|y)(\W)(?:\\\2|[^\2\n])*(?:\2[gimsox]*)"
#	"<font color=\"#b000d0\">", "</font>", "(\b| )((m|qq?)?/)(\\/|[^/\n])*(/[gimsox]*)"
##	"<font color=\"#b000d0\">", "</font>", "(?:\b| )?/(?:\\/|[^/\n])*(?:/[gimsox]*)"
#	"<font color=\"#b000d0\">", "</font>", "(?:\b| )(?:(?:m|qq?)(\W))(\\\2|[^\2\n])*(\2[gimsox]*)"
##	"<font color=\"#b000d0\">", "</font>", "(?:\b| )(?:(?:m|qq?)([!\"#\$%&'*+-/]))(?:\\\2|[^\2\n])*(?:\2[gimsox]*)"
#regex substitution
#	"<font color=\"#b000d0\">", "</font>", "(\b| )((s|y|tr)/)(\\/|[^/\n])*(/)[^/\n]*(/[gimsox]*)"
#	"<font color=\"#b000d0\">", "</font>", "(?:\b| )?(?:s(\W))(?:\\\2|[^\2\n])*?(\2)[^(\2)\n]*?(\2[gimsox]*)"
##	"<font color=\"#b000d0\">", "</font>", "(?:\b| )?(?:s([!\"#\$%&'*+-/]))(?:\\\2|[^\2\n])*?(\2)[^(\2)\n]*?(\2[gimsox]*)"
#translate
##	"<font color=\"#b000d0\">", "</font>", "(?:\b| )(?:(?:tr|y)(\W))(?:\\\2|[^\2\n])*?(\2)[^(\2)\n]*?(\2[gimsox]*)"

#keywords
	"<strong>", "</strong>", "\b(my|local|new|if|until|while|elsif|else|eval|unless|for|foreach|continue|exit|die|last|goto|next|redo|return|local|exec|do|use|require|package|eval|BEGIN|END|eq|ne|not|\|\||\&\&|and|or)\b"
#library fns
	"<font color=\"a52a2a\"><strong>", "</strong></font>", "\b(?:a(?:bs|ccept|larm|tan2)|b(?:ind|inmode|less)|c(?:aller|hdir|hmod|homp|hop|hr|hroot|hown|losedir|lose|onnect|os|rypt)|d(?:bmclose|bmopen|efined|elete|ie|ump)|e(?:ach|nd(?:grent|hostent|netent|protoent|pwent|servent)|of|xec|xists|xp)|f(?:ctnl|ileno|lock|ork|ormat|ormline)|g(?:et(?:c|grent|grgid|grnam|hostbyaddr|hostbyname|hostent|login|netbyaddr|netbyname|netent|peername|pgrp|ppid|priority|protobyname|protobynumber|protoent|pwent|pwnam|pwuid|servbyname|servbyport|servent|sockname|sockopt)|lob|mtime|rep)|hex|i(?:mport|ndex|nt|octl)|join|keys|kill|l(?:cfirst|c|ength|ink|isten|og|ocaltime|stat)|m(?:ap|kdir|sgctl|sgget|sgrcv)|no|o(?:ct|pendir|pen|rd)|p(?:ack|ipe|op|os|rintf|rint|ush)|quotemeta|r(?:and|eaddir|ead|eadlink|ecv|ef|ename|eset|everse|ewinddir|index|mdir)|s(?:calar|eekdir|eek|elect|emctl|emget|emop|end|et(?:grent|hostent|netent|pgrp|priority|protoent|pwent|sockopt)|hift|hmctl|hmget|hmread|hmwrite|hutdown|in|leep|ocket|ocketpair|ort|plice|plit|printf|qrt|rand|tat|tudy|ubstr|ymlink|yscall|ysopen|ysread|ystem|yswrite)|t(?:elldir|ell|ie|ied|ime|imes|runcate)|u(?:c|cfirst|mask|ndef|nlink|npack|nshift|ntie|time)|values|vec|w(?:ait|aitpid|antarray|arn|rite)|qw|-[rwxoRWXOezsfdlpSbctugkTBMAC])\b"
#braces and parens
	"<strong>", "</strong>", "[\[\]\{\}\(\)]"
#<< stuff
	"<i>", "</i>", "<<(?:(\"|')([^\n]*)\2|\w*).*?^\3$"
#	"<i>", "</i>", "<<\"([^\n]*)\";.*?^\2$"
#	"<i>", "</i>", "<<(\w*).*?^\2$"
#POD
	"<i>", "</i>", "^=.*?^(?:=cut|\Z)"
#	"<i>", "</i>", "(^=begin).*?^=end"



######################################################################
################################# sql ################################
######################################################################
[sql]
bgcolor=#ffffff
textcolor=#000000
filename=\.sql$

#keywords
        "<font color=\"#0000FF\"><strong>", "</strong></font>", ",|%|<|>|:=|=|\(|\)|\b(SELECT|ON|FROM|ORDER BY|DESC|WHERE|AND|OR|NOT|NULL|TRUE|FALSE|select|on|from|order by|desc|where|and|or|not|null|true|false|Select|On|From|Order By|Desc|Where|And|Or|Not|Null|True|False)\b"
#comment
        "<font color=\"#444444\"><i>", "</i></font>", "--.*?$"
#comment
	"<font color=\"#444444\"><i>", "</i></font>", "/\*.*?\*/"
#string; so this part realy is weird, but it works!
	"<font color=\"#008000\">", "</font>", "(('')|('[^'\\]')|('[^'].*?[^\\]'))"
#keywords
        "<font color=\"#0000FF\"><strong>", "</strong></font>", "END IF;|End If;|end if;|\b(CREATE|REPLACE|BEGIN|END|FUNCTION|RETURN|FETCH|OPEN|CLOSE|INTO|IS|IN|WHEN|OTHERS|GRANT|ON|TO|EXCEPTION|SHOW|SET|OUT|PRAGMA|AS|PACKAGE|create|replace|begin|end|function|return|fetch|open|close|into|is|in|when|others|grant|on|to|exception|show|set|out|pragma|as|package|Create|Replace|Begin|End|Function|Return|Fetch|Open|Close|Into|Is|In|When|Others|Grant|On|To|Exception|Show|Set|Out|Pragma|As|Package)\b"
#keywords
        "<font color=\"#0000FF\"><strong>", "</strong></font>", "\b(ALTER|Alter|alter)\b"

#datatypes
        "<font color=\"#8800FF\">", "</font>", "\b(INTEGER|Integer|integer|BLOB|Blob|blobl|DATE|Date|date|NUMERIC|Numeric|numeric|CHARACTER|Character|character|VARYING|Varying|varying|VARCHAR|Varchar|varchar|CHAR|Char|char)\b"

#st
        "<font color=\"#0000FF\"><strong>", "</strong></font>", "\b(CONSTRAINT|Constraint|constraint|KEY|Key|key|CONSTRAINT|Constraint|constraint|REFERENCES|References|references|PRIMARY|Primary|primary|TABLE|Table|table|FOREIGN|Foreign|foreign|ADD|Add|add|INSERT|Insert|insert|GROUP BY|Group By|group by)\b"

######################################################################



## contributed by JA
###########################################################################
## AWK
########################################################################### 
[awk]
bgcolor=#ffffff
textcolor=#000000
filename=\.awk$

## COMMENT
	"<font color=\"#444444\">", "</font>", "#.*?$"

## VARIABLES
# 


## STRING (""); so this part really is weird, but it works!
	"<font color=\"#008000\">", "</font>", "((\"\")|(\"\\\\\")|(\"[^\"\\]\")|(\"[^\"].*?[^\\]\"))"
	## ESC CHARACTER
	-	"<font color=\"#77dd77\">", "</font>", "\\."
	## VARIABLES
#	-	"<font color=\"2040a0\">", "</font>", "[$@%]\$?({[^}]*}|[^a-zA-Z0-9_/\t\n\.,\\[\\{\\(]|[0-9]+|[a-zA-Z_][a-zA-Z0-9_]*)?"

## STRING (''); so this part realy is weird, but it works!
	"<font color=\"#008000\">", "</font>", "(('')|('\\\\')|('[^'\\]')|('[^'].*?[^\\]'))"
	## ESC CHARACTER
	-	"<font color=\"#77dd77\">", "</font>", "\\."

## FUNCTION HEADER
	"<strong>", "</strong>", "function[\t ]+([a-zA-Z0-9_]+)[\t \n]*(\{|\n)"
	## FUNCTION COLORING
	-	"<font color=\"#ff0000\">", "</font>", "[\t ]([a-zA-Z0-9_]+)"

## REGEX MATCHING
	"<font color=\"#b000d0\">", "</font>", "(\b| )?(/)(\\/|[^/\n])*(/[gimsox]*)"
#	"<font color=\"#b000d0\">", "</font>", "(?:\b| )(?:(?:m|q|qq)(\W))(\\\2|[^\2\n])*(\2[gimsox]*)"
	"<font color=\"#b000d0\">", "</font>", "(?:\b| )(?:(?:m|q|qq)([!\"#$%&'*+-/]))(\\\2|[^\2\n])*(\2[gimsox]*)"

## REGEX SUBSTITUTION
#	"<font color=\"#b000d0\">", "</font>", "(?:\b| )?(?:s(\W))(?:\\\2|[^\2\n])*?(\2)[^(\2)\n]*?(\2[gimsox]*)"
	"<font color=\"#b000d0\">", "</font>", "(?:\b| )?(?:s([!\"#$%&'*+-/]))(?:\\\2|[^\2\n])*?(\2)[^(\2)\n]*?(\2[gimsox]*)"

## TRANSLATE
	"<font color=\"#b000d0\">", "</font>", "(?:\b| )(?:(?:tr|y)(\W))(?:\\\2|[^\2\n])*?(\2)[^(\2)\n]*?(\2[gimsox]*)"

## KEYWORDS
	"<strong>", "</strong>", "\b(BEGIN|END|ARGC|ARGIND|ARGV|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS|FILENAME|FNR|FS|IGNORECASE|NF|NR|OFMT|OFS|ORS|RS|RT|RSTART|RLENGTH|SUBSEP)\b"
	"<strong>", "</strong>", "\b(if|while|do|for|in|break|continue|delete|exit|next|nextfile|function)\b"

## LIBRARY FNS
	"<font color=\"#a52a2a\"><strong>", "</strong></font>", "\b(close|getline|print|printf|system|fflush|atan2|cos|exp|int|log|rand|sin|sqrt|srand|gensub|gsub|index|length|split|sprintf|sub|substr|tolower|toupper|systime|strftime)\b"

## BRACES AND PARENS
	"<strong>", "</strong>", "[\[\]\{\}\(\)]"

## << STUFF
	"<i>", "</i>", "<<'([^\n]*)';.*?^\2$"
	"<i>", "</i>", "<<([^\n]*).*?^\2$"

## contributed by JA
###########################################################################
## M4
###########################################################################
[m4]
bgcolor=#ffffff
textcolor=#000000
filename=\.m4$

## COMMENT
	"<font color=\"#444444\">", "</font>", "dnl.*?$"
	"<font color=\"#444444\"><i>", "</i></font>", "#.*?$"


## KEYWORDS;
	"<strong>","</strong>","\b(define|undefine|defn|pushdef|popdef|indir|builtin|changequote|changecom|changeword|m4wrap|m4exit|include|sinclude|divert|undivert|divnum|cleardiv|shift|dumpdef|traceon|traceoff|debugfile|debugmode|len|index|regexp|substr|translit|patsubst|format|incr|decr|syscmd|esyscmd|sysval|maketemp|errprint)\b"
	"<strong>","</strong>","\b(ifdef|ifelse|loops)\b"
## STRING (`');
## CURRENTLY NOT WORKING!

#	"<font color=\"#008000\">","</font>","(`[A-Za-z0-9_]*')"
#	"<font color=\"#ff0000\">","</font>","(`\\\\')|(`[^'\\]')"
#	"<font color=\"#008000\">","</font>","(`[^`].*?[^\\]''*)"
#	"<font color=\"#008000\">","</font>","(`.*?(?>`.*')')"

	## MACRO ARGUMENT SUBSTITUTION
	-	"<font color=\"2040a0\">", "</font>", "[$]\$?({[^}]*}|[^a-zA-Z0-9_/\t\n\.,\\[\\{\\(]|[0-9]+|[a-zA-Z_][a-zA-Z0-9_]*)?"

## contributed by JA
###########################################################################
## Groff
###########################################################################
[groff]
bgcolor=#ffffff
textcolor=#000000
filename=\.groff$

## COMMENT ('\"')
	"<font color=\"#444444\">","</font>","\\\".*?$"

## KEYWORDS
#	"<strong>","</strong>","^[\.\\][]A-Za-z0-9_{}()$[]+"






EODB
;

};
