lua.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.31.1(337587859b1c171314b40503171188b6cea6a32a)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. define("vs/basic-languages/lua/lua",[],()=>{
  8. var moduleExports = (() => {
  9. var __defProp = Object.defineProperty;
  10. var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
  11. var __export = (target, all) => {
  12. __markAsModule(target);
  13. for (var name in all)
  14. __defProp(target, name, { get: all[name], enumerable: true });
  15. };
  16. // src/basic-languages/lua/lua.ts
  17. var lua_exports = {};
  18. __export(lua_exports, {
  19. conf: () => conf,
  20. language: () => language
  21. });
  22. var conf = {
  23. comments: {
  24. lineComment: "--",
  25. blockComment: ["--[[", "]]"]
  26. },
  27. brackets: [
  28. ["{", "}"],
  29. ["[", "]"],
  30. ["(", ")"]
  31. ],
  32. autoClosingPairs: [
  33. { open: "{", close: "}" },
  34. { open: "[", close: "]" },
  35. { open: "(", close: ")" },
  36. { open: '"', close: '"' },
  37. { open: "'", close: "'" }
  38. ],
  39. surroundingPairs: [
  40. { open: "{", close: "}" },
  41. { open: "[", close: "]" },
  42. { open: "(", close: ")" },
  43. { open: '"', close: '"' },
  44. { open: "'", close: "'" }
  45. ]
  46. };
  47. var language = {
  48. defaultToken: "",
  49. tokenPostfix: ".lua",
  50. keywords: [
  51. "and",
  52. "break",
  53. "do",
  54. "else",
  55. "elseif",
  56. "end",
  57. "false",
  58. "for",
  59. "function",
  60. "goto",
  61. "if",
  62. "in",
  63. "local",
  64. "nil",
  65. "not",
  66. "or",
  67. "repeat",
  68. "return",
  69. "then",
  70. "true",
  71. "until",
  72. "while"
  73. ],
  74. brackets: [
  75. { token: "delimiter.bracket", open: "{", close: "}" },
  76. { token: "delimiter.array", open: "[", close: "]" },
  77. { token: "delimiter.parenthesis", open: "(", close: ")" }
  78. ],
  79. operators: [
  80. "+",
  81. "-",
  82. "*",
  83. "/",
  84. "%",
  85. "^",
  86. "#",
  87. "==",
  88. "~=",
  89. "<=",
  90. ">=",
  91. "<",
  92. ">",
  93. "=",
  94. ";",
  95. ":",
  96. ",",
  97. ".",
  98. "..",
  99. "..."
  100. ],
  101. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  102. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  103. tokenizer: {
  104. root: [
  105. [
  106. /[a-zA-Z_]\w*/,
  107. {
  108. cases: {
  109. "@keywords": { token: "keyword.$0" },
  110. "@default": "identifier"
  111. }
  112. }
  113. ],
  114. { include: "@whitespace" },
  115. [/(,)(\s*)([a-zA-Z_]\w*)(\s*)(:)(?!:)/, ["delimiter", "", "key", "", "delimiter"]],
  116. [/({)(\s*)([a-zA-Z_]\w*)(\s*)(:)(?!:)/, ["@brackets", "", "key", "", "delimiter"]],
  117. [/[{}()\[\]]/, "@brackets"],
  118. [
  119. /@symbols/,
  120. {
  121. cases: {
  122. "@operators": "delimiter",
  123. "@default": ""
  124. }
  125. }
  126. ],
  127. [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float"],
  128. [/0[xX][0-9a-fA-F_]*[0-9a-fA-F]/, "number.hex"],
  129. [/\d+?/, "number"],
  130. [/[;,.]/, "delimiter"],
  131. [/"([^"\\]|\\.)*$/, "string.invalid"],
  132. [/'([^'\\]|\\.)*$/, "string.invalid"],
  133. [/"/, "string", '@string."'],
  134. [/'/, "string", "@string.'"]
  135. ],
  136. whitespace: [
  137. [/[ \t\r\n]+/, ""],
  138. [/--\[([=]*)\[/, "comment", "@comment.$1"],
  139. [/--.*$/, "comment"]
  140. ],
  141. comment: [
  142. [/[^\]]+/, "comment"],
  143. [
  144. /\]([=]*)\]/,
  145. {
  146. cases: {
  147. "$1==$S2": { token: "comment", next: "@pop" },
  148. "@default": "comment"
  149. }
  150. }
  151. ],
  152. [/./, "comment"]
  153. ],
  154. string: [
  155. [/[^\\"']+/, "string"],
  156. [/@escapes/, "string.escape"],
  157. [/\\./, "string.escape.invalid"],
  158. [
  159. /["']/,
  160. {
  161. cases: {
  162. "$#==$S2": { token: "string", next: "@pop" },
  163. "@default": "string"
  164. }
  165. }
  166. ]
  167. ]
  168. }
  169. };
  170. return lua_exports;
  171. })();
  172. return moduleExports;
  173. });