2016-03-21 19:16:02 +03:00
## D syntax highlighting for GNU nano
##
## Author: Andrei Vinokurov
## Based on D lexer specification (http://dlang.org/lex)
2016-08-25 03:15:36 +03:00
syntax "d" "\.(d(i|d)?)$"
2016-03-21 19:16:02 +03:00
## Operators and punctuation
2016-03-21 23:02:58 +03:00
color statement "(\*|/|%|\+|-|>>|<<|>>>|&|\^(\^)?|\||~)?="
color statement "\.\.(\.)?|!|\*|&|~|\(|\)|\[|\]|\\|/|\+|-|%|<|>|\?|:|;"
2016-03-21 19:16:02 +03:00
## Octal integer literals are deprecated
2016-03-21 23:02:58 +03:00
color error "(0[0-7_]*)(L[uU]?|[uU]L?)?"
2016-03-21 19:16:02 +03:00
## Decimal integer literals
2016-03-21 23:02:58 +03:00
color constant "([0-9]|[1-9][0-9_]*)(L[uU]?|[uU]L?)?"
2016-03-21 19:16:02 +03:00
## Binary integer literals
2016-03-21 23:02:58 +03:00
color constant "(0[bB][01_]*)(L[uU]?|[uU]L?)?"
2016-03-21 19:16:02 +03:00
## Decimal float literals
2016-03-21 23:02:58 +03:00
color constant "[0-9][0-9_]*\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
color constant "[0-9][0-9_]*([eE][+-]?([0-9][0-9_]*))[fFL]?i?"
color constant "[^.]\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
color constant "[0-9][0-9_]*([fFL]?i|[fF])"
2016-03-21 19:16:02 +03:00
## Hexadecimal integer literals
2016-03-21 23:02:58 +03:00
color constant "(0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F]))(L[uU]?|[uU]L?)?"
2016-03-21 19:16:02 +03:00
## Hexadecimal float literals
2016-03-21 23:02:58 +03:00
color constant "0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])(\.[0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])?[pP][+-]?([0-9][0-9_]*)[fFL]?i?"
color constant "0[xX]\.([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F])[pP][+-]?([0-9][0-9_]*)[fFL]?i?"
2016-03-21 19:16:02 +03:00
## Character literals
2016-03-21 23:02:58 +03:00
color constant "'([^\']|\\(['"?\abfnrtv]|x[[:xdigit:]]{2}|[0-7]{1,3}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8}|&.*;))'"
2016-03-21 19:16:02 +03:00
## Keywords
## a-e
2016-03-21 23:02:58 +03:00
color statement "\b(abstract|alias|align|asm|assert|auto|body|break|case|cast|catch|class|const|continue|debug|default|delegate|do|else|enum|export|extern)\b"
2016-03-21 19:16:02 +03:00
## f-l
2016-03-21 23:02:58 +03:00
color statement "\b(false|final|finally|for|foreach|foreach_reverse|function|goto|if|immutable|import|in|inout|interface|invariant|is|lazy)\b"
2016-03-21 19:16:02 +03:00
## m-r
2016-03-21 23:02:58 +03:00
color statement "\b(macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|ref|return)\b"
2016-03-21 19:16:02 +03:00
## s-w
2016-03-21 23:02:58 +03:00
color statement "\b(scope|shared|static|struct|super|switch|synchronized|template|this|throw|true|try|typeid|typeof|union|unittest|version|while|with)\b"
2016-03-21 19:16:02 +03:00
## __
2016-03-21 23:02:58 +03:00
color statement "\b(__FILE__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__|__gshared|__traits|__vector|__parameters)\b"
2016-03-21 19:16:02 +03:00
## Deprecated keywords
2016-03-21 23:02:58 +03:00
color error "\b(delete|deprecated|typedef|volatile)\b"
2016-03-21 19:16:02 +03:00
## Primitive types
2016-03-21 23:02:58 +03:00
color type "\b(bool|byte|cdouble|cent|cfloat|char|creal|dchar|double|float|idouble|ifloat|int|ireal|long|real|short|ubyte|ucent|uint|ulong|ushort|void|wchar)\b"
2016-03-21 19:16:02 +03:00
## Globally defined symbols
2016-03-21 23:02:58 +03:00
color type "\b(string|wstring|dstring|size_t|ptrdiff_t)\b"
2016-03-21 19:16:02 +03:00
## Special tokens
2016-03-21 23:02:58 +03:00
color constant "\b(__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__)\b"
2016-03-21 19:16:02 +03:00
## String literals
## TODO: multiline backtick and doublequote string. (Unlikely possible at all with nano.)
### DoubleQuotedString
2016-06-26 02:20:13 +03:00
color constant.string ""(\\.|[^"])*""
2016-03-21 19:16:02 +03:00
### WysiwygString
2016-06-26 02:20:13 +03:00
color constant.string start="r"" end="""
color constant.string "`[^`]*`"
2016-03-21 19:16:02 +03:00
### HexString
2016-06-26 02:20:13 +03:00
color constant.string "x"([[:space:]]*[[:xdigit:]][[:space:]]*[[:xdigit:]])*[[:space:]]*""
2016-03-21 19:16:02 +03:00
### DelimitedString
2016-06-26 02:20:13 +03:00
color constant.string "q"\(.*\)""
color constant.string "q"\{.*\}""
color constant.string "q"\[.*\]""
color constant.string "q"<.*>""
color constant.string start="q"[^({[<"][^"]*$" end="^[^"]+""
color constant.string "q"([^({[<"]).*""
2016-03-21 19:16:02 +03:00
### TokenString
### True token strings require nesting, so, again, they can't be implemented accurately here.
### At the same time, the intended purpose of token strings makes it questionable to highlight them as strings at all.
2016-03-25 23:41:36 +03:00
## color ,magenta start="q\{" end="\}"
2016-03-21 19:16:02 +03:00
## Comments
2016-03-21 23:02:58 +03:00
## NB: true nested brightblacks are impossible to implement with plain regex
color comment "//.*"
2016-03-25 23:41:36 +03:00
color comment start="/\*" end="\*/"
color comment start="/\+" end="\+/"