pascaligo.js 4.2 KB

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