pascaligo.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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: '.pascaligo',
  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. 'begin', 'block', 'case', 'const', 'else', 'end',
  46. 'fail', 'for', 'from', 'function', 'if', 'is', 'nil',
  47. 'of', 'remove', 'return', 'skip', 'then', 'type', 'var',
  48. 'while', 'with', 'option', 'None', 'transaction'
  49. ],
  50. typeKeywords: [
  51. 'bool', 'int', 'list', 'map', 'nat', 'record',
  52. 'string', 'unit', 'address', 'map', 'mtz', 'xtz'
  53. ],
  54. operators: [
  55. '=', '>', '<', '<=', '>=', '<>', ':', ':=', 'and', 'mod', 'or',
  56. '+', '-', '*', '/', '@', '&', '^', '%'
  57. ],
  58. // we include these common regular expressions
  59. symbols: /[=><:@\^&|+\-*\/\^%]+/,
  60. // The main tokenizer for our languages
  61. tokenizer: {
  62. root: [
  63. // identifiers and keywords
  64. [/[a-zA-Z_][\w]*/, {
  65. cases: {
  66. '@keywords': { token: 'keyword.$0' },
  67. '@default': 'identifier'
  68. }
  69. }],
  70. // whitespace
  71. { include: '@whitespace' },
  72. // delimiters and operators
  73. [/[{}()\[\]]/, '@brackets'],
  74. [/[<>](?!@symbols)/, '@brackets'],
  75. [/@symbols/, {
  76. cases: {
  77. '@operators': 'delimiter',
  78. '@default': ''
  79. }
  80. }],
  81. // numbers
  82. [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
  83. [/\$[0-9a-fA-F]{1,16}/, 'number.hex'],
  84. [/\d+/, 'number'],
  85. // delimiter: after number because of .\d floats
  86. [/[;,.]/, 'delimiter'],
  87. // strings
  88. [/'([^'\\]|\\.)*$/, 'string.invalid'],
  89. [/'/, 'string', '@string'],
  90. // characters
  91. [/'[^\\']'/, 'string'],
  92. [/'/, 'string.invalid'],
  93. [/\#\d+/, 'string']
  94. ],
  95. /* */
  96. comment: [
  97. [/[^\(\*]+/, 'comment'],
  98. //[/\(\*/, 'comment', '@push' ], // nested comment not allowed :-(
  99. [/\*\)/, 'comment', '@pop'],
  100. [/\(\*/, 'comment']
  101. ],
  102. string: [
  103. [/[^\\']+/, 'string'],
  104. [/\\./, 'string.escape.invalid'],
  105. [/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
  106. ],
  107. whitespace: [
  108. [/[ \t\r\n]+/, 'white'],
  109. [/\(\*/, 'comment', '@comment'],
  110. [/\/\/.*$/, 'comment'],
  111. ],
  112. },
  113. };
  114. });