package xm::code::pascal;

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

sub DESC{"
  highlight sourcecode - PASCAL mode
"}

# BEGIN {

# taken from nedit
# modified by PP
$LANGUAGE{'pas'}        = {
                            'filename'   => '(?i)\\.p(as)?$',
                            'regex'      => '',
                            'patterns'   => [
                                              {
                                                'name'       => 'comment1 (*    *)',
                                                'regex'      => '\\(\\*.*?\\*\\)',
                                                'style'      => 'comment',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'comment2 {    }',
                                                'regex'      => '\\{.*?\\}',
                                                'style'      => 'comment',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'string',
                                                'regex'      => '\'.*?(\'|$)',
                                                'style'      => 'string',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'preprocessor line',
                                                'regex'      => '^[ \\t]*#.*?$',
                                                'style'      => 'preprocessor',
                                                'childregex' => [
                                                                  {
                                                                    'name'       => 'comment1 (*    *)',
                                                                    'regex'      => '\\(\\*.*?\\*\\)',
                                                                    'style'      => 'comment',
                                                                    'childregex' => []
                                                                  },
                                                                  {
                                                                    'name'       => 'comment2 {    }',
                                                                    'regex'      => '\\{.*?\\}',
                                                                    'style'      => 'comment',
                                                                    'childregex' => []
                                                                  }
                                                                ]
                                              },
                                              {
                                                'name'       => 'character constant',
                                                'regex'      => '\'.\'',
                                                'style'      => 'character',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'numeric constant',
                                                'regex'      => '\\b((0(x|X)[0-9a-fA-F]*)|[0-9.]+((e|E)(\\+|-)?)?[0-9]*)(L|l|UL|ul|u|U|F|f)?\\b',
                                                'style'      => 'numeric',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'storage and ops',
                                                'regex'      => '\\b(?i)(and|array|const|div|export|file|function|import|in|label|mod|module|nil|not|only|or|packed|pow|pragma|procedure|program|protected|qualified|record|restricted|set|type|var)\\b',
                                                'style'      => 'reserved word',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'keywords',
                                                'regex'      => '\\b(?i)(begin|case|do|downto|else|end|for|goto|if|of|otherwise|repeat|then|to|until|while|with)\\b',
                                                'style'      => 'reserved word',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'sumbols',
                                                'regex'      => '([\\*\\-\\+=:;<>\\(\\)\\[\\]!]|[^/]/[^/])',
                                                'style'      => 'symbol',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'identifiers',
                                                'regex'      => '([a-zA-Z_][a-zA-Z_0-9.^]*[a-zA-Z_0-9]|[a-zA-Z_][a-zA-Z_0-9]*)',
                                                'style'      => 'identifier',
                                                'childregex' => [
                                                                  {
                                                                    'regex'      => '(\\.|\\^)+',
                                                                    'style'      => 'symbol',
                                                                    'childregex' => []
                                                                  }
                                                                ]
                                              }
                                            ],
                          };
$LANGUAGE{'pascal'}     = $LANGUAGE{'pas'};

# }1;

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

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

1;