]> git.lizzy.rs Git - micro.git/blobdiff - runtime/syntax/d.micro
adding hexidecimal numbers to the existing C syntax rules
[micro.git] / runtime / syntax / d.micro
index c7ccb60330f5a2851ebb315e1ccdfb172288cf92..210e570db261b64dfefec76b3e17097847f8c69e 100644 (file)
@@ -3,7 +3,7 @@
 ## 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 "(\*|/|%|\+|-|>>|<<|>>>|&|\^(\^)?|\||~)?="
@@ -13,27 +13,27 @@ 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
@@ -62,30 +62,30 @@ color constant "\b(__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION_
 ## 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="\+/"