diff options
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/docs/.vitepress/config.mts | 16 | ||||
| -rw-r--r-- | doc/docs/.vitepress/grammars/moonscript.tmLanguage | 263 | ||||
| -rw-r--r-- | doc/docs/.vitepress/grammars/moonscript.tmLanguage.json | 149 | ||||
| -rw-r--r-- | doc/docs/.vitepress/grammars/yuescript.tmLanguage.json | 689 | ||||
| -rwxr-xr-x | doc/docs/.vitepress/theme/components/YueCompiler.vue | 193 | ||||
| -rw-r--r-- | doc/docs/doc/destructuring-assignment.md | 2 | ||||
| -rw-r--r-- | doc/docs/doc/macro.md | 1 | ||||
| -rw-r--r-- | doc/docs/zh/doc/destructuring-assignment.md | 2 | ||||
| -rw-r--r-- | doc/docs/zh/doc/macro.md | 1 |
9 files changed, 869 insertions, 447 deletions
diff --git a/doc/docs/.vitepress/config.mts b/doc/docs/.vitepress/config.mts index c672c7a..188c2fa 100644 --- a/doc/docs/.vitepress/config.mts +++ b/doc/docs/.vitepress/config.mts | |||
| @@ -10,13 +10,13 @@ import darkPlus from '@shikijs/themes/dark-plus'; | |||
| 10 | import lightPlus from '@shikijs/themes/light-plus'; | 10 | import lightPlus from '@shikijs/themes/light-plus'; |
| 11 | 11 | ||
| 12 | const __dirname = dirname(fileURLToPath(import.meta.url)) | 12 | const __dirname = dirname(fileURLToPath(import.meta.url)) |
| 13 | const moonscriptGrammarPath = resolve(__dirname, 'grammars/moonscript.tmLanguage.json') | 13 | const yuescriptGrammarPath = resolve(__dirname, 'grammars/yuescript.tmLanguage.json') |
| 14 | const moonscriptGrammar = JSON.parse(readFileSync(moonscriptGrammarPath, 'utf-8')) | 14 | const yuescriptGrammar = JSON.parse(readFileSync(yuescriptGrammarPath, 'utf-8')) |
| 15 | const moonscriptLanguage = { | 15 | const yuescriptLanguage = { |
| 16 | ...moonscriptGrammar, | 16 | ...yuescriptGrammar, |
| 17 | name: 'moonscript', | 17 | name: 'yuescript', |
| 18 | scopeName: 'source.moonscript', | 18 | scopeName: 'source.yuescript', |
| 19 | aliases: ['yue', 'yuescript', 'moon'], | 19 | aliases: ['yue'], |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | // Generate sidebar configuration function | 22 | // Generate sidebar configuration function |
| @@ -205,7 +205,7 @@ export default defineConfig({ | |||
| 205 | }, | 205 | }, |
| 206 | markdown: { | 206 | markdown: { |
| 207 | languages: [ | 207 | languages: [ |
| 208 | moonscriptLanguage, | 208 | yuescriptLanguage, |
| 209 | ], | 209 | ], |
| 210 | theme: { | 210 | theme: { |
| 211 | light: lightPlus, | 211 | light: lightPlus, |
diff --git a/doc/docs/.vitepress/grammars/moonscript.tmLanguage b/doc/docs/.vitepress/grammars/moonscript.tmLanguage deleted file mode 100644 index 2c041ba..0000000 --- a/doc/docs/.vitepress/grammars/moonscript.tmLanguage +++ /dev/null | |||
| @@ -1,263 +0,0 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| 3 | <plist version="1.0"> | ||
| 4 | <dict> | ||
| 5 | <!-- | ||
| 6 | Some parts extratec from Lua.tmLanguage | ||
| 7 | --> | ||
| 8 | <key>comment</key> | ||
| 9 | <string>MoonScript Syntax: 0.0.1</string> | ||
| 10 | <key>fileTypes</key> | ||
| 11 | <array> | ||
| 12 | <string>moon</string> | ||
| 13 | </array> | ||
| 14 | |||
| 15 | <key>name</key> | ||
| 16 | <string>MoonScript</string> | ||
| 17 | |||
| 18 | <key>patterns</key> | ||
| 19 | <array> | ||
| 20 | <dict> | ||
| 21 | <key>captures</key> | ||
| 22 | <dict> | ||
| 23 | <key>1</key> | ||
| 24 | <dict> | ||
| 25 | <key>name</key> | ||
| 26 | <string>punctuation.definition.comment.lua</string> | ||
| 27 | </dict> | ||
| 28 | </dict> | ||
| 29 | <key>match</key> | ||
| 30 | <string>(--)(?!\[\[).*$\n?</string> | ||
| 31 | <key>name</key> | ||
| 32 | <string>comment.line.double-dash.lua</string> | ||
| 33 | </dict> | ||
| 34 | |||
| 35 | |||
| 36 | <dict> | ||
| 37 | <key>begin</key> | ||
| 38 | <string>'</string> | ||
| 39 | <key>beginCaptures</key> | ||
| 40 | <dict> | ||
| 41 | <key>0</key> | ||
| 42 | <dict> | ||
| 43 | <key>name</key> | ||
| 44 | <string>punctuation.definition.string.begin.lua</string> | ||
| 45 | </dict> | ||
| 46 | </dict> | ||
| 47 | <key>end</key> | ||
| 48 | <string>'</string> | ||
| 49 | <key>endCaptures</key> | ||
| 50 | <dict> | ||
| 51 | <key>0</key> | ||
| 52 | <dict> | ||
| 53 | <key>name</key> | ||
| 54 | <string>punctuation.definition.string.end.lua</string> | ||
| 55 | </dict> | ||
| 56 | </dict> | ||
| 57 | <key>name</key> | ||
| 58 | <string>string.quoted.single.lua</string> | ||
| 59 | <key>patterns</key> | ||
| 60 | <array> | ||
| 61 | <dict> | ||
| 62 | <key>match</key> | ||
| 63 | <string>\\(\d{1,3}|.)</string> | ||
| 64 | <key>name</key> | ||
| 65 | <string>constant.character.escape.lua</string> | ||
| 66 | </dict> | ||
| 67 | </array> | ||
| 68 | </dict> | ||
| 69 | |||
| 70 | <dict> | ||
| 71 | <key>begin</key> | ||
| 72 | <string>"</string> | ||
| 73 | <key>beginCaptures</key> | ||
| 74 | <dict> | ||
| 75 | <key>0</key> | ||
| 76 | <dict> | ||
| 77 | <key>name</key> | ||
| 78 | <string>punctuation.definition.string.begin.lua</string> | ||
| 79 | </dict> | ||
| 80 | </dict> | ||
| 81 | <key>end</key> | ||
| 82 | <string>"</string> | ||
| 83 | <key>endCaptures</key> | ||
| 84 | <dict> | ||
| 85 | <key>0</key> | ||
| 86 | <dict> | ||
| 87 | <key>name</key> | ||
| 88 | <string>punctuation.definition.string.end.lua</string> | ||
| 89 | </dict> | ||
| 90 | </dict> | ||
| 91 | <key>name</key> | ||
| 92 | <string>string.quoted.double.lua</string> | ||
| 93 | <key>patterns</key> | ||
| 94 | <array> | ||
| 95 | <dict> | ||
| 96 | <key>match</key> | ||
| 97 | <string>\\(\d{1,3}|.)</string> | ||
| 98 | <key>name</key> | ||
| 99 | <string>constant.character.escape.lua</string> | ||
| 100 | </dict> | ||
| 101 | </array> | ||
| 102 | </dict> | ||
| 103 | |||
| 104 | <dict> | ||
| 105 | <key>begin</key> | ||
| 106 | <string>(?<!--)\[(=*)\[</string> | ||
| 107 | <key>beginCaptures</key> | ||
| 108 | <dict> | ||
| 109 | <key>0</key> | ||
| 110 | <dict> | ||
| 111 | <key>name</key> | ||
| 112 | <string>punctuation.definition.string.begin.lua</string> | ||
| 113 | </dict> | ||
| 114 | </dict> | ||
| 115 | <key>end</key> | ||
| 116 | <string>\]\1\]</string> | ||
| 117 | <key>endCaptures</key> | ||
| 118 | <dict> | ||
| 119 | <key>0</key> | ||
| 120 | <dict> | ||
| 121 | <key>name</key> | ||
| 122 | <string>punctuation.definition.string.end.lua</string> | ||
| 123 | </dict> | ||
| 124 | </dict> | ||
| 125 | <key>name</key> | ||
| 126 | <string>string.quoted.other.multiline.lua</string> | ||
| 127 | </dict> | ||
| 128 | |||
| 129 | <dict> | ||
| 130 | <key>match</key> | ||
| 131 | <string>(?<![\d.])\s0x[a-fA-F\d]+|\b\d+(\.\d+)?([eE]-?\d+)?|\.\d+([eE]-?\d+)?</string> | ||
| 132 | <key>name</key> | ||
| 133 | <string>constant.numeric.lua</string> | ||
| 134 | </dict> | ||
| 135 | |||
| 136 | <dict> | ||
| 137 | <key>name</key> | ||
| 138 | <string>support.constant</string> | ||
| 139 | <key>match</key> | ||
| 140 | <string>\b[A-Z]\w*\b(?!:)</string> | ||
| 141 | </dict> | ||
| 142 | |||
| 143 | <dict> | ||
| 144 | <key>name</key> | ||
| 145 | <string>keyword.operator</string> | ||
| 146 | <key>match</key> | ||
| 147 | <string>=>|-></string> | ||
| 148 | </dict> | ||
| 149 | |||
| 150 | <dict> | ||
| 151 | <key>match</key> | ||
| 152 | <string>\b(and|or|not)\b</string> | ||
| 153 | <key>name</key> | ||
| 154 | <string>keyword.operator.lua</string> | ||
| 155 | </dict> | ||
| 156 | |||
| 157 | <dict> | ||
| 158 | <key>match</key> | ||
| 159 | <string>[a-zA-Z_]\w*\s*(?=:)</string> | ||
| 160 | <key>name</key> | ||
| 161 | <string>entity.name.function</string> | ||
| 162 | </dict> | ||
| 163 | |||
| 164 | <dict> | ||
| 165 | <key>match</key> | ||
| 166 | <string>\(|\)</string> | ||
| 167 | <key>name</key> | ||
| 168 | <string>entity.name.function</string> | ||
| 169 | </dict> | ||
| 170 | |||
| 171 | <dict> | ||
| 172 | <key>match</key> | ||
| 173 | <string>\+|-|%|#|\*|\/|\^|==?|~=|!=|\\|:|,|;|\.|<=?|>=?|(?<!\.)\.{2}(?!\.)</string> | ||
| 174 | <key>name</key> | ||
| 175 | <string>keyword.operator.lua</string> | ||
| 176 | </dict> | ||
| 177 | |||
| 178 | <dict> | ||
| 179 | <key>match</key> | ||
| 180 | <string>{|}|\[|\]</string> | ||
| 181 | <key>name</key> | ||
| 182 | <string>storage.modifier</string> | ||
| 183 | </dict> | ||
| 184 | |||
| 185 | <dict> | ||
| 186 | <key>name</key> | ||
| 187 | <string>storage.type.class</string> | ||
| 188 | <key>match</key> | ||
| 189 | <string>\b(class|extends|super)\b</string> | ||
| 190 | </dict> | ||
| 191 | |||
| 192 | <dict> | ||
| 193 | <key>name</key> | ||
| 194 | <string>keyword.control</string> | ||
| 195 | <key>match</key> | ||
| 196 | <string>\b(if|then|else|elseif|export|import|from|switch|when|with|using|do|for|in|while|return|local|unless|continue|break)\b</string> | ||
| 197 | </dict> | ||
| 198 | |||
| 199 | <dict> | ||
| 200 | <key>name</key> | ||
| 201 | <string>variable.language</string> | ||
| 202 | <key>match</key> | ||
| 203 | <string>\b(self)\b</string> | ||
| 204 | </dict> | ||
| 205 | |||
| 206 | <dict> | ||
| 207 | <key>name</key> | ||
| 208 | <string>variable.parameter</string> | ||
| 209 | <key>match</key> | ||
| 210 | <string>@@?[a-zA-Z_]\w*\b</string> | ||
| 211 | </dict> | ||
| 212 | |||
| 213 | <dict> | ||
| 214 | <key>name</key> | ||
| 215 | <string>constant.language.nil</string> | ||
| 216 | <key>match</key> | ||
| 217 | <string>\b(nil)\b</string> | ||
| 218 | </dict> | ||
| 219 | |||
| 220 | |||
| 221 | <dict> | ||
| 222 | <key>match</key> | ||
| 223 | <string>\b(true|false)\b</string> | ||
| 224 | <key>name</key> | ||
| 225 | <string>constant.language.boolean</string> | ||
| 226 | </dict> | ||
| 227 | |||
| 228 | <dict> | ||
| 229 | <key>match</key> | ||
| 230 | <string>(?<!\.|\\)\b(function|repeat|end)\b(?!\s*:)</string> | ||
| 231 | <key>name</key> | ||
| 232 | <string>invalid.illegal</string> | ||
| 233 | </dict> | ||
| 234 | |||
| 235 | <dict> | ||
| 236 | <key>match</key> | ||
| 237 | <string>(?<![^.]\.|\\)\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\b</string> | ||
| 238 | <key>name</key> | ||
| 239 | <string>support.function.lua</string> | ||
| 240 | </dict> | ||
| 241 | |||
| 242 | <dict> | ||
| 243 | <key>match</key> | ||
| 244 | <string>(?<![^.]\.|\\)\b(_G)\b</string> | ||
| 245 | <key>name</key> | ||
| 246 | <string>support.constant</string> | ||
| 247 | </dict> | ||
| 248 | |||
| 249 | <dict> | ||
| 250 | <key>match</key> | ||
| 251 | <string>(?<![^.]\.|\\)\b(coroutine\.(create|resume|running|status|wrap|yield)|string\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)|table\.(concat|insert|maxn|remove|sort)|math\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|pow|rad|random|randomseed|sinh?|sqrt|tanh?)|io\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)|os\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\.(cpath|loaded|loadlib|path|preload|seeall)|debug\.(debug|[gs]etfenv|[gs]ethook|getinfo|[gs]etlocal|[gs]etmetatable|getregistry|[gs]etupvalue|traceback))\b</string> | ||
| 252 | <key>name</key> | ||
| 253 | <string>support.function.library.lua</string> | ||
| 254 | </dict> | ||
| 255 | |||
| 256 | </array> | ||
| 257 | |||
| 258 | <key>scopeName</key> | ||
| 259 | <string>source.moonscript</string> | ||
| 260 | <key>uuid</key> | ||
| 261 | <string>D363822C-639B-4450-A21A-F45643A6940F</string> | ||
| 262 | </dict> | ||
| 263 | </plist> | ||
diff --git a/doc/docs/.vitepress/grammars/moonscript.tmLanguage.json b/doc/docs/.vitepress/grammars/moonscript.tmLanguage.json deleted file mode 100644 index 98a3dc9..0000000 --- a/doc/docs/.vitepress/grammars/moonscript.tmLanguage.json +++ /dev/null | |||
| @@ -1,149 +0,0 @@ | |||
| 1 | { | ||
| 2 | "comment": "MoonScript Syntax: 0.0.1", | ||
| 3 | "fileTypes": [ | ||
| 4 | "moon" | ||
| 5 | ], | ||
| 6 | "name": "MoonScript", | ||
| 7 | "patterns": [ | ||
| 8 | { | ||
| 9 | "captures": { | ||
| 10 | "1": { | ||
| 11 | "name": "punctuation.definition.comment.lua" | ||
| 12 | } | ||
| 13 | }, | ||
| 14 | "match": "(--)(?!\\[\\[).*$\\n?", | ||
| 15 | "name": "comment.line.double-dash.lua" | ||
| 16 | }, | ||
| 17 | { | ||
| 18 | "begin": "'", | ||
| 19 | "beginCaptures": { | ||
| 20 | "0": { | ||
| 21 | "name": "punctuation.definition.string.begin.lua" | ||
| 22 | } | ||
| 23 | }, | ||
| 24 | "end": "'", | ||
| 25 | "endCaptures": { | ||
| 26 | "0": { | ||
| 27 | "name": "punctuation.definition.string.end.lua" | ||
| 28 | } | ||
| 29 | }, | ||
| 30 | "name": "string.quoted.single.lua", | ||
| 31 | "patterns": [ | ||
| 32 | { | ||
| 33 | "match": "\\\\(\\d{1,3}|.)", | ||
| 34 | "name": "constant.character.escape.lua" | ||
| 35 | } | ||
| 36 | ] | ||
| 37 | }, | ||
| 38 | { | ||
| 39 | "begin": "\"", | ||
| 40 | "beginCaptures": { | ||
| 41 | "0": { | ||
| 42 | "name": "punctuation.definition.string.begin.lua" | ||
| 43 | } | ||
| 44 | }, | ||
| 45 | "end": "\"", | ||
| 46 | "endCaptures": { | ||
| 47 | "0": { | ||
| 48 | "name": "punctuation.definition.string.end.lua" | ||
| 49 | } | ||
| 50 | }, | ||
| 51 | "name": "string.quoted.double.lua", | ||
| 52 | "patterns": [ | ||
| 53 | { | ||
| 54 | "match": "\\\\(\\d{1,3}|.)", | ||
| 55 | "name": "constant.character.escape.lua" | ||
| 56 | } | ||
| 57 | ] | ||
| 58 | }, | ||
| 59 | { | ||
| 60 | "begin": "(?<!--)\\[(=*)\\[", | ||
| 61 | "beginCaptures": { | ||
| 62 | "0": { | ||
| 63 | "name": "punctuation.definition.string.begin.lua" | ||
| 64 | } | ||
| 65 | }, | ||
| 66 | "end": "\\]\\1\\]", | ||
| 67 | "endCaptures": { | ||
| 68 | "0": { | ||
| 69 | "name": "punctuation.definition.string.end.lua" | ||
| 70 | } | ||
| 71 | }, | ||
| 72 | "name": "string.quoted.other.multiline.lua" | ||
| 73 | }, | ||
| 74 | { | ||
| 75 | "match": "(?<![\\d.])\\s0x[a-fA-F\\d]+|\\b\\d+(\\.\\d+)?([eE]-?\\d+)?|\\.\\d+([eE]-?\\d+)?", | ||
| 76 | "name": "constant.numeric.lua" | ||
| 77 | }, | ||
| 78 | { | ||
| 79 | "name": "support.constant", | ||
| 80 | "match": "\\b[A-Z]\\w*\\b(?!:)" | ||
| 81 | }, | ||
| 82 | { | ||
| 83 | "name": "keyword.operator", | ||
| 84 | "match": "=>|->" | ||
| 85 | }, | ||
| 86 | { | ||
| 87 | "match": "\\b(and|or|not)\\b", | ||
| 88 | "name": "keyword.operator.lua" | ||
| 89 | }, | ||
| 90 | { | ||
| 91 | "match": "[a-zA-Z_]\\w*\\s*(?=:)", | ||
| 92 | "name": "entity.name.function" | ||
| 93 | }, | ||
| 94 | { | ||
| 95 | "match": "\\(|\\)", | ||
| 96 | "name": "entity.name.function" | ||
| 97 | }, | ||
| 98 | { | ||
| 99 | "match": "\\+|-|%|#|\\*|\\/|\\^|==?|~=|!=|\\\\|:|,|;|\\.|<=?|>=?|(?<!\\.)\\.{2}(?!\\.)", | ||
| 100 | "name": "keyword.operator.lua" | ||
| 101 | }, | ||
| 102 | { | ||
| 103 | "match": "{|}|\\[|\\]", | ||
| 104 | "name": "storage.modifier" | ||
| 105 | }, | ||
| 106 | { | ||
| 107 | "name": "storage.type.class", | ||
| 108 | "match": "\\b(class|extends|super)\\b" | ||
| 109 | }, | ||
| 110 | { | ||
| 111 | "name": "keyword.control", | ||
| 112 | "match": "\\b(if|then|else|elseif|export|import|from|switch|when|with|using|do|for|in|while|return|local|unless|continue|break)\\b" | ||
| 113 | }, | ||
| 114 | { | ||
| 115 | "name": "variable.language", | ||
| 116 | "match": "\\b(self)\\b" | ||
| 117 | }, | ||
| 118 | { | ||
| 119 | "name": "variable.parameter", | ||
| 120 | "match": "@@?[a-zA-Z_]\\w*\\b" | ||
| 121 | }, | ||
| 122 | { | ||
| 123 | "name": "constant.language.nil", | ||
| 124 | "match": "\\b(nil)\\b" | ||
| 125 | }, | ||
| 126 | { | ||
| 127 | "match": "\\b(true|false)\\b", | ||
| 128 | "name": "constant.language.boolean" | ||
| 129 | }, | ||
| 130 | { | ||
| 131 | "match": "(?<!\\.|\\\\)\\b(function|repeat|end)\\b(?!\\s*:)", | ||
| 132 | "name": "invalid.illegal" | ||
| 133 | }, | ||
| 134 | { | ||
| 135 | "match": "(?<![^.]\\.|\\\\)\\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\\b", | ||
| 136 | "name": "support.function.lua" | ||
| 137 | }, | ||
| 138 | { | ||
| 139 | "match": "(?<![^.]\\.|\\\\)\\b(_G)\\b", | ||
| 140 | "name": "support.constant" | ||
| 141 | }, | ||
| 142 | { | ||
| 143 | "match": "(?<![^.]\\.|\\\\)\\b(coroutine\\.(create|resume|running|status|wrap|yield)|string\\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)|table\\.(concat|insert|maxn|remove|sort)|math\\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|pow|rad|random|randomseed|sinh?|sqrt|tanh?)|io\\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)|os\\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\\.(cpath|loaded|loadlib|path|preload|seeall)|debug\\.(debug|[gs]etfenv|[gs]ethook|getinfo|[gs]etlocal|[gs]etmetatable|getregistry|[gs]etupvalue|traceback))\\b", | ||
| 144 | "name": "support.function.library.lua" | ||
| 145 | } | ||
| 146 | ], | ||
| 147 | "scopeName": "source.moonscript", | ||
| 148 | "uuid": "D363822C-639B-4450-A21A-F45643A6940F" | ||
| 149 | } \ No newline at end of file | ||
diff --git a/doc/docs/.vitepress/grammars/yuescript.tmLanguage.json b/doc/docs/.vitepress/grammars/yuescript.tmLanguage.json new file mode 100644 index 0000000..62ac5fb --- /dev/null +++ b/doc/docs/.vitepress/grammars/yuescript.tmLanguage.json | |||
| @@ -0,0 +1,689 @@ | |||
| 1 | { | ||
| 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", | ||
| 3 | "scopeName": "source.yue", | ||
| 4 | "name": "YueScript", | ||
| 5 | "fileTypes": [ | ||
| 6 | "yue" | ||
| 7 | ], | ||
| 8 | "patterns": [ | ||
| 9 | { | ||
| 10 | "match": "\\A(#!).*$\\n?", | ||
| 11 | "name": "comment.line.shebang.yue", | ||
| 12 | "captures": { | ||
| 13 | "1": { | ||
| 14 | "name": "punctuation.definition.comment.yue" | ||
| 15 | } | ||
| 16 | } | ||
| 17 | }, | ||
| 18 | { | ||
| 19 | "match": "(\\(.*?\\))?\\s*([=-]>)", | ||
| 20 | "name": "meta.inline.function.yue", | ||
| 21 | "captures": { | ||
| 22 | "1": { | ||
| 23 | "name": "variable.parameter.function.yue" | ||
| 24 | }, | ||
| 25 | "2": { | ||
| 26 | "name": "storage.type.function.yue" | ||
| 27 | } | ||
| 28 | } | ||
| 29 | }, | ||
| 30 | { | ||
| 31 | "match": "(?<=^|\\bdo\\b|[=-]>)\\s*(\\(.*?\\))?\\s*(<[=-]\\s*(?=[a-zA-Z_]))", | ||
| 32 | "name": "meta.inline.function.yue", | ||
| 33 | "captures": { | ||
| 34 | "1": { | ||
| 35 | "name": "variable.parameter.function.yue" | ||
| 36 | }, | ||
| 37 | "2": { | ||
| 38 | "name": "storage.type.function.yue" | ||
| 39 | } | ||
| 40 | } | ||
| 41 | }, | ||
| 42 | { | ||
| 43 | "match": "(\\b[A-Z]\\w*)\\s*", | ||
| 44 | "name": "entity.name.type.class.yue", | ||
| 45 | "captures": { | ||
| 46 | "1": { | ||
| 47 | "name": "entity.name.type.class" | ||
| 48 | } | ||
| 49 | } | ||
| 50 | }, | ||
| 51 | { | ||
| 52 | "begin": "\\[(=*)\\[", | ||
| 53 | "beginCaptures": { | ||
| 54 | "0": { | ||
| 55 | "name": "punctuation.definition.string.begin.yue" | ||
| 56 | } | ||
| 57 | }, | ||
| 58 | "end": "\\]\\1\\]", | ||
| 59 | "endCaptures": { | ||
| 60 | "0": { | ||
| 61 | "name": "punctuation.definition.string.end.yue" | ||
| 62 | } | ||
| 63 | }, | ||
| 64 | "name": "string.quoted.other.multiline.yue" | ||
| 65 | }, | ||
| 66 | { | ||
| 67 | "begin": "(?<!-)--\\[\\[", | ||
| 68 | "captures": { | ||
| 69 | "0": { | ||
| 70 | "name": "punctuation.definition.comment.yue" | ||
| 71 | } | ||
| 72 | }, | ||
| 73 | "end": "\\]\\]", | ||
| 74 | "name": "comment.block.yue", | ||
| 75 | "patterns": [ | ||
| 76 | { | ||
| 77 | "match": "@\\w*", | ||
| 78 | "name": "storage.type.annotation.yue" | ||
| 79 | } | ||
| 80 | ] | ||
| 81 | }, | ||
| 82 | { | ||
| 83 | "begin": "(?<!-)--", | ||
| 84 | "end": "(?:[ \\t]*\\n)", | ||
| 85 | "name": "comment.line.yue", | ||
| 86 | "patterns": [ | ||
| 87 | { | ||
| 88 | "match": "@\\w*", | ||
| 89 | "name": "storage.type.annotation.yuescript" | ||
| 90 | } | ||
| 91 | ], | ||
| 92 | "captures": { | ||
| 93 | "0": { | ||
| 94 | "name": "punctuation.definition.comment.yue" | ||
| 95 | } | ||
| 96 | } | ||
| 97 | }, | ||
| 98 | { | ||
| 99 | "match": "(::)\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*(::)", | ||
| 100 | "name": "string.tag.lua", | ||
| 101 | "captures": { | ||
| 102 | "1": { | ||
| 103 | "name": "punctuation.section.embedded.begin.yue" | ||
| 104 | }, | ||
| 105 | "2": { | ||
| 106 | "name": "punctuation.section.embedded.end.yue" | ||
| 107 | } | ||
| 108 | } | ||
| 109 | }, | ||
| 110 | { | ||
| 111 | "patterns": [ | ||
| 112 | { | ||
| 113 | "match": "<\\b(?:mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\\b>", | ||
| 114 | "name": "constant.language.yue" | ||
| 115 | }, | ||
| 116 | { | ||
| 117 | "match": "<>", | ||
| 118 | "name": "constant.language.yue" | ||
| 119 | }, | ||
| 120 | { | ||
| 121 | "match": "<(\"(?:\\\\\"|[^\"])*\")>", | ||
| 122 | "name": "constant.language.yue", | ||
| 123 | "captures": { | ||
| 124 | "1": { | ||
| 125 | "name": "string.quoted.double.yue" | ||
| 126 | } | ||
| 127 | } | ||
| 128 | }, | ||
| 129 | { | ||
| 130 | "match": "<('(?:\\\\'|[^'])*')>", | ||
| 131 | "name": "constant.language.yue", | ||
| 132 | "captures": { | ||
| 133 | "1": { | ||
| 134 | "name": "string.quoted.single.yue" | ||
| 135 | } | ||
| 136 | } | ||
| 137 | }, | ||
| 138 | { | ||
| 139 | "match": "<\\w+>", | ||
| 140 | "name": "invalid.illegal.yue" | ||
| 141 | } | ||
| 142 | ] | ||
| 143 | }, | ||
| 144 | { | ||
| 145 | "match": "(\\+|\\-|\\*|/|%|\\^|//|\\||\\&|>>|<<|(?<!\\?)\\?{2}(?!\\?)|(?<!\\.)\\.{2}(?!\\.)|\\band|\\bor)=?", | ||
| 146 | "name": "keyword.operator.yue" | ||
| 147 | }, | ||
| 148 | { | ||
| 149 | "match": "\\[\\]\\s*=", | ||
| 150 | "name": "keyword.operator.yue" | ||
| 151 | }, | ||
| 152 | { | ||
| 153 | "match": "==|~=|\\!=|>|>=|<|<=", | ||
| 154 | "name": "keyword.operator.yue" | ||
| 155 | }, | ||
| 156 | { | ||
| 157 | "match": "#|\\-|~|\\?|!", | ||
| 158 | "name": "keyword.operator.yue" | ||
| 159 | }, | ||
| 160 | { | ||
| 161 | "match": "\\|>|=|:=|(?<!:):(?!:)|,|\\b_\\b", | ||
| 162 | "name": "keyword.operator.yue" | ||
| 163 | }, | ||
| 164 | { | ||
| 165 | "match": "(?<!\\.)\\.{3}(?!\\.)(?!\\w+)", | ||
| 166 | "name": "constant.language.yue" | ||
| 167 | }, | ||
| 168 | { | ||
| 169 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using)\\b(?!:)", | ||
| 170 | "name": "keyword.yue" | ||
| 171 | }, | ||
| 172 | { | ||
| 173 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto)\\b(?!:)", | ||
| 174 | "name": "keyword.control.yue" | ||
| 175 | }, | ||
| 176 | { | ||
| 177 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:or|and|in|not)\\b(?!:)", | ||
| 178 | "name": "keyword.control.yue" | ||
| 179 | }, | ||
| 180 | { | ||
| 181 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:true|false|nil)\\b(?!:)", | ||
| 182 | "name": "constant.language.boolean.yue" | ||
| 183 | }, | ||
| 184 | { | ||
| 185 | "match": "\\b(?<![\\.|:|::|\\\\|\\$])(function|end)(?!:)\\b", | ||
| 186 | "name": "invalid.illegal.yue" | ||
| 187 | }, | ||
| 188 | { | ||
| 189 | "match": "((?<!\\.)\\.{4,}(?!\\.))", | ||
| 190 | "name": "invalid.illegal.yue" | ||
| 191 | }, | ||
| 192 | { | ||
| 193 | "begin": "(?<=\\s|^)(\\{)(?=.+?\\}\\s+[:=])", | ||
| 194 | "beginCaptures": { | ||
| 195 | "0": { | ||
| 196 | "name": "keyword.control.yue" | ||
| 197 | } | ||
| 198 | }, | ||
| 199 | "end": "(\\}\\s*[:=])", | ||
| 200 | "endCaptures": { | ||
| 201 | "0": { | ||
| 202 | "name": "keyword.control.yue" | ||
| 203 | } | ||
| 204 | }, | ||
| 205 | "name": "meta.variable.assignment.destructured.object.yue", | ||
| 206 | "patterns": [ | ||
| 207 | { | ||
| 208 | "include": "#expression" | ||
| 209 | } | ||
| 210 | ] | ||
| 211 | }, | ||
| 212 | { | ||
| 213 | "match": "(?<=[ \t]*)\\b(?:new)\\b(?=:(?:\\s*\\(.*\\))?\\s*=>)", | ||
| 214 | "name": "variable.language.yue" | ||
| 215 | }, | ||
| 216 | { | ||
| 217 | "match": "(?x)\n\t\t\t\t(?<=^|\\s)\n\t\t\t\t(?=@?[a-zA-Z\\$_]\\??)\n\t\t\t\t(\n\t\t\t\t\t@?[a-zA-Z\\$_]\\??(\\w|\\$|:|\\.)*\\s*\n\t\t\t\t\t(?=[:=](\\s*\\(.*\\))?\\s*([=-]>))\n\t\t\t\t)\n\t\t\t", | ||
| 218 | "name": "meta.function.yue", | ||
| 219 | "captures": { | ||
| 220 | "1": { | ||
| 221 | "name": "entity.name.function.yue" | ||
| 222 | }, | ||
| 223 | "2": { | ||
| 224 | "name": "entity.name.function.yue" | ||
| 225 | }, | ||
| 226 | "3": { | ||
| 227 | "name": "variable.parameter.function.yue" | ||
| 228 | }, | ||
| 229 | "4": { | ||
| 230 | "name": "storage.type.function.yue" | ||
| 231 | } | ||
| 232 | } | ||
| 233 | }, | ||
| 234 | { | ||
| 235 | "match": "\\b__(class|base|init|inherited|mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\\b", | ||
| 236 | "name": "entity.name.function.yue" | ||
| 237 | }, | ||
| 238 | { | ||
| 239 | "match": "(?:\\bclass\\b)\\s+(@?[a-zA-Z\\$_][\\w\\.]*)?(?:\\s+(?:\\bextends\\b)\\s+(@?[a-zA-Z\\$\\._][\\w\\.]*))?", | ||
| 240 | "name": "meta.class.yue", | ||
| 241 | "captures": { | ||
| 242 | "1": { | ||
| 243 | "name": "storage.type.class.yue" | ||
| 244 | }, | ||
| 245 | "2": { | ||
| 246 | "name": "entity.name.type.class.yue" | ||
| 247 | }, | ||
| 248 | "3": { | ||
| 249 | "name": "keyword.control.inheritance.yue" | ||
| 250 | }, | ||
| 251 | "4": { | ||
| 252 | "name": "entity.other.inherited-class.yue" | ||
| 253 | } | ||
| 254 | } | ||
| 255 | }, | ||
| 256 | { | ||
| 257 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:_ENV|_G|_VERSION|arg)\\b(?!(?:\\s*(?:(?:\\+|\\-|\\*|/|%|\\^|//|\\||\\&|>>|<<|(?<!\\?)\\?{2}(?!\\?)|(?<!\\.)\\.{2}(?!\\.)|\\band|\\bor)?=|:=)\\s*|:))", | ||
| 258 | "name": "constant.language.yue" | ||
| 259 | }, | ||
| 260 | { | ||
| 261 | "include": "#expression" | ||
| 262 | }, | ||
| 263 | { | ||
| 264 | "match": ",[ \\t]*", | ||
| 265 | "name": "meta.delimiter.object.comma.yue" | ||
| 266 | }, | ||
| 267 | { | ||
| 268 | "match": "\\.|::|\\\\", | ||
| 269 | "name": "meta.delimiter.method.yue" | ||
| 270 | }, | ||
| 271 | { | ||
| 272 | "match": "\\{|\\}", | ||
| 273 | "name": "meta.brace.curly.yue" | ||
| 274 | }, | ||
| 275 | { | ||
| 276 | "match": "\\(|\\)", | ||
| 277 | "name": "meta.brace.round.yue" | ||
| 278 | }, | ||
| 279 | { | ||
| 280 | "match": "\\[|\\]", | ||
| 281 | "name": "meta.brace.square.yue" | ||
| 282 | } | ||
| 283 | ], | ||
| 284 | "repository": { | ||
| 285 | "expression": { | ||
| 286 | "patterns": [ | ||
| 287 | { | ||
| 288 | "include": "#string" | ||
| 289 | }, | ||
| 290 | { | ||
| 291 | "include": "#numeric" | ||
| 292 | }, | ||
| 293 | { | ||
| 294 | "include": "#builtins" | ||
| 295 | }, | ||
| 296 | { | ||
| 297 | "include": "#variable_name" | ||
| 298 | } | ||
| 299 | ] | ||
| 300 | }, | ||
| 301 | "keyword": { | ||
| 302 | "patterns": [ | ||
| 303 | { | ||
| 304 | "match": "\\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using)\\b", | ||
| 305 | "name": "keyword.yue" | ||
| 306 | }, | ||
| 307 | { | ||
| 308 | "match": "\\b(?:if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto)\\b", | ||
| 309 | "name": "keyword.control.yue" | ||
| 310 | }, | ||
| 311 | { | ||
| 312 | "match": "\\b(?:or|and|in|not)\\b", | ||
| 313 | "name": "keyword.operator.yue" | ||
| 314 | } | ||
| 315 | ] | ||
| 316 | }, | ||
| 317 | "string": { | ||
| 318 | "patterns": [ | ||
| 319 | { | ||
| 320 | "include": "#single_quoted_string" | ||
| 321 | }, | ||
| 322 | { | ||
| 323 | "include": "#double_quoted_string" | ||
| 324 | } | ||
| 325 | ] | ||
| 326 | }, | ||
| 327 | "string_format_code": { | ||
| 328 | "patterns": [ | ||
| 329 | { | ||
| 330 | "match": "%(%|a|A|c|d|e|E|f|g|G|i|o|p|q|s|u|x|X)", | ||
| 331 | "name": "constant.character.yue" | ||
| 332 | } | ||
| 333 | ] | ||
| 334 | }, | ||
| 335 | "string_escape_sequence": { | ||
| 336 | "patterns": [ | ||
| 337 | { | ||
| 338 | "match": "\\\\([abfnrtvz\\'\"\\\\]|\\d{1,3}|x\\h{2}|u\\{\\h+\\})", | ||
| 339 | "name": "constant.character.yue" | ||
| 340 | }, | ||
| 341 | { | ||
| 342 | "match": "\\\\.", | ||
| 343 | "name": "invalid.illegal.yue" | ||
| 344 | } | ||
| 345 | ] | ||
| 346 | }, | ||
| 347 | "double_quoted_string": { | ||
| 348 | "patterns": [ | ||
| 349 | { | ||
| 350 | "begin": "\"", | ||
| 351 | "beginCaptures": { | ||
| 352 | "0": { | ||
| 353 | "name": "punctuation.definition.string.begin.yue" | ||
| 354 | } | ||
| 355 | }, | ||
| 356 | "end": "\"", | ||
| 357 | "endCaptures": { | ||
| 358 | "0": { | ||
| 359 | "name": "punctuation.definition.string.end.yue" | ||
| 360 | } | ||
| 361 | }, | ||
| 362 | "name": "string.quoted.double.yue", | ||
| 363 | "patterns": [ | ||
| 364 | { | ||
| 365 | "include": "#string_escape_sequence" | ||
| 366 | }, | ||
| 367 | { | ||
| 368 | "include": "#interpolated_yue" | ||
| 369 | }, | ||
| 370 | { | ||
| 371 | "include": "#string_format_code" | ||
| 372 | } | ||
| 373 | ] | ||
| 374 | } | ||
| 375 | ] | ||
| 376 | }, | ||
| 377 | "single_quoted_string": { | ||
| 378 | "patterns": [ | ||
| 379 | { | ||
| 380 | "begin": "'", | ||
| 381 | "beginCaptures": { | ||
| 382 | "0": { | ||
| 383 | "name": "punctuation.definition.string.begin.yue" | ||
| 384 | } | ||
| 385 | }, | ||
| 386 | "end": "'", | ||
| 387 | "endCaptures": { | ||
| 388 | "0": { | ||
| 389 | "name": "punctuation.definition.string.end.yue" | ||
| 390 | } | ||
| 391 | }, | ||
| 392 | "name": "string.quoted.single.yue", | ||
| 393 | "patterns": [ | ||
| 394 | { | ||
| 395 | "include": "#string_escape_sequence" | ||
| 396 | }, | ||
| 397 | { | ||
| 398 | "include": "#string_format_code" | ||
| 399 | } | ||
| 400 | ] | ||
| 401 | } | ||
| 402 | ] | ||
| 403 | }, | ||
| 404 | "interpolated_yue": { | ||
| 405 | "patterns": [ | ||
| 406 | { | ||
| 407 | "begin": "\\#\\{", | ||
| 408 | "captures": { | ||
| 409 | "0": { | ||
| 410 | "name": "punctuation.section.embedded.yue" | ||
| 411 | } | ||
| 412 | }, | ||
| 413 | "end": "\\}", | ||
| 414 | "name": "source.yue.embedded.source", | ||
| 415 | "patterns": [ | ||
| 416 | { | ||
| 417 | "include": "$self" | ||
| 418 | } | ||
| 419 | ] | ||
| 420 | } | ||
| 421 | ] | ||
| 422 | }, | ||
| 423 | "variable_name": { | ||
| 424 | "patterns": [ | ||
| 425 | { | ||
| 426 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)(\\b(?:self)\\b)(?!:)\\b", | ||
| 427 | "name": "invalid.deprecated.yue" | ||
| 428 | }, | ||
| 429 | { | ||
| 430 | "match": "(?x)\\b(?<!\\.|:|::|\\\\|\\$)\\b(?:super)\\b(?!(?:\\s*(?:(?:\\+|\\-|\\*|/|%|\\^|//|\\||\\&|>>|<<|(?<!\\?)\\?{2}(?!\\?)|(?<!\\.)\\.{2}(?!\\.)|\\band|\\bor)?=|:=)\\s*|:))", | ||
| 431 | "name": "variable.language.yue" | ||
| 432 | }, | ||
| 433 | { | ||
| 434 | "match": "(?:\\${2,}|@{3,})(?:(?:\\b[a-zA-Z_]\\w*)?((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*)*\\b)?", | ||
| 435 | "name": "invalid.illegal.yue" | ||
| 436 | }, | ||
| 437 | { | ||
| 438 | "match": "(?<!\\$)\\$\\b[a-zA-Z_]\\w*\\b", | ||
| 439 | "name": "entity.name.function.preprocessor.yue" | ||
| 440 | }, | ||
| 441 | { | ||
| 442 | "match": "(?<!\\$)\\$(?!\\$)", | ||
| 443 | "name": "invalid.illegal.yue" | ||
| 444 | }, | ||
| 445 | { | ||
| 446 | "match": "(?<![\\$@])@@(?:(?:\\b[a-zA-Z_]\\w*)?((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*)*\\b)?", | ||
| 447 | "name": "variable.other.static.yue" | ||
| 448 | }, | ||
| 449 | { | ||
| 450 | "match": "(?<![\\$@])@(?:(?:\\b[a-zA-Z_]\\w*)?((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*)*\\b)?", | ||
| 451 | "name": "variable.other.member.yue" | ||
| 452 | }, | ||
| 453 | { | ||
| 454 | "match": "(?<![\\$@])\\b[a-zA-Z_]\\w*((?:\\.|::|\\\\)\\b[a-zA-Z_]\\w*\\b)*", | ||
| 455 | "name": "variable.assignment.yue" | ||
| 456 | }, | ||
| 457 | { | ||
| 458 | "match": "(?<![\\$@])\\b([a-zA-Z\\$_]\\w*(\\.\\w+)*)\\b", | ||
| 459 | "name": "variable.assignment.yue", | ||
| 460 | "captures": { | ||
| 461 | "1": { | ||
| 462 | "name": "variable.assignment.yue" | ||
| 463 | } | ||
| 464 | } | ||
| 465 | } | ||
| 466 | ] | ||
| 467 | }, | ||
| 468 | "numeric": { | ||
| 469 | "patterns": [ | ||
| 470 | { | ||
| 471 | "match": "\\b([\\d_]+(\\.[\\d_]+)?|\\.[\\d_]+)(e[+\\-]?[\\d_]+)?\\b", | ||
| 472 | "name": "constant.numeric.yue" | ||
| 473 | }, | ||
| 474 | { | ||
| 475 | "match": "\\b0x(((?:\\h|\\h[\\h_]*\\h)(\\.(?:\\h|\\h[\\h_]*\\h))?)|\\.(?:\\h|\\h[\\h_]*\\h))\\b", | ||
| 476 | "name": "constant.numeric.yue" | ||
| 477 | }, | ||
| 478 | { | ||
| 479 | "match": "\\b\\d(?:\\w|\\.|:|::|\\\\)+\\b", | ||
| 480 | "name": "invalid.illegal.yue" | ||
| 481 | } | ||
| 482 | ] | ||
| 483 | }, | ||
| 484 | "builtins": { | ||
| 485 | "patterns": [ | ||
| 486 | { | ||
| 487 | "name": "support.function.library.yue", | ||
| 488 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*(?:lpeg|lpeglabel)(?:(?:\\.|::|\\\\)(?:B|C|Carg|Cb|Cc|Cf|Cg|Cmt|Cp|Cs|Ct|P|R|S|T|V|locale|match|pcode|ptree|setmaxstack|type|utfR|version))?\\b" | ||
| 489 | }, | ||
| 490 | { | ||
| 491 | "name": "support.function.library.yue", | ||
| 492 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*(?:re|relabel)(?:(?:\\.|::|\\\\)(?:calcline|compile|find|gsub|match|updatelocale))?\\b" | ||
| 493 | }, | ||
| 494 | { | ||
| 495 | "name": "support.function.library.yue", | ||
| 496 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*coroutine(?:(?:\\.|::|\\\\)(?:close|create|isyieldable|resume|running|status|wrap|yield))?\\b" | ||
| 497 | }, | ||
| 498 | { | ||
| 499 | "name": "support.function.library.yue", | ||
| 500 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*debug(?:(?:\\.|::|\\\\)(?:debug|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|getuservalue|setcstacklimit|sethook|setlocal|setmetatable|setupvalue|setuservalue|traceback|upvalueid|upvaluejoin))?\\b" | ||
| 501 | }, | ||
| 502 | { | ||
| 503 | "name": "support.function.library.yue", | ||
| 504 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*io(?:(?:\\.|::|\\\\)(?:close|flush|input|lines|open|output|popen|read|stderr|stdin|stdout|tmpfile|type|write))?\\b" | ||
| 505 | }, | ||
| 506 | { | ||
| 507 | "name": "support.function.library.yue", | ||
| 508 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*math(?:(?:\\.|::|\\\\)(?:abs|acos|asin|atan|atan2|ceil|cos|cosh|deg|exp|floor|fmod|frexp|huge|ldexp|log|log10|max|maxinteger|min|mininteger|modf|pi|pow|rad|random|randomseed|sin|sinh|sqrt|tan|tanh|tointeger|type|ult))?\\b" | ||
| 509 | }, | ||
| 510 | { | ||
| 511 | "name": "support.function.library.yue", | ||
| 512 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*os(?:(?:\\.|::|\\\\)(?:clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname))?\\b" | ||
| 513 | }, | ||
| 514 | { | ||
| 515 | "name": "support.function.library.yue", | ||
| 516 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*package(?:(?:\\.|::|\\\\)(?:config|cpath|loaded|loadlib|path|preload|searchers|searchpath))?\\b" | ||
| 517 | }, | ||
| 518 | { | ||
| 519 | "name": "support.function.library.yue", | ||
| 520 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.Date(?:(?:\\.|::|\\\\)(?:Format|Interval|_class|_init|add|cast|catch|class_of|day|diff|hour|is_a|is_weekend|last_day|min|month|month_name|sec|set|toLocal|toUTC|tzone|weekday_name|yday|year))?\\b" | ||
| 521 | }, | ||
| 522 | { | ||
| 523 | "name": "support.function.library.yue", | ||
| 524 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.List(?:(?:\\.|::|\\\\)(?:_class|_create|_init|_name|append|cast|catch|chop|class_of|clear|clone|concat|contains|count|default_map|default_map_with|extend|filter|foreach|foreachm|get|index|insert|is_a|iter|iterate|join|len|map|map2|mapm|minmax|new|partition|pop|push|put|range|reduce|remove|remove_value|reverse|slice|slice_assign|sort|sorted|splice|split|transform))?\\b" | ||
| 525 | }, | ||
| 526 | { | ||
| 527 | "name": "support.function.library.yue", | ||
| 528 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.Map(?:(?:\\.|::|\\\\)(?:_class|_init|_name|cast|catch|class_of|get|getvalues|is_a|items|iter|keys|len|set|setdefault|update|values))?\\b" | ||
| 529 | }, | ||
| 530 | { | ||
| 531 | "name": "support.function.library.yue", | ||
| 532 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.MultiMap(?:(?:\\.|::|\\\\)(?:_base|_class|_init|_name|_parent_with_init|cast|catch|class_of|get|getvalues|is_a|items|iter|keys|len|set|setdefault|update|values))?\\b" | ||
| 533 | }, | ||
| 534 | { | ||
| 535 | "name": "support.function.library.yue", | ||
| 536 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.OrderedMap(?:(?:\\.|::|\\\\)(?:_base|_class|_init|_name|_parent_with_init|cast|catch|class_of|get|getvalues|insert|is_a|items|iter|keys|len|set|setdefault|sort|update|values))?\\b" | ||
| 537 | }, | ||
| 538 | { | ||
| 539 | "name": "support.function.library.yue", | ||
| 540 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.Set(?:(?:\\.|::|\\\\)(?:_base|_class|_init|_name|_parent_with_init|cast|catch|class_of|difference|get|getvalues|intersection|is_a|isdisjoint|isempty|issubset|items|iter|keys|len|map|set|setdefault|symmetric_difference|union|update|values))?\\b" | ||
| 541 | }, | ||
| 542 | { | ||
| 543 | "name": "support.function.library.yue", | ||
| 544 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.app(?:(?:\\.|::|\\\\)(?:appfile|lua|parse_args|platform|require_here|script_name))?\\b" | ||
| 545 | }, | ||
| 546 | { | ||
| 547 | "name": "support.function.library.yue", | ||
| 548 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.array2d(?:(?:\\.|::|\\\\)(?:column|columns|default_range|extract_cols|extract_rows|flatten|forall|iter|map|map2|move|new|parse_range|product|range|reduce2|reduce_cols|reduce_rows|remove_col|remove_row|reshape|row|rows|set|size|slice|swap_cols|swap_rows|transpose|write))?\\b" | ||
| 549 | }, | ||
| 550 | { | ||
| 551 | "name": "support.function.library.yue", | ||
| 552 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.class(?:(?:\\.|::|\\\\)(?:properties))?\\b" | ||
| 553 | }, | ||
| 554 | { | ||
| 555 | "name": "support.function.library.yue", | ||
| 556 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.compat(?:(?:\\.|::|\\\\)(?:dir_separator|execute|getfenv|is_windows|jit|load|lua51|setfenv))?\\b" | ||
| 557 | }, | ||
| 558 | { | ||
| 559 | "name": "support.function.library.yue", | ||
| 560 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.comprehension(?:(?:\\.|::|\\\\)(?:new))?\\b" | ||
| 561 | }, | ||
| 562 | { | ||
| 563 | "name": "support.function.library.yue", | ||
| 564 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.config(?:(?:\\.|::|\\\\)(?:lines|read))?\\b" | ||
| 565 | }, | ||
| 566 | { | ||
| 567 | "name": "support.function.library.yue", | ||
| 568 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.data(?:(?:\\.|::|\\\\)(?:filter|new|query|read|write))?\\b" | ||
| 569 | }, | ||
| 570 | { | ||
| 571 | "name": "support.function.library.yue", | ||
| 572 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.dir(?:(?:\\.|::|\\\\)(?:clonetree|copyfile|dirtree|filter|fnmatch|getallfiles|getdirectories|getfiles|makepath|movefile|rmtree|walk))?\\b" | ||
| 573 | }, | ||
| 574 | { | ||
| 575 | "name": "support.function.library.yue", | ||
| 576 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.file(?:(?:\\.|::|\\\\)(?:access_time|copy|creation_time|delete|modified_time|move|read|write))?\\b" | ||
| 577 | }, | ||
| 578 | { | ||
| 579 | "name": "support.function.library.yue", | ||
| 580 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.func(?:(?:\\.|::|\\\\)(?:And|Args|Eq|Ge|Gt|I|Le|Len|Lt|Nil|Not|Or|PE|Var|_|_0|_1|_2|_3|_4|_5|bind|bind1|collect_values|compose|curry|import|instantiate|isPE|lookup_imported_name|register|repr|tail))?\\b" | ||
| 581 | }, | ||
| 582 | { | ||
| 583 | "name": "support.function.library.yue", | ||
| 584 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.input(?:(?:\\.|::|\\\\)(?:alltokens|create_getter|fields|numbers|words))?\\b" | ||
| 585 | }, | ||
| 586 | { | ||
| 587 | "name": "support.function.library.yue", | ||
| 588 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.lapp(?:(?:\\.|::|\\\\)(?:add_type|assert|callback|error|open|process_options_string|quit|show_usage_error))?\\b" | ||
| 589 | }, | ||
| 590 | { | ||
| 591 | "name": "support.function.library.yue", | ||
| 592 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.lexer(?:(?:\\.|::|\\\\)(?:cpp|expecting|get_keywords|get_separated_list|getline|getrest|insert|lineno|lua|scan|skipws))?\\b" | ||
| 593 | }, | ||
| 594 | { | ||
| 595 | "name": "support.function.library.yue", | ||
| 596 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.luabalanced(?:(?:\\.|::|\\\\)(?:gsub|match_bracketed|match_explist|match_expression|match_namelist|match_string))?\\b" | ||
| 597 | }, | ||
| 598 | { | ||
| 599 | "name": "support.function.library.yue", | ||
| 600 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.operator(?:(?:\\.|::|\\\\)(?:add|call|concat|div|eq|ge|gt|index|land|le|len|lnot|lor|lt|match|mod|mul|neq|nop|optable|pow|sub|table|unm))?\\b" | ||
| 601 | }, | ||
| 602 | { | ||
| 603 | "name": "support.function.library.yue", | ||
| 604 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.path(?:(?:\\.|::|\\\\)(?:abspath|attrib|basename|chdir|common_prefix|currentdir|dir|dirname|dirsep|exists|expanduser|extension|getatime|getctime|getmtime|getsize|is_windows|isabs|isdir|isfile|islink|join|link_attrib|mkdir|normcase|normpath|package_path|relpath|rmdir|sep|splitext|splitpath|tmpname))?\\b" | ||
| 605 | }, | ||
| 606 | { | ||
| 607 | "name": "support.function.library.yue", | ||
| 608 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.permute(?:(?:\\.|::|\\\\)(?:iter|list_iter|list_table|order_iter|order_table|table))?\\b" | ||
| 609 | }, | ||
| 610 | { | ||
| 611 | "name": "support.function.library.yue", | ||
| 612 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.pretty(?:(?:\\.|::|\\\\)(?:debug|dump|load|number|read|write))?\\b" | ||
| 613 | }, | ||
| 614 | { | ||
| 615 | "name": "support.function.library.yue", | ||
| 616 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.seq(?:(?:\\.|::|\\\\)(?:copy|copy2|copy_tuples|count|count_map|enum|equal_to|filter|foreach|greater_than|import|iter|keys|last|less_than|lines|list|map|mapmethod|matching|minmax|printall|random|range|reduce|skip|sort|splice|sum|take|unique|zip))?\\b" | ||
| 617 | }, | ||
| 618 | { | ||
| 619 | "name": "support.function.library.yue", | ||
| 620 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.sip(?:(?:\\.|::|\\\\)(?:compile|create_pattern|create_spec_fun|custom_pattern|fields|match|match_at_start|pattern|read))?\\b" | ||
| 621 | }, | ||
| 622 | { | ||
| 623 | "name": "support.function.library.yue", | ||
| 624 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.strict(?:(?:\\.|::|\\\\)(?:closed_module|make_all_strict|module))?\\b" | ||
| 625 | }, | ||
| 626 | { | ||
| 627 | "name": "support.function.library.yue", | ||
| 628 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.stringio(?:(?:\\.|::|\\\\)(?:create|lines|open))?\\b" | ||
| 629 | }, | ||
| 630 | { | ||
| 631 | "name": "support.function.library.yue", | ||
| 632 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.stringx(?:(?:\\.|::|\\\\)(?:Template|at|capitalize|center|count|dedent|endswith|expandtabs|fill|format_operator|import|indent|isalnum|isalpha|isdigit|islower|isspace|isupper|join|lfind|lines|ljust|lstrip|partition|quote_string|replace|rfind|rjust|rpartition|rstrip|shorten|split|splitlines|splitv|startswith|strip|title|wrap))?\\b" | ||
| 633 | }, | ||
| 634 | { | ||
| 635 | "name": "support.function.library.yue", | ||
| 636 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.tablex(?:(?:\\.|::|\\\\)(?:_normalize_slice|clear|compare|compare_no_order|copy|count_map|deepcompare|deepcopy|difference|filter|find|find_if|foreach|foreachi|icopy|imap|imap2|index_by|index_map|insertvalues|intersection|keys|makeset|map|map2|map_named_method|mapn|merge|move|new|pairmap|range|readonly|reduce|removevalues|rfind|search|set|size|sort|sortv|sub|transform|union|update|values|zip))?\\b" | ||
| 637 | }, | ||
| 638 | { | ||
| 639 | "name": "support.function.library.yue", | ||
| 640 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.template(?:(?:\\.|::|\\\\)(?:compile|substitute))?\\b" | ||
| 641 | }, | ||
| 642 | { | ||
| 643 | "name": "support.function.library.yue", | ||
| 644 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.test(?:(?:\\.|::|\\\\)(?:asserteq|asserteq2|assertmatch|assertraise|complain|error_handler|timer|tuple))?\\b" | ||
| 645 | }, | ||
| 646 | { | ||
| 647 | "name": "support.function.library.yue", | ||
| 648 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.text(?:(?:\\.|::|\\\\)(?:Template|at|capitalize|center|count|dedent|endswith|expandtabs|fill|format_operator|import|indent|isalnum|isalpha|isdigit|islower|isspace|isupper|join|lfind|lines|ljust|lstrip|partition|quote_string|replace|rfind|rjust|rpartition|rstrip|shorten|split|splitlines|splitv|startswith|strip|title|wrap))?\\b" | ||
| 649 | }, | ||
| 650 | { | ||
| 651 | "name": "support.function.library.yue", | ||
| 652 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.types(?:(?:\\.|::|\\\\)(?:is_callable|is_empty|is_indexable|is_integer|is_iterable|is_type|is_writeable|to_bool|type))?\\b" | ||
| 653 | }, | ||
| 654 | { | ||
| 655 | "name": "support.function.library.yue", | ||
| 656 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.url(?:(?:\\.|::|\\\\)(?:quote|unquote))?\\b" | ||
| 657 | }, | ||
| 658 | { | ||
| 659 | "name": "support.function.library.yue", | ||
| 660 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.utils(?:(?:\\.|::|\\\\)(?:_VERSION|add_function_factory|array_tostring|assert_arg|assert_string|bind1|bind2|choose|dir_separator|enum|escape|execute|executeex|fprintf|function_arg|getfenv|import|is_type|is_windows|jit|kpairs|load|lua51|memoize|npairs|on_error|pack|patterns|printf|quit|quote_arg|raise|raise_deprecation|readfile|readlines|set_deprecation_func|setfenv|split|splitv|stdmt|string_lambda|unpack|writefile))?\\b" | ||
| 661 | }, | ||
| 662 | { | ||
| 663 | "name": "support.function.library.yue", | ||
| 664 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*pl\\.xml(?:(?:\\.|::|\\\\)(?:basic_parse|clone|compare|elem|is_tag|new|parse|parsehtml|tags|tostring|walk|xml_escape|xml_unescape))?\\b" | ||
| 665 | }, | ||
| 666 | { | ||
| 667 | "name": "support.function.library.yue", | ||
| 668 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*string(?:(?:\\.|::|\\\\)(?:byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper))?\\b" | ||
| 669 | }, | ||
| 670 | { | ||
| 671 | "name": "support.function.library.yue", | ||
| 672 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*table(?:(?:\\.|::|\\\\)(?:concat|insert|move|pack|remove|sort|unpack))?\\b" | ||
| 673 | }, | ||
| 674 | { | ||
| 675 | "name": "support.function.library.yue", | ||
| 676 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*utf8(?:(?:\\.|::|\\\\)(?:char|charpattern|codepoint|codes|len|offset))?\\b" | ||
| 677 | }, | ||
| 678 | { | ||
| 679 | "name": "support.function.library.yue", | ||
| 680 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*yue(?:(?:\\.|::|\\\\)(?:check|dofile|file_exist|find_modulepath|format|insert_loader|is_ast|loadfile|loadstring|macro_env|options|p|pcall|read_file|to_ast|to_lua|traceback|version|yue_compiled))?\\b" | ||
| 681 | }, | ||
| 682 | { | ||
| 683 | "name": "support.function.library.yue", | ||
| 684 | "match": "\\b(?:_G(?:\\.|:|::|\\\\))*(?:_G|_VERSION|arg|assert|collectgarbage|coroutine|debug|dofile|error|getmetatable|io|ipairs|lfs|load|loadfile|math|next|os|package|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setmetatable|string|table|tonumber|tostring|type|utf8|warn|xpcall)\\b" | ||
| 685 | } | ||
| 686 | ] | ||
| 687 | } | ||
| 688 | } | ||
| 689 | } \ No newline at end of file | ||
diff --git a/doc/docs/.vitepress/theme/components/YueCompiler.vue b/doc/docs/.vitepress/theme/components/YueCompiler.vue index 0b7a530..ff391e5 100755 --- a/doc/docs/.vitepress/theme/components/YueCompiler.vue +++ b/doc/docs/.vitepress/theme/components/YueCompiler.vue | |||
| @@ -142,8 +142,23 @@ const lightPlusHighlightStyle = HighlightStyle.define([ | |||
| 142 | { tag: tags.tagName, color: '#800000' }, | 142 | { tag: tags.tagName, color: '#800000' }, |
| 143 | { tag: tags.attributeName, color: '#e50000' }, | 143 | { tag: tags.attributeName, color: '#e50000' }, |
| 144 | { tag: tags.meta, color: '#666666' }, | 144 | { tag: tags.meta, color: '#666666' }, |
| 145 | { tag: tags.invalid, color: '#cd3131' } | 145 | { tag: tags.invalid, color: '#cd3131' }, |
| 146 | ]) | 146 | // Additional tags for YueScript - ensure all token types have styles |
| 147 | { tag: tags.variableName, color: '#001080' }, | ||
| 148 | { tag: tags.constant(tags.name), color: '#098658' }, | ||
| 149 | { tag: tags.constant(tags.variableName), color: '#098658' }, | ||
| 150 | { tag: tags.constant, color: '#098658' }, | ||
| 151 | { tag: tags.definition(tags.variableName), color: '#001080' }, | ||
| 152 | { tag: tags.modifier, color: '#AF00DB' }, | ||
| 153 | { tag: tags.namespace, color: '#267f99' }, | ||
| 154 | { tag: tags.labelName, color: '#795e26' }, | ||
| 155 | { tag: tags.character, color: '#098658' }, | ||
| 156 | { tag: tags.literal, color: '#098658' }, | ||
| 157 | { tag: tags.bracket, color: '#000000' }, | ||
| 158 | { tag: tags.squareBracket, color: '#000000' }, | ||
| 159 | { tag: tags.paren, color: '#000000' }, | ||
| 160 | { tag: tags.brace, color: '#000000' } | ||
| 161 | ], { fallback: true }) | ||
| 147 | 162 | ||
| 148 | /* shikijs/themes/dark-plus tokenColors */ | 163 | /* shikijs/themes/dark-plus tokenColors */ |
| 149 | const darkPlusHighlightStyle = HighlightStyle.define([ | 164 | const darkPlusHighlightStyle = HighlightStyle.define([ |
| @@ -160,8 +175,23 @@ const darkPlusHighlightStyle = HighlightStyle.define([ | |||
| 160 | { tag: tags.tagName, color: '#569cd6' }, | 175 | { tag: tags.tagName, color: '#569cd6' }, |
| 161 | { tag: tags.attributeName, color: '#9cdcfe' }, | 176 | { tag: tags.attributeName, color: '#9cdcfe' }, |
| 162 | { tag: tags.meta, color: '#d4d4d4' }, | 177 | { tag: tags.meta, color: '#d4d4d4' }, |
| 163 | { tag: tags.invalid, color: '#f44747' } | 178 | { tag: tags.invalid, color: '#f44747' }, |
| 164 | ]) | 179 | // Additional tags for YueScript - ensure all token types have styles |
| 180 | { tag: tags.variableName, color: '#9cdcfe' }, | ||
| 181 | { tag: tags.constant(tags.name), color: '#b5cea8' }, | ||
| 182 | { tag: tags.constant(tags.variableName), color: '#b5cea8' }, | ||
| 183 | { tag: tags.constant, color: '#b5cea8' }, | ||
| 184 | { tag: tags.definition(tags.variableName), color: '#9cdcfe' }, | ||
| 185 | { tag: tags.modifier, color: '#C586C0' }, | ||
| 186 | { tag: tags.namespace, color: '#4ec9b0' }, | ||
| 187 | { tag: tags.labelName, color: '#dcdcaa' }, | ||
| 188 | { tag: tags.character, color: '#b5cea8' }, | ||
| 189 | { tag: tags.literal, color: '#b5cea8' }, | ||
| 190 | { tag: tags.bracket, color: '#d4d4d4' }, | ||
| 191 | { tag: tags.squareBracket, color: '#d4d4d4' }, | ||
| 192 | { tag: tags.paren, color: '#d4d4d4' }, | ||
| 193 | { tag: tags.brace, color: '#d4d4d4' } | ||
| 194 | ], { fallback: true }) | ||
| 165 | 195 | ||
| 166 | export default { | 196 | export default { |
| 167 | props: { | 197 | props: { |
| @@ -273,37 +303,150 @@ export default { | |||
| 273 | return | 303 | return |
| 274 | } | 304 | } |
| 275 | 305 | ||
| 276 | const moonscriptMode = simpleMode({ | 306 | const yuescriptMode = simpleMode({ |
| 277 | start: [ | 307 | start: [ |
| 308 | // Shebang | ||
| 309 | { regex: /^#!.*/, token: 'comment' }, | ||
| 310 | // Multiline string: [=[...]=] with any number of = | ||
| 311 | { regex: /\[(=*)\[/, token: 'string', push: 'luaString' }, | ||
| 312 | // Block comment: --[[...]] (but not ---) | ||
| 278 | { regex: /--\[\[/, token: 'comment', push: 'commentBlock' }, | 313 | { regex: /--\[\[/, token: 'comment', push: 'commentBlock' }, |
| 279 | { regex: /\[\[/, token: 'string', push: 'stringBlock' }, | 314 | // Line comment: -- (but not ---) |
| 280 | { regex: /--.*/, token: 'comment' }, | 315 | { regex: /--(?!-).*/, token: 'comment' }, |
| 281 | { regex: /"(?:[^\\"]|\\.)*"?/, token: 'string' }, | 316 | // Double quoted string with interpolation #{...} |
| 282 | { regex: /'(?:[^\\']|\\.)*'?/, token: 'string' }, | 317 | { regex: /"/, token: 'string', push: 'doubleString' }, |
| 283 | { | 318 | // Single quoted string |
| 284 | regex: /\b(?:class|extends|if|else|elseif|then|for|in|while|until|do|return|break|continue|switch|when|case|default|try|catch|finally|with|import|export|from|as|super|self|true|false|nil|and|or|not)\b/, | 319 | { regex: /'/, token: 'string', push: 'singleString' }, |
| 285 | token: 'keyword' | 320 | // Tag: ::name:: |
| 286 | }, | 321 | { regex: /(::)\s*[a-zA-Z_][a-zA-Z0-9_]*\s*(::)/, token: 'tagName' }, |
| 287 | { regex: /@[a-zA-Z_]\w*/, token: 'variable-2' }, | 322 | // Class definition: class Name extends Base |
| 288 | { regex: /\b[A-Z][\w]*\b/, token: 'typeName' }, | 323 | { regex: /\bclass\b\s+(@?[a-zA-Z$_][\w.]*)?(?:\s+\bextends\b\s+(@?[a-zA-Z$._][\w.]*))?/, token: 'keyword' }, |
| 289 | { | 324 | // Function definition: name: => or name := => or name(params): => |
| 290 | regex: /(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/i, | 325 | { regex: /(@?[a-zA-Z$_]\??[\w$:.]*\s*[:=]\s*(?:\([^)]*\))?\s*[=-]>)/, token: 'function' }, |
| 291 | token: 'number' | 326 | // Destructured assignment: { ... } := or { ... } = |
| 292 | }, | 327 | { regex: /\{\s*[^}]*\}\s*[:=]/, token: 'keyword' }, |
| 293 | { regex: /[+\-/*=<>!]=?|[~^|&%]/, token: 'operator' }, | 328 | // Keywords (must come before operators to catch 'and', 'or', 'in', 'not') |
| 329 | { regex: /\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using)\b(?![:\w])/, token: 'keyword' }, | ||
| 330 | // Control keywords | ||
| 331 | { regex: /\b(?:if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto)\b(?![:\w])/, token: 'keyword' }, | ||
| 332 | { regex: /\b(?:or|and|in|not)\b(?![:\w])/, token: 'keyword' }, | ||
| 333 | // Boolean and nil | ||
| 334 | { regex: /\b(?:true|false|nil)\b(?![:\w])/, token: 'number' }, | ||
| 335 | // Invalid: function/end | ||
| 336 | { regex: /\b(?:function|end)\b(?![:\w])/, token: 'invalid' }, | ||
| 337 | // Invalid: self (deprecated) | ||
| 338 | { regex: /\bself\b(?![:\w])/, token: 'invalid' }, | ||
| 339 | // super keyword | ||
| 340 | { regex: /\bsuper\b(?![:\w])/, token: 'variable' }, | ||
| 341 | // Invalid variables: $$, $@, @@@, standalone $ | ||
| 342 | { regex: /\$\$+/, token: 'invalid' }, | ||
| 343 | { regex: /@@@+/, token: 'invalid' }, | ||
| 344 | { regex: /\$(?!\w)/, token: 'invalid' }, | ||
| 345 | // Special operators: <mode>, <>, <"string">, <'string'>, <word> (invalid) | ||
| 346 | { regex: /<\b(?:mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\b>/, token: 'constant' }, | ||
| 347 | { regex: /<>/, token: 'constant' }, | ||
| 348 | { regex: /<"[^"]*">/, token: 'constant' }, | ||
| 349 | { regex: /<'[^']*'>/, token: 'constant' }, | ||
| 350 | { regex: /<\w+>/, token: 'invalid' }, | ||
| 351 | // Operators (and/or removed since they're keywords, ?? must not match ???) | ||
| 352 | { regex: /(\+|\-|\*|\/|%|\^|\/\/|\||\&|>>|<<|\.\.)=?/, token: 'operator' }, | ||
| 353 | { regex: /\?\?(?!\?)/, token: 'operator' }, | ||
| 354 | { regex: /\[\]\s*=/, token: 'operator' }, | ||
| 355 | { regex: /==|~=|!=|>|>=|<|<=/, token: 'operator' }, | ||
| 356 | { regex: /#|~|\?|!/, token: 'operator' }, | ||
| 357 | { regex: /\|>|=|:=|:(?!:)|,|\b_\b/, token: 'operator' }, | ||
| 358 | { regex: /\.\.\.(?!\.)/, token: 'constant' }, | ||
| 359 | // Invalid: 4+ dots | ||
| 360 | { regex: /\.{4,}/, token: 'invalid' }, | ||
| 361 | // Class name (capitalized) - must come after keywords | ||
| 362 | { regex: /\b[A-Z]\w*\b/, token: 'typeName' }, | ||
| 363 | // Special variables: $variable (preprocessor), @variable (member), @@variable (static) | ||
| 364 | { regex: /\$\b[a-zA-Z_]\w*\b/, token: 'variable-2' }, | ||
| 365 | { regex: /@@(?:(?:\b[a-zA-Z_]\w*)?((?:\.|::|\\)\b[a-zA-Z_]\w*\b)*)?/, token: 'variable-2' }, | ||
| 366 | { regex: /@(?:(?:\b[a-zA-Z_]\w*)?((?:\.|::|\\)\b[a-zA-Z_]\w*\b)*)?/, token: 'variable-2' }, | ||
| 367 | // Magic methods: __class, __base, etc. | ||
| 368 | { regex: /\b__(?:class|base|init|inherited|mode|name|add|sub|mul|div|mod|pow|unm|idiv|band|bor|bxor|bnot|shl|shr|concat|len|eq|lt|le|index|newindex|call|metatable|gc|close|tostring|pairs|ipairs)\b/, token: 'function' }, | ||
| 369 | // Numbers: decimal, hex, with underscores | ||
| 370 | { regex: /\b([\d_]+(\.[\d_]+)?|\.[\d_]+)(e[+\-]?[\d_]+)?\b/i, token: 'number' }, | ||
| 371 | { regex: /\b0x([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_]*[0-9a-fA-F])?)\b/i, token: 'number' }, | ||
| 372 | // Invalid number | ||
| 373 | { regex: /\b\d(?:\w|\.|:|::|\\)+\b/, token: 'invalid' }, | ||
| 374 | // Built-in constants | ||
| 375 | { regex: /\b(?:_ENV|_G|_VERSION|arg)\b(?![:\w])/, token: 'constant' }, | ||
| 376 | // Built-in functions - comprehensive list | ||
| 377 | { regex: /\b(?:_G(?:\\.|:|::|\\))*(?:lpeg|lpeglabel)(?:(?:\\.|::|\\)(?:B|C|Carg|Cb|Cc|Cf|Cg|Cmt|Cp|Cs|Ct|P|R|S|T|V|locale|match|pcode|ptree|setmaxstack|type|utfR|version))?\b/, token: 'function' }, | ||
| 378 | { regex: /\b(?:_G(?:\\.|:|::|\\))*(?:re|relabel)(?:(?:\\.|::|\\)(?:calcline|compile|find|gsub|match|updatelocale))?\b/, token: 'function' }, | ||
| 379 | { regex: /\b(?:_G(?:\\.|:|::|\\))*coroutine(?:(?:\\.|::|\\)(?:close|create|isyieldable|resume|running|status|wrap|yield))?\b/, token: 'function' }, | ||
| 380 | { regex: /\b(?:_G(?:\\.|:|::|\\))*debug(?:(?:\\.|::|\\)(?:debug|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|getuservalue|setcstacklimit|sethook|setlocal|setmetatable|setupvalue|setuservalue|traceback|upvalueid|upvaluejoin))?\b/, token: 'function' }, | ||
| 381 | { regex: /\b(?:_G(?:\\.|:|::|\\))*io(?:(?:\\.|::|\\)(?:close|flush|input|lines|open|output|popen|read|stderr|stdin|stdout|tmpfile|type|write))?\b/, token: 'function' }, | ||
| 382 | { regex: /\b(?:_G(?:\\.|:|::|\\))*math(?:(?:\\.|::|\\)(?:abs|acos|asin|atan|atan2|ceil|cos|cosh|deg|exp|floor|fmod|frexp|huge|ldexp|log|log10|max|maxinteger|min|mininteger|modf|pi|pow|rad|random|randomseed|sin|sinh|sqrt|tan|tanh|tointeger|type|ult))?\b/, token: 'function' }, | ||
| 383 | { regex: /\b(?:_G(?:\\.|:|::|\\))*os(?:(?:\\.|::|\\)(?:clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname))?\b/, token: 'function' }, | ||
| 384 | { regex: /\b(?:_G(?:\\.|:|::|\\))*package(?:(?:\\.|::|\\)(?:config|cpath|loaded|loadlib|path|preload|searchers|searchpath))?\b/, token: 'function' }, | ||
| 385 | { regex: /\b(?:_G(?:\\.|:|::|\\))*string(?:(?:\\.|::|\\)(?:byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper))?\b/, token: 'function' }, | ||
| 386 | { regex: /\b(?:_G(?:\\.|:|::|\\))*table(?:(?:\\.|::|\\)(?:concat|insert|move|pack|remove|sort|unpack))?\b/, token: 'function' }, | ||
| 387 | { regex: /\b(?:_G(?:\\.|:|::|\\))*utf8(?:(?:\\.|::|\\)(?:char|charpattern|codepoint|codes|len|offset))?\b/, token: 'function' }, | ||
| 388 | { regex: /\b(?:_G(?:\\.|:|::|\\))*yue(?:(?:\\.|::|\\)(?:check|dofile|file_exist|find_modulepath|format|insert_loader|is_ast|loadfile|loadstring|macro_env|options|p|pcall|read_file|to_ast|to_lua|traceback|version|yue_compiled))?\b/, token: 'function' }, | ||
| 389 | { regex: /\b(?:_G(?:\\.|:|::|\\))*(?:assert|collectgarbage|dofile|error|getmetatable|ipairs|lfs|load|loadfile|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setmetatable|tonumber|tostring|type|warn|xpcall)\b/, token: 'function' }, | ||
| 390 | // pl.* library functions (penlight) | ||
| 391 | { regex: /\b(?:_G(?:\\.|:|::|\\))*pl\.(?:Date|List|Map|MultiMap|OrderedMap|Set|app|array2d|class|compat|comprehension|config|data|dir|file|func|input|lapp|lexer|luabalanced|operator|path|permute|pretty|seq|sip|strict|stringio|stringx|tablex|template|test|text|types|url|utils|xml)(?:(?:\\.|::|\\)\w+)?\b/, token: 'function' }, | ||
| 392 | // Arrow functions: (params) => or <= name | ||
| 393 | { regex: /\([^)]*\)\s*[=-]>/, token: 'operator' }, | ||
| 394 | { regex: /\([^)]*\)?\s*<[=-]\s*(?=[a-zA-Z_])/, token: 'operator' }, | ||
| 395 | // new keyword before arrow function | ||
| 396 | { regex: /\bnew\b(?=:\s*\([^)]*\)?\s*[=-]>)/, token: 'variable' }, | ||
| 397 | // Brackets and delimiters | ||
| 294 | { regex: /[()\[\]{}]/, token: 'bracket' }, | 398 | { regex: /[()\[\]{}]/, token: 'bracket' }, |
| 295 | { regex: /[a-zA-Z_]\w*/, token: 'variable' } | 399 | { regex: /\.|::|\\/, token: 'operator' }, |
| 400 | // Variable names (with dot notation support) | ||
| 401 | { regex: /[a-zA-Z_$][\w$]*(?:(?:\.|::|\\)[a-zA-Z_$][\w$]*)*/, token: 'variable' } | ||
| 296 | ], | 402 | ], |
| 297 | commentBlock: [ | 403 | commentBlock: [ |
| 298 | { regex: /.*?\]\]/, token: 'comment', pop: true }, | 404 | { regex: /.*?\]\]/, token: 'comment', pop: true }, |
| 405 | { regex: /@\w*/, token: 'typeName' }, | ||
| 299 | { regex: /.*/, token: 'comment' } | 406 | { regex: /.*/, token: 'comment' } |
| 300 | ], | 407 | ], |
| 301 | stringBlock: [ | 408 | luaString: [ |
| 302 | { regex: /.*?\]\]/, token: 'string', pop: true }, | 409 | // Match closing ]=] where number of = matches opening |
| 410 | // This is a simplified version - matches ]=] with 0 or more = | ||
| 411 | { regex: /\](=*)\]/, token: 'string', pop: true }, | ||
| 303 | { regex: /.*/, token: 'string' } | 412 | { regex: /.*/, token: 'string' } |
| 304 | ], | 413 | ], |
| 414 | doubleString: [ | ||
| 415 | { regex: /"/, token: 'string', pop: true }, | ||
| 416 | { regex: /\\[abfnrtvz\\'"]/, token: 'constant' }, | ||
| 417 | { regex: /\\\d{1,3}/, token: 'constant' }, | ||
| 418 | { regex: /\\x[0-9a-fA-F]{2}/, token: 'constant' }, | ||
| 419 | { regex: /\\u\{[0-9a-fA-F]+\}/, token: 'constant' }, | ||
| 420 | { regex: /\\\./, token: 'invalid' }, | ||
| 421 | { regex: /#\{/, token: 'operator', push: 'interpolation' }, | ||
| 422 | { regex: /%[%aAcdeEfgiopsuxX]/, token: 'constant' }, | ||
| 423 | { regex: /[^"\\#%]+/, token: 'string' } | ||
| 424 | ], | ||
| 425 | singleString: [ | ||
| 426 | { regex: /'/, token: 'string', pop: true }, | ||
| 427 | { regex: /\\[abfnrtvz\\']/, token: 'string' }, | ||
| 428 | { regex: /\\\d{1,3}/, token: 'string' }, | ||
| 429 | { regex: /\\x[0-9a-fA-F]{2}/, token: 'string' }, | ||
| 430 | { regex: /\\u\{[0-9a-fA-F]+\}/, token: 'string' }, | ||
| 431 | { regex: /\\\./, token: 'invalid' }, | ||
| 432 | { regex: /%[%aAcdeEfgiopsuxX]/, token: 'constant' }, | ||
| 433 | { regex: /[^'\\%]+/, token: 'string' } | ||
| 434 | ], | ||
| 435 | interpolation: [ | ||
| 436 | { regex: /\}/, token: 'operator', pop: true }, | ||
| 437 | { regex: /\{/, token: 'operator', push: 'interpolation' }, | ||
| 438 | { regex: /"(?:[^\\"]|\\.)*"?/, token: 'string' }, | ||
| 439 | { regex: /'(?:[^\\']|\\.)*'?/, token: 'string' }, | ||
| 440 | { regex: /\b(?:import|as|from|export|macro|local|global|close|const|class|extends|using|if|then|else|elseif|until|unless|switch|when|with|do|for|while|repeat|return|continue|break|try|catch|goto|or|and|in|not|true|false|nil)\b/, token: 'keyword' }, | ||
| 441 | { regex: /\b[A-Z]\w*\b/, token: 'typeName' }, | ||
| 442 | { regex: /[a-zA-Z_$][\w$]*/, token: 'variable' }, | ||
| 443 | { regex: /(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/i, token: 'number' }, | ||
| 444 | { regex: /[+\-/*=<>!]=?|[~^|&%]/, token: 'operator' }, | ||
| 445 | { regex: /[()\[\]{}]/, token: 'bracket' }, | ||
| 446 | { regex: /[^}]/, token: 'variable' } | ||
| 447 | ], | ||
| 305 | languageData: { | 448 | languageData: { |
| 306 | name: 'moonscript' | 449 | name: 'yuescript' |
| 307 | } | 450 | } |
| 308 | }) | 451 | }) |
| 309 | 452 | ||
| @@ -327,7 +470,7 @@ export default { | |||
| 327 | lineNumbers(), | 470 | lineNumbers(), |
| 328 | history(), | 471 | history(), |
| 329 | keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]), | 472 | keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]), |
| 330 | StreamLanguage.define(moonscriptMode), | 473 | StreamLanguage.define(yuescriptMode), |
| 331 | indentUnit.of(' '), | 474 | indentUnit.of(' '), |
| 332 | this.readOnlyCompartment.of(EditorState.readOnly.of(this.readonly)), | 475 | this.readOnlyCompartment.of(EditorState.readOnly.of(this.readonly)), |
| 333 | this.highlightCompartment.of( | 476 | this.highlightCompartment.of( |
diff --git a/doc/docs/doc/destructuring-assignment.md b/doc/docs/doc/destructuring-assignment.md index 8967eb3..e7b8046 100644 --- a/doc/docs/doc/destructuring-assignment.md +++ b/doc/docs/doc/destructuring-assignment.md | |||
| @@ -79,7 +79,7 @@ obj2 = { | |||
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | {numbers: [first, second]} = obj2 | 82 | {numbers: [first, second], properties: {color: color}} = obj2 |
| 83 | print first, second, color | 83 | print first, second, color |
| 84 | ``` | 84 | ``` |
| 85 | 85 | ||
diff --git a/doc/docs/doc/macro.md b/doc/docs/doc/macro.md index 917c20e..6d194c3 100644 --- a/doc/docs/doc/macro.md +++ b/doc/docs/doc/macro.md | |||
| @@ -148,6 +148,7 @@ export macro map = (items, action) -> "[#{action} for _ in *#{items}]" | |||
| 148 | export macro filter = (items, action) -> "[_ for _ in *#{items} when #{action}]" | 148 | export macro filter = (items, action) -> "[_ for _ in *#{items} when #{action}]" |
| 149 | export macro foreach = (items, action) -> "for _ in *#{items} | 149 | export macro foreach = (items, action) -> "for _ in *#{items} |
| 150 | #{action}" | 150 | #{action}" |
| 151 | |||
| 151 | -- file main.yue | 152 | -- file main.yue |
| 152 | -- import function is not available in browser, try it in a real environment | 153 | -- import function is not available in browser, try it in a real environment |
| 153 | --[[ | 154 | --[[ |
diff --git a/doc/docs/zh/doc/destructuring-assignment.md b/doc/docs/zh/doc/destructuring-assignment.md index 205a1ff..29219d3 100644 --- a/doc/docs/zh/doc/destructuring-assignment.md +++ b/doc/docs/zh/doc/destructuring-assignment.md | |||
| @@ -80,7 +80,7 @@ obj2 = { | |||
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | {numbers: [first, second]} = obj2 | 83 | {numbers: [first, second], properties: {color: color}} = obj2 |
| 84 | print first, second, color | 84 | print first, second, color |
| 85 | ``` | 85 | ``` |
| 86 | 86 | ||
diff --git a/doc/docs/zh/doc/macro.md b/doc/docs/zh/doc/macro.md index 924b3ab..91be42c 100644 --- a/doc/docs/zh/doc/macro.md +++ b/doc/docs/zh/doc/macro.md | |||
| @@ -150,6 +150,7 @@ export macro map = (items, action) -> "[#{action} for _ in *#{items}]" | |||
| 150 | export macro filter = (items, action) -> "[_ for _ in *#{items} when #{action}]" | 150 | export macro filter = (items, action) -> "[_ for _ in *#{items} when #{action}]" |
| 151 | export macro foreach = (items, action) -> "for _ in *#{items} | 151 | export macro foreach = (items, action) -> "for _ in *#{items} |
| 152 | #{action}" | 152 | #{action}" |
| 153 | |||
| 153 | -- 文件 main.yue | 154 | -- 文件 main.yue |
| 154 | -- 在浏览器中不支持import函数,请在真实环境中尝试 | 155 | -- 在浏览器中不支持import函数,请在真实环境中尝试 |
| 155 | --[[ | 156 | --[[ |
