cameligo.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. ['{', '}'],
  15. ['[', ']'],
  16. ['(', ')'],
  17. ['<', '>'],
  18. ],
  19. autoClosingPairs: [
  20. { open: '{', close: '}' },
  21. { open: '[', close: ']' },
  22. { open: '(', close: ')' },
  23. { open: '<', close: '>' },
  24. { open: '\'', close: '\'' },
  25. ],
  26. surroundingPairs: [
  27. { open: '{', close: '}' },
  28. { open: '[', close: ']' },
  29. { open: '(', close: ')' },
  30. { open: '<', close: '>' },
  31. { open: '\'', close: '\'' },
  32. ]
  33. };
  34. exports.language = {
  35. defaultToken: '',
  36. tokenPostfix: '.cameligo',
  37. ignoreCase: true,
  38. brackets: [
  39. { open: '{', close: '}', token: 'delimiter.curly' },
  40. { open: '[', close: ']', token: 'delimiter.square' },
  41. { open: '(', close: ')', token: 'delimiter.parenthesis' },
  42. { open: '<', close: '>', token: 'delimiter.angle' }
  43. ],
  44. keywords: [
  45. 'abs', 'begin', 'Bytes', 'Crypto', 'Current', 'else', 'end', 'failwith',
  46. 'false', 'fun', 'if', 'in', 'let', 'let%entry', 'let%init', 'List', 'list',
  47. 'Map', 'map', 'match', 'match%nat', 'mod', 'not', 'operation', 'Operation', 'of',
  48. 'Set', 'set', 'sender', 'source', 'String', 'then', 'true', 'type', 'with',
  49. ],
  50. typeKeywords: [
  51. 'int', 'unit', 'string', 'tz',
  52. ],
  53. operators: [
  54. '=', '>', '<', '<=', '>=', '<>', ':', ':=', 'and', 'mod', 'or',
  55. '+', '-', '*', '/', '@', '&', '^', '%', '->', '<-'
  56. ],
  57. // we include these common regular expressions
  58. symbols: /[=><:@\^&|+\-*\/\^%]+/,
  59. // The main tokenizer for our languages
  60. tokenizer: {
  61. root: [
  62. // identifiers and keywords
  63. [/[a-zA-Z_][\w]*/, {
  64. cases: {
  65. '@keywords': { token: 'keyword.$0' },
  66. '@default': 'identifier'
  67. }
  68. }],
  69. // whitespace
  70. { include: '@whitespace' },
  71. // delimiters and operators
  72. [/[{}()\[\]]/, '@brackets'],
  73. [/[<>](?!@symbols)/, '@brackets'],
  74. [/@symbols/, {
  75. cases: {
  76. '@operators': 'delimiter',
  77. '@default': ''
  78. }
  79. }],
  80. // numbers
  81. [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
  82. [/\$[0-9a-fA-F]{1,16}/, 'number.hex'],
  83. [/\d+/, 'number'],
  84. // delimiter: after number because of .\d floats
  85. [/[;,.]/, 'delimiter'],
  86. // strings
  87. [/'([^'\\]|\\.)*$/, 'string.invalid'],
  88. [/'/, 'string', '@string'],
  89. // characters
  90. [/'[^\\']'/, 'string'],
  91. [/'/, 'string.invalid'],
  92. [/\#\d+/, 'string']
  93. ],
  94. /* */
  95. comment: [
  96. [/[^\(\*]+/, 'comment'],
  97. //[/\(\*/, 'comment', '@push' ], // nested comment not allowed :-(
  98. [/\*\)/, 'comment', '@pop'],
  99. [/\(\*/, 'comment']
  100. ],
  101. string: [
  102. [/[^\\']+/, 'string'],
  103. [/\\./, 'string.escape.invalid'],
  104. [/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
  105. ],
  106. whitespace: [
  107. [/[ \t\r\n]+/, 'white'],
  108. [/\(\*/, 'comment', '@comment'],
  109. [/\/\/.*$/, 'comment'],
  110. ],
  111. },
  112. };
  113. });