scheme.js 3.6 KB

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