## Author: Andrei Vinokurov
## Based on D lexer specification (http://dlang.org/lex)
-syntax "D" "\.(d(i|d)?)$"
+syntax "d" "\.(d(i|d)?)$"
## Operators and punctuation
color statement "(\*|/|%|\+|-|>>|<<|>>>|&|\^(\^)?|\||~)?="
color error "(0[0-7_]*)(L[uU]?|[uU]L?)?"
## Decimal integer literals
-color constant "([0-9]|[1-9][0-9_]*)(L[uU]?|[uU]L?)?"
+color constant.number "([0-9]|[1-9][0-9_]*)(L[uU]?|[uU]L?)?"
## Binary integer literals
color constant "(0[bB][01_]*)(L[uU]?|[uU]L?)?"
## Decimal float literals
-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])"
+color constant.number "[0-9][0-9_]*\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
+color constant.number "[0-9][0-9_]*([eE][+-]?([0-9][0-9_]*))[fFL]?i?"
+color constant.number "[^.]\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?"
+color constant.number "[0-9][0-9_]*([fFL]?i|[fF])"
## Hexadecimal integer literals
-color constant "(0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F]))(L[uU]?|[uU]L?)?"
+color constant.number "(0[xX]([0-9a-fA-F][0-9a-fA-F_]*|[0-9a-fA-F_]*[0-9a-fA-F]))(L[uU]?|[uU]L?)?"
## Hexadecimal float literals
-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?"
+color constant.number "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.number "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?"
## Character literals
-color constant "'([^\']|\\(['"?\abfnrtv]|x[[:xdigit:]]{2}|[0-7]{1,3}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8}|&.*;))'"
+color constant.string "'([^\']|\\(['"?\abfnrtv]|x[[:xdigit:]]{2}|[0-7]{1,3}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8}|&.*;))'"
## Keywords
## a-e
## String literals
## TODO: multiline backtick and doublequote string. (Unlikely possible at all with nano.)
### DoubleQuotedString
-color constant ""(\\.|[^"])*""
+color constant.string ""(\\.|[^"])*""
### WysiwygString
-color constant (s) "r".*?""
-color constant "`[^`]*`"
+color constant.string start="r"" end="""
+color constant.string "`[^`]*`"
### HexString
-color ,constant "x"([[:space:]]*[[:xdigit:]][[:space:]]*[[:xdigit:]])*[[:space:]]*""
+color constant.string "x"([[:space:]]*[[:xdigit:]][[:space:]]*[[:xdigit:]])*[[:space:]]*""
### DelimitedString
-color constant "q"\(.*\)""
-color constant "q"\{.*\}""
-color constant "q"\[.*\]""
-color constant "q"<.*>""
-color constant (s) "q"[^({[<"][^"]*$.*?^[^"]+""
-color constant "q"([^({[<"]).*\1""
+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"([^({[<"]).*""
### 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.
-## color ,magenta (s) "q\{.*?\}"
+## color ,magenta start="q\{" end="\}"
## Comments
## NB: true nested brightblacks are impossible to implement with plain regex
color comment "//.*"
-color comment (s) "/\*.*?\*/"
-color comment (s) "/\+.*?\+/"
+color comment start="/\*" end="\*/"
+color comment start="/\+" end="\+/"