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