cameligo.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. ],
  16. autoClosingPairs: [
  17. { open: '{', close: '}' },
  18. { open: '[', close: ']' },
  19. { open: '(', close: ')' },
  20. { open: '<', close: '>' },
  21. { open: "'", close: "'" },
  22. { open: "\"", close: "\"" },
  23. { open: "(*", close: "*)" },
  24. ],
  25. surroundingPairs: [
  26. { open: '{', close: '}' },
  27. { open: '[', close: ']' },
  28. { open: '(', close: ')' },
  29. { open: '<', close: '>' },
  30. { open: "'", close: "'" },
  31. { open: "\"", close: "\"" },
  32. { open: "(*", close: "*)" },
  33. ]
  34. };
  35. export var language = {
  36. defaultToken: '',
  37. tokenPostfix: '.cameligo',
  38. ignoreCase: true,
  39. brackets: [
  40. { open: '{', close: '}', token: 'delimiter.curly' },
  41. { open: '[', close: ']', token: 'delimiter.square' },
  42. { open: '(', close: ')', token: 'delimiter.parenthesis' },
  43. { open: '<', close: '>', token: 'delimiter.angle' }
  44. ],
  45. keywords: [
  46. 'abs',
  47. 'assert',
  48. 'block',
  49. 'Bytes',
  50. 'case',
  51. 'Crypto',
  52. 'Current',
  53. 'else',
  54. 'failwith',
  55. 'false',
  56. 'for',
  57. 'fun',
  58. 'if',
  59. 'in',
  60. 'let',
  61. 'let%entry',
  62. 'let%init',
  63. 'List',
  64. 'list',
  65. 'Map',
  66. 'map',
  67. 'match',
  68. 'match%nat',
  69. 'mod',
  70. 'not',
  71. 'operation',
  72. 'Operation',
  73. 'of',
  74. 'record',
  75. 'Set',
  76. 'set',
  77. 'sender',
  78. 'skip',
  79. 'source',
  80. 'String',
  81. 'then',
  82. 'to',
  83. 'true',
  84. 'type',
  85. 'with',
  86. ],
  87. typeKeywords: ['int', 'unit', 'string', 'tz', 'nat', 'bool'],
  88. operators: [
  89. '=',
  90. '>',
  91. '<',
  92. '<=',
  93. '>=',
  94. '<>',
  95. ':',
  96. ':=',
  97. 'and',
  98. 'mod',
  99. 'or',
  100. '+',
  101. '-',
  102. '*',
  103. '/',
  104. '@',
  105. '&',
  106. '^',
  107. '%',
  108. '->',
  109. '<-',
  110. '&&',
  111. '||',
  112. ],
  113. // we include these common regular expressions
  114. symbols: /[=><:@\^&|+\-*\/\^%]+/,
  115. // The main tokenizer for our languages
  116. tokenizer: {
  117. root: [
  118. // identifiers and keywords
  119. [
  120. /[a-zA-Z_][\w]*/,
  121. {
  122. cases: {
  123. '@keywords': { token: 'keyword.$0' },
  124. '@default': 'identifier'
  125. }
  126. }
  127. ],
  128. // whitespace
  129. { include: '@whitespace' },
  130. // delimiters and operators
  131. [/[{}()\[\]]/, '@brackets'],
  132. [/[<>](?!@symbols)/, '@brackets'],
  133. [
  134. /@symbols/,
  135. {
  136. cases: {
  137. '@operators': 'delimiter',
  138. '@default': ''
  139. }
  140. }
  141. ],
  142. // numbers
  143. [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
  144. [/\$[0-9a-fA-F]{1,16}/, 'number.hex'],
  145. [/\d+/, 'number'],
  146. // delimiter: after number because of .\d floats
  147. [/[;,.]/, 'delimiter'],
  148. // strings
  149. [/'([^'\\]|\\.)*$/, 'string.invalid'],
  150. [/'/, 'string', '@string'],
  151. // characters
  152. [/'[^\\']'/, 'string'],
  153. [/'/, 'string.invalid'],
  154. [/\#\d+/, 'string']
  155. ],
  156. /* */
  157. comment: [
  158. [/[^\(\*]+/, 'comment'],
  159. //[/\(\*/, 'comment', '@push' ], // nested comment not allowed :-(
  160. [/\*\)/, 'comment', '@pop'],
  161. [/\(\*/, 'comment']
  162. ],
  163. string: [
  164. [/[^\\']+/, 'string'],
  165. [/\\./, 'string.escape.invalid'],
  166. [/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
  167. ],
  168. whitespace: [
  169. [/[ \t\r\n]+/, 'white'],
  170. [/\(\*/, 'comment', '@comment'],
  171. [/\/\/.*$/, 'comment']
  172. ]
  173. }
  174. };