sophia.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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('vs/basic-languages/sophia/sophia',["require", "exports"], function (require, exports) {
  6. "use strict";
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.language = exports.conf = void 0;
  9. exports.conf = {
  10. comments: {
  11. lineComment: '//',
  12. blockComment: ['/*', '*/']
  13. },
  14. brackets: [
  15. ['{', '}'],
  16. ['[', ']'],
  17. ['(', ')'],
  18. ['<', '>']
  19. ],
  20. autoClosingPairs: [
  21. { open: '"', close: '"', notIn: ['string', 'comment'] },
  22. { open: '{', close: '}', notIn: ['string', 'comment'] },
  23. { open: '[', close: ']', notIn: ['string', 'comment'] },
  24. { open: '(', close: ')', notIn: ['string', 'comment'] }
  25. ]
  26. };
  27. exports.language = {
  28. defaultToken: '',
  29. tokenPostfix: '.aes',
  30. brackets: [
  31. { token: 'delimiter.curly', open: '{', close: '}' },
  32. { token: 'delimiter.parenthesis', open: '(', close: ')' },
  33. { token: 'delimiter.square', open: '[', close: ']' },
  34. { token: 'delimiter.angle', open: '<', close: '>' }
  35. ],
  36. keywords: [
  37. // Main keywords
  38. 'contract',
  39. 'library',
  40. 'entrypoint',
  41. 'function',
  42. 'stateful',
  43. 'state',
  44. 'hash',
  45. 'signature',
  46. 'tuple',
  47. 'list',
  48. 'address',
  49. 'string',
  50. 'bool',
  51. 'int',
  52. 'record',
  53. 'datatype',
  54. 'type',
  55. 'option',
  56. 'oracle',
  57. 'oracle_query',
  58. 'Call',
  59. 'Bits',
  60. 'Bytes',
  61. 'Oracle',
  62. 'String',
  63. 'Crypto',
  64. 'Address',
  65. 'Auth',
  66. 'Chain',
  67. 'None',
  68. 'Some',
  69. 'bits',
  70. 'bytes',
  71. 'event',
  72. 'let',
  73. 'map',
  74. 'private',
  75. 'public',
  76. 'true',
  77. 'false',
  78. 'var',
  79. 'if',
  80. 'else',
  81. 'throw'
  82. ],
  83. operators: [
  84. '=',
  85. '>',
  86. '<',
  87. '!',
  88. '~',
  89. '?',
  90. '::',
  91. ':',
  92. '==',
  93. '<=',
  94. '>=',
  95. '!=',
  96. '&&',
  97. '||',
  98. '++',
  99. '--',
  100. '+',
  101. '-',
  102. '*',
  103. '/',
  104. '&',
  105. '|',
  106. '^',
  107. '%',
  108. '<<',
  109. '>>',
  110. '>>>',
  111. '+=',
  112. '-=',
  113. '*=',
  114. '/=',
  115. '&=',
  116. '|=',
  117. '^=',
  118. '%=',
  119. '<<=',
  120. '>>=',
  121. '>>>='
  122. ],
  123. // we include these common regular expressions
  124. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  125. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  126. integersuffix: /(ll|LL|u|U|l|L)?(ll|LL|u|U|l|L)?/,
  127. floatsuffix: /[fFlL]?/,
  128. // The main tokenizer for our languages
  129. tokenizer: {
  130. root: [
  131. // identifiers and keywords
  132. [
  133. /[a-zA-Z_]\w*/,
  134. {
  135. cases: {
  136. '@keywords': { token: 'keyword.$0' },
  137. '@default': 'identifier'
  138. }
  139. }
  140. ],
  141. // whitespace
  142. { include: '@whitespace' },
  143. // [[ attributes ]].
  144. [/\[\[.*\]\]/, 'annotation'],
  145. // Preprocessor directive
  146. [/^\s*#\w+/, 'keyword'],
  147. //DataTypes
  148. [/int\d*/, 'keyword'],
  149. // delimiters and operators
  150. [/[{}()\[\]]/, '@brackets'],
  151. [/[<>](?!@symbols)/, '@brackets'],
  152. [
  153. /@symbols/,
  154. {
  155. cases: {
  156. '@operators': 'delimiter',
  157. '@default': ''
  158. }
  159. }
  160. ],
  161. // numbers
  162. [/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/, 'number.float'],
  163. [/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/, 'number.float'],
  164. [/0[xX][0-9a-fA-F']*[0-9a-fA-F](@integersuffix)/, 'number.hex'],
  165. [/0[0-7']*[0-7](@integersuffix)/, 'number.octal'],
  166. [/0[bB][0-1']*[0-1](@integersuffix)/, 'number.binary'],
  167. [/\d[\d']*\d(@integersuffix)/, 'number'],
  168. [/\d(@integersuffix)/, 'number'],
  169. // delimiter: after number because of .\d floats
  170. [/[;,.]/, 'delimiter'],
  171. // strings
  172. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  173. [/"/, 'string', '@string'],
  174. // characters
  175. [/'[^\\']'/, 'string'],
  176. [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
  177. [/'/, 'string.invalid']
  178. ],
  179. whitespace: [
  180. [/[ \t\r\n]+/, ''],
  181. [/\/\*\*(?!\/)/, 'comment.doc', '@doccomment'],
  182. [/\/\*/, 'comment', '@comment'],
  183. [/\/\/.*$/, 'comment']
  184. ],
  185. comment: [
  186. [/[^\/*]+/, 'comment'],
  187. [/\*\//, 'comment', '@pop'],
  188. [/[\/*]/, 'comment']
  189. ],
  190. //Identical copy of comment above, except for the addition of .doc
  191. doccomment: [
  192. [/[^\/*]+/, 'comment.doc'],
  193. [/\*\//, 'comment.doc', '@pop'],
  194. [/[\/*]/, 'comment.doc']
  195. ],
  196. string: [
  197. [/[^\\"]+/, 'string'],
  198. [/@escapes/, 'string.escape'],
  199. [/\\./, 'string.escape.invalid'],
  200. [/"/, 'string', '@pop']
  201. ]
  202. }
  203. };
  204. });