sb.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. // src/basic-languages/sb/sb.ts
  8. var conf = {
  9. comments: {
  10. lineComment: "'"
  11. },
  12. brackets: [
  13. ["(", ")"],
  14. ["[", "]"],
  15. ["If", "EndIf"],
  16. ["While", "EndWhile"],
  17. ["For", "EndFor"],
  18. ["Sub", "EndSub"]
  19. ],
  20. autoClosingPairs: [
  21. { open: '"', close: '"', notIn: ["string", "comment"] },
  22. { open: "(", close: ")", notIn: ["string", "comment"] },
  23. { open: "[", close: "]", notIn: ["string", "comment"] }
  24. ]
  25. };
  26. var language = {
  27. defaultToken: "",
  28. tokenPostfix: ".sb",
  29. ignoreCase: true,
  30. brackets: [
  31. { token: "delimiter.array", open: "[", close: "]" },
  32. { token: "delimiter.parenthesis", open: "(", close: ")" },
  33. { token: "keyword.tag-if", open: "If", close: "EndIf" },
  34. { token: "keyword.tag-while", open: "While", close: "EndWhile" },
  35. { token: "keyword.tag-for", open: "For", close: "EndFor" },
  36. { token: "keyword.tag-sub", open: "Sub", close: "EndSub" }
  37. ],
  38. keywords: [
  39. "Else",
  40. "ElseIf",
  41. "EndFor",
  42. "EndIf",
  43. "EndSub",
  44. "EndWhile",
  45. "For",
  46. "Goto",
  47. "If",
  48. "Step",
  49. "Sub",
  50. "Then",
  51. "To",
  52. "While"
  53. ],
  54. tagwords: ["If", "Sub", "While", "For"],
  55. operators: [">", "<", "<>", "<=", ">=", "And", "Or", "+", "-", "*", "/", "="],
  56. identifier: /[a-zA-Z_][\w]*/,
  57. symbols: /[=><:+\-*\/%\.,]+/,
  58. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  59. tokenizer: {
  60. root: [
  61. { include: "@whitespace" },
  62. [/(@identifier)(?=[.])/, "type"],
  63. [
  64. /@identifier/,
  65. {
  66. cases: {
  67. "@keywords": { token: "keyword.$0" },
  68. "@operators": "operator",
  69. "@default": "variable.name"
  70. }
  71. }
  72. ],
  73. [
  74. /([.])(@identifier)/,
  75. {
  76. cases: {
  77. $2: ["delimiter", "type.member"],
  78. "@default": ""
  79. }
  80. }
  81. ],
  82. [/\d*\.\d+/, "number.float"],
  83. [/\d+/, "number"],
  84. [/[()\[\]]/, "@brackets"],
  85. [
  86. /@symbols/,
  87. {
  88. cases: {
  89. "@operators": "operator",
  90. "@default": "delimiter"
  91. }
  92. }
  93. ],
  94. [/"([^"\\]|\\.)*$/, "string.invalid"],
  95. [/"/, "string", "@string"]
  96. ],
  97. whitespace: [
  98. [/[ \t\r\n]+/, ""],
  99. [/(\').*$/, "comment"]
  100. ],
  101. string: [
  102. [/[^\\"]+/, "string"],
  103. [/@escapes/, "string.escape"],
  104. [/\\./, "string.escape.invalid"],
  105. [/"C?/, "string", "@pop"]
  106. ]
  107. }
  108. };
  109. export {
  110. conf,
  111. language
  112. };