X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=runtime%2Fsyntax%2Fd.yaml;h=db9fd6951414b17f78f5bc0f991ad03988eb8b59;hb=604d78de0f4e79221d022f9e4b01ab6044946ca5;hp=d3c1a8de246b9729fc8b08be4b2c98338079b40f;hpb=b977bf5cca84f7dc762fe8d9967831502ee5cc87;p=micro.git diff --git a/runtime/syntax/d.yaml b/runtime/syntax/d.yaml index d3c1a8de..db9fd695 100644 --- a/runtime/syntax/d.yaml +++ b/runtime/syntax/d.yaml @@ -1,55 +1,119 @@ filetype: d -detect: +detect: filename: "\\.(d(i|d)?)$" rules: + # Operators and punctuation - statement: "(\\*|/|%|\\+|-|>>|<<|>>>|&|\\^(\\^)?|\\||~)?=" - statement: "\\.\\.(\\.)?|!|\\*|&|~|\\(|\\)|\\[|\\]|\\\\|/|\\+|-|%|<|>|\\?|:|;" + # Octal integer literals are deprecated - error: "(0[0-7_]*)(L[uU]?|[uU]L?)?" + # Decimal integer literals - constant.number: "([0-9]|[1-9][0-9_]*)(L[uU]?|[uU]L?)?" + # Binary integer literals - constant: "(0[bB][01_]*)(L[uU]?|[uU]L?)?" + # Decimal float literals - constant.number: "[0-9][0-9_]*\\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?" - constant.number: "[0-9][0-9_]*([eE][+-]?([0-9][0-9_]*))[fFL]?i?" - constant.number: "[^.]\\.([0-9][0-9_]*)([eE][+-]?([0-9][0-9_]*))?[fFL]?i?" - constant.number: "[0-9][0-9_]*([fFL]?i|[fF])" + # Hexadecimal integer literals - 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 - 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?" - 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?" - - constant.string: "'([^\\']|\\\\(['\"?\\abfnrtv]|x[[:xdigit:]]{2}|[0-7]{1,3}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8}|&.*;))'" + # Character literals + - constant.string: + start: "'" + end: "'" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\." + # Keywords + # a-e - 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" + # f-l - statement: "\\b(false|final|finally|for|foreach|foreach_reverse|function|goto|if|immutable|import|in|inout|interface|invariant|is|lazy)\\b" + # m-r - statement: "\\b(macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|ref|return)\\b" + # s-w - statement: "\\b(scope|shared|static|struct|super|switch|synchronized|template|this|throw|true|try|typeid|typeof|union|unittest|version|while|with)\\b" + # __ - statement: "\\b(__FILE__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__|__gshared|__traits|__vector|__parameters)\\b" + # Deprecated keywords - error: "\\b(delete|deprecated|typedef|volatile)\\b" + # Primitive types - 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" + # Globally defined symbols - type: "\\b(string|wstring|dstring|size_t|ptrdiff_t)\\b" + # Special tokens - constant: "\\b(__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__)\\b" - - constant.string: "\"(\\\\.|[^\"])*\"" + # String literals + # DoubleQuotedString + - constant.string: + start: "\"" + end: "\"" + skip: "\\\\." + rules: + - constant.specialChar: "\\\\." + # WysiwygString - constant.string: start: "r\"" end: "\"" - rules: [] - - - constant.string: "`[^`]*`" - - constant.string: "x\"([[:space:]]*[[:xdigit:]][[:space:]]*[[:xdigit:]])*[[:space:]]*\"" - - constant.string: "q\"\\(.*\\)\"" - - constant.string: "q\"\\{.*\\}\"" - - constant.string: "q\"\\[.*\\]\"" - - constant.string: "q\"<.*>\"" + rules: + - constant.specialChar: "\\\\." + - constant.string: + start: "`" + end: "`" + rules: + - constant.specialChar: "\\\\." + # HexString + - constant.string: + start: "x\"" + end: "\"" + rules: + - constant.specialChar: "\\\\." + # DelimitedString + - constant.string: + start: "q\"\\(" + end: "\\)\"" + rules: + - constant.specialChar: "\\\\." + - constant.string: + start: "q\"\\{" + end: "q\"\\}" + rules: + - constant.specialChar: "\\\\." + - constant.string: + start: "q\"\\[" + end: "q\"\\]" + rules: + - constant.specialChar: "\\\\." + - constant.string: + start: "q\"<" + end: "q\">" + rules: + - constant.specialChar: "\\\\." - constant.string: start: "q\"[^({[<\"][^\"]*$" end: "^[^\"]+\"" + rules: + - constant.specialChar: "\\\\." + - constant.string: + start: "q\"([^({[<\"])" + end: "\"" + rules: + - constant.specialChar: "\\\\." + # Comments + - comment: + start: "//" + end: "$" rules: [] - - - constant.string: "q\"([^({[<\"]).*\"" - - comment: "//.*" - comment: start: "/\\*" end: "\\*/" rules: [] - - comment: start: "/\\+" end: "\\+/"