sb.js 3.6 KB

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