current commit
260917.1.1 · Add m4 language definition
Description="M4 Macro Language"

Categories = {"source", "script"}

Identifiers=[[ [a-zA-Z_][\w\-]* ]]

Digits=[[ (?:0x|0X)[0-9a-fA-F]+|\d+[\.]?\d* ]]

Keywords={
  -- m4 builtins
  { Id=1,
    List={"builtin", "changecom", "changequote", "changeword", "debugfile", "debugmode", "decr",
        "define", "defn", "divert", "divnum", "dumpdef", "errprint", "esyscmd", "eval", "format",
        "ifdef", "ifelse", "include", "incr", "index", "indir", "len", "m4exit", "m4wrap", "mkstemp",
        "patsubst", "popdef", "pushdef", "regexp", "sinclude", "shift", "substr", "syscmd", "sysval",
        "traceoff", "traceon", "translit", "undefine", "undivert"},
  },
  -- autoconf m4sugar aliases
  { Id=1,
    List={"m4_argn", "m4_append", "m4_append_uniq", "m4_bmatch", "m4_bpatsubst", "m4_bpatsubsts",
        "m4_case", "m4_cond", "m4_copy", "m4_curry", "m4_default", "m4_default_nblank",
        "m4_default_nblank_quoted", "m4_default_quoted", "m4_define", "m4_defn", "m4_divert",
        "m4_divert_once", "m4_divert_pop", "m4_divert_push", "m4_divert_text", "m4_do", "m4_dquote",
        "m4_dquote_elt", "m4_dumpdefs", "m4_dumpvars", "m4_echo", "m4_esyscmd", "m4_esyscmd_s",
        "m4_expand", "m4_fatal", "m4_foreach", "m4_foreach_w", "m4_format", "m4_for", "m4_if",
        "m4_ifblank", "m4_ifdef", "m4_ifnblank", "m4_ifndef", "m4_ifset", "m4_ifval", "m4_ifvaln",
        "m4_include", "m4_index", "m4_input", "m4_join", "m4_joinall", "m4_len", "m4_list_cmp",
        "m4_make", "m4_maketemp", "m4_map", "m4_map_args", "m4_map_args_list", "m4_map_args_pair",
        "m4_map_args_sep", "m4_map_sep", "m4_mapall", "m4_max", "m4_min", "m4_newline",
        "m4_pattern_allow", "m4_pattern_forbid", "m4_popdef", "m4_pushdef", "m4_quote",
        "m4_re_escape", "m4_regexp", "m4_rename", "m4_require", "m4_set_add", "m4_set_add_all",
        "m4_set_contains", "m4_set_contents", "m4_set_delete", "m4_set_difference", "m4_set_dump",
        "m4_set_empty", "m4_set_foreach", "m4_set_intersection", "m4_set_list", "m4_set_listc",
        "m4_set_remove", "m4_set_size", "m4_set_union", "m4_shift", "m4_shift2", "m4_shift3",
        "m4_shiftn", "m4_sinclude", "m4_split", "m4_stack_foreach", "m4_stack_foreach_quit",
        "m4_substr", "m4_symbols", "m4_syscmd", "m4_sysval", "m4_text_box", "m4_text_wrap",
        "m4_tolower", "m4_toupper", "m4_translit", "m4_undefine", "m4_undivert", "m4_unquote",
        "m4_version_compare", "m4_warn"},
  },
  -- shell variables and m4 positional parameters
  { Id=2,
    Regex=[[ \$(?:\{[\w]+\}|[@\w]+|\d+|@|#|\*) ]],
  },
  -- shell control keywords inside embedded script
  { Id=3,
    List={"if", "then", "else", "elif", "fi", "case", "esac", "for", "while", "until", "do", "done",
        "in", "function", "select", "time"},
  },
  -- autoconf macros (AC_*)
  { Id=4,
    Regex=[[\bAC_[A-Z][A-Z0-9_]*\b]],
    Group=0,
  },
  -- automake (AM_), m4sh (AS_) and other Autotools macros
  { Id=5,
    Regex=[[\b(AM|AS|AH|AT|AU|AX|LT|PKG|GL|ND|DUTI)_[A-Z][A-Z0-9_]*\b]],
    Group=0,
  },
  -- shell builtin commands inside embedded script
  { Id=6,
    List={"test", "echo", "shift", "set", "unset", "export", "readonly", "return", "exit", "break",
        "continue", "cd", "printf", "read", "pwd", "trap", "true", "false", "eval", "exec",
        "command", "local"},
  },
}

Strings={
  -- shell double-quoted strings inside embedded script
  Delimiter=[=["]=],
  -- m4 quoting: `...'
  DelimiterPairs={
    { Open=[[`]], Close=[[']] },
  },
}

IgnoreCase=false

Comments={
  { Block=false,
    Delimiter= { [[\bdnl\b]] },
  },
  { Block=false,
    Delimiter= { [[\B#]] },
  },
}

Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\:|\&|<|>|\!|\=|\/|\*|\%|\+|\-|\$]]