package xm::code::java;

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

sub DESC{"
  highlight sourcecode - JAVA mode
"}

# BEGIN {
 
# taken from nedit
# modified by PP
$LANGUAGE{'java'}       = {
                            'filename'   => '\\.java$',
                            'regex'      => '',
                            'patterns'   => [
                                              {
                                                'name'       => 'doc comment',
                                                'regex'      => '/\\*\\*.*?\\*/',
                                                'style'      => 'doc comment',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'comment',
                                                'regex'      => '/\\*.*?\\*/',
                                                'style'      => 'comment',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'cplus comment',
                                                'regex'      => '//.*?$',
                                                'style'      => 'comment',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'string',
                                                'regex'      => '""|".*?([^\\\\](\\\\\\\\)*)"|"\\\\\\\\"',
#                                                'regex'      => '""|"\\\\\\\\"|"[^"\\\\]"|"[^"].*?[^\\\\]"',
                                                'style'      => 'string',
                                                'childregex' => [
                                                                  {
                                                                    'name'       => 'esc character',
                                                                    'regex'      => '\\\\.',
                                                                    'style'      => 'esc character',
                                                                    'childregex' => []
                                                                  }
                                                                ]
                                              },
                                              {
                                                'name'       => 'single quoted',
                                                'regex'      => '\'\'|\'.*?([^\\\\](\\\\\\\\)*)\'|\'\\\\\\\\\'',
#                                                'regex'      => '\'\'|\'\\\\\\\\\'|\'[^\'\\\\]\'|\'[^\'].*?[^\\\\]\'',
                                                'style'      => 'string',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'numeric constant',
                                                'regex'      => '\\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',
                                                'style'      => 'numeric',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'include',
                                                'regex'      => '\\b(import|package)\\b.*?$',
                                                'style'      => 'include',
                                                'childregex' => [
                                                                  {
                                                                    'name'       => 'esc character',
                                                                    'regex'      => '\\\\(.|\\n)',
                                                                    'style'      => 'esc character',
                                                                    'childregex' => []
                                                                  },
                                                                  {
                                                                    'name'       => 'comment',
                                                                    'regex'      => '[^/]/\\*.*?\\*/',
                                                                    'style'      => 'comment',
                                                                    'childregex' => []
                                                                  }
                                                                ]
                                              },
                                              {
                                                'name'       => 'storage keyword',
                                                'regex'      => '\\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',
                                                'style'      => 'reserved word',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'keyword',
                                                'regex'      => '\\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',
                                                'style'      => 'reserved word',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'braces and parens',
                                                'regex'      => '[\\{\\}\\(\\)\\[\\]]',
                                                'style'      => 'braces',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'Identifiers',
                                                'regex'      => '\\b[a-zA-Z_][a-zA-Z0-9_]*\\b',
                                                'style'      => 'identifier',
                                                'childregex' => []
                                              },
                                              {
                                                'name'       => 'symbols',
                                                'regex'      => '([\\*\\-\\+=:;%&\\|<>!])',
                                                'style'      => 'symbol',
                                                'childregex' => []
                                              }
                                            ]
                          };
 
 
# }1;

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

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

1;