package xm::code::m4;

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

sub DESC{"
  highlight sourcecode - M4 mode
"}

# BEGIN {

# written by JA
$LANGUAGE{'m4'}         = {
                            'filename'   => '\\.m4$',
                            'regex'      => '',
                            'patterns' => [
                                            {
                                              'regex'      => 'dnl.*?$',
                                              'style'      => 'doc comment',
                                              'childregex' => []
                                            },
                                            {
                                              'regex'      => '#.*?$',
                                              'style'      => 'comment',
                                              'childregex' => []
                                            },
                                            {
                                              'regex'      => '\\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',
                                              'style'      => 'reserved word',
                                              'childregex' => []
                                            },
                                            {
                                              'regex'      => '\\b(ifdef|ifelse|loops)\\b',
                                              'style'      => 'reserved word',
                                              'childregex' => [
                                                                {
                                                                  'regex'      => '[$]\\$?({[^}]*}|[^a-zA-Z0-9_/\\t\\n\\.,\\\\[\\\\{\\\\(]|[0-9]+|[a-zA-Z_][a-zA-Z0-9_]*)?',
                                                                  'style'      => 'identifier',
                                                                  'childregex' => []
                                                                }
                                                              ]
                                            }
                                          ]
                          };



# }1;


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

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

1;