package xm::code::sql;

use xm::o;
use xm::code::vars;
use xm::code::func;

sub DESC{"
  highlight sourcecode - SQL mode
"}

# BEGIN {
 
# taken from nedit
# modified by PP
# very inclomplete!
$LANGUAGE{'sql'}        = {
                            'filename'   => '(?i)\\.sql$',
                            'regex'      => '',
                            'patterns'   => [
                                              {
                                                'name'       => 'keywords I',
                                                'regex'      => '(?i)(,|%|<|>|:=|=|\\(|\\)|\\bselect|on|from|order by|desc|where|and|or|not|null|true|false)\\b',
                                                'style'      => 'reserved word',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'comment I',
                                                'regex'      => '--.*?$',
                                                'style'      => 'comment',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'comment II',
                                                'regex'      => '/\\*.*?\\*/',
                                                'style'      => 'comment',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'string',
                                                'regex'      => '\'\'|\'.*?([^\\\\](\\\\\\\\)*)\'|\'\\\\\\\\\'',
#                                                'regex'      => '(\'\'|\'[^\'\\\\]\'|\'[^\'].*?[^\\\\]\')',
                                                'style'      => 'string',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'keywords II',
                                                'regex'      => '(?i)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)\\b',
                                                'style'      => 'reserved word',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'keywords III',
                                                'regex'      => '(?i)\\balter\\b',
                                                'style'      => 'reserved word',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'datatypes',
                                                'regex'      => '(?i)\\b(integer|blol|date|numeric|character|varying|varchar|char)\\b',
                                                'style'      => 'predefined type',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'words',
                                                'regex'      => '(?i)\\b(constraint|key|references|primary|table|foreign|add|insert|group by)\\b',
                                                'style'      => 'reserved word',
                                                'childregex' => []
                                              }
                                            ]
                            };
   

# }1;


sub DO
{
    return xm::code::func::DO($_[0],$LANGUAGE{c}{patterns});
}

sub ARGS { return    xm::o::args_stdin(@_, DESC); }
sub main { return DO(xm::o::args_stdin(@_, DESC)); }

1;