scheme.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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/scheme/scheme.ts
  8. var conf = {
  9. comments: {
  10. lineComment: ";",
  11. blockComment: ["#|", "|#"]
  12. },
  13. brackets: [
  14. ["(", ")"],
  15. ["{", "}"],
  16. ["[", "]"]
  17. ],
  18. autoClosingPairs: [
  19. { open: "{", close: "}" },
  20. { open: "[", close: "]" },
  21. { open: "(", close: ")" },
  22. { open: '"', close: '"' }
  23. ],
  24. surroundingPairs: [
  25. { open: "{", close: "}" },
  26. { open: "[", close: "]" },
  27. { open: "(", close: ")" },
  28. { open: '"', close: '"' }
  29. ]
  30. };
  31. var language = {
  32. defaultToken: "",
  33. ignoreCase: true,
  34. tokenPostfix: ".scheme",
  35. brackets: [
  36. { open: "(", close: ")", token: "delimiter.parenthesis" },
  37. { open: "{", close: "}", token: "delimiter.curly" },
  38. { open: "[", close: "]", token: "delimiter.square" }
  39. ],
  40. keywords: [
  41. "case",
  42. "do",
  43. "let",
  44. "loop",
  45. "if",
  46. "else",
  47. "when",
  48. "cons",
  49. "car",
  50. "cdr",
  51. "cond",
  52. "lambda",
  53. "lambda*",
  54. "syntax-rules",
  55. "format",
  56. "set!",
  57. "quote",
  58. "eval",
  59. "append",
  60. "list",
  61. "list?",
  62. "member?",
  63. "load"
  64. ],
  65. constants: ["#t", "#f"],
  66. operators: ["eq?", "eqv?", "equal?", "and", "or", "not", "null?"],
  67. tokenizer: {
  68. root: [
  69. [/#[xXoObB][0-9a-fA-F]+/, "number.hex"],
  70. [/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?/, "number.float"],
  71. [
  72. /(?:\b(?:(define|define-syntax|define-macro))\b)(\s+)((?:\w|\-|\!|\?)*)/,
  73. ["keyword", "white", "variable"]
  74. ],
  75. { include: "@whitespace" },
  76. { include: "@strings" },
  77. [
  78. /[a-zA-Z_#][a-zA-Z0-9_\-\?\!\*]*/,
  79. {
  80. cases: {
  81. "@keywords": "keyword",
  82. "@constants": "constant",
  83. "@operators": "operators",
  84. "@default": "identifier"
  85. }
  86. }
  87. ]
  88. ],
  89. comment: [
  90. [/[^\|#]+/, "comment"],
  91. [/#\|/, "comment", "@push"],
  92. [/\|#/, "comment", "@pop"],
  93. [/[\|#]/, "comment"]
  94. ],
  95. whitespace: [
  96. [/[ \t\r\n]+/, "white"],
  97. [/#\|/, "comment", "@comment"],
  98. [/;.*$/, "comment"]
  99. ],
  100. strings: [
  101. [/"$/, "string", "@popall"],
  102. [/"(?=.)/, "string", "@multiLineString"]
  103. ],
  104. multiLineString: [
  105. [/[^\\"]+$/, "string", "@popall"],
  106. [/[^\\"]+/, "string"],
  107. [/\\./, "string.escape"],
  108. [/"/, "string", "@popall"],
  109. [/\\$/, "string"]
  110. ]
  111. }
  112. };
  113. export {
  114. conf,
  115. language
  116. };