st.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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/st/st',["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. ['var', 'end_var'],
  19. ['var_input', 'end_var'],
  20. ['var_output', 'end_var'],
  21. ['var_in_out', 'end_var'],
  22. ['var_temp', 'end_var'],
  23. ['var_global', 'end_var'],
  24. ['var_access', 'end_var'],
  25. ['var_external', 'end_var'],
  26. ['type', 'end_type'],
  27. ['struct', 'end_struct'],
  28. ['program', 'end_program'],
  29. ['function', 'end_function'],
  30. ['function_block', 'end_function_block'],
  31. ['action', 'end_action'],
  32. ['step', 'end_step'],
  33. ['initial_step', 'end_step'],
  34. ['transaction', 'end_transaction'],
  35. ['configuration', 'end_configuration'],
  36. ['tcp', 'end_tcp'],
  37. ['recource', 'end_recource'],
  38. ['channel', 'end_channel'],
  39. ['library', 'end_library'],
  40. ['folder', 'end_folder'],
  41. ['binaries', 'end_binaries'],
  42. ['includes', 'end_includes'],
  43. ['sources', 'end_sources']
  44. ],
  45. autoClosingPairs: [
  46. { open: '[', close: ']' },
  47. { open: '{', close: '}' },
  48. { open: '(', close: ')' },
  49. { open: '/*', close: '*/' },
  50. { open: "'", close: "'", notIn: ['string_sq'] },
  51. { open: '"', close: '"', notIn: ['string_dq'] },
  52. { open: 'var_input', close: 'end_var' },
  53. { open: 'var_output', close: 'end_var' },
  54. { open: 'var_in_out', close: 'end_var' },
  55. { open: 'var_temp', close: 'end_var' },
  56. { open: 'var_global', close: 'end_var' },
  57. { open: 'var_access', close: 'end_var' },
  58. { open: 'var_external', close: 'end_var' },
  59. { open: 'type', close: 'end_type' },
  60. { open: 'struct', close: 'end_struct' },
  61. { open: 'program', close: 'end_program' },
  62. { open: 'function', close: 'end_function' },
  63. { open: 'function_block', close: 'end_function_block' },
  64. { open: 'action', close: 'end_action' },
  65. { open: 'step', close: 'end_step' },
  66. { open: 'initial_step', close: 'end_step' },
  67. { open: 'transaction', close: 'end_transaction' },
  68. { open: 'configuration', close: 'end_configuration' },
  69. { open: 'tcp', close: 'end_tcp' },
  70. { open: 'recource', close: 'end_recource' },
  71. { open: 'channel', close: 'end_channel' },
  72. { open: 'library', close: 'end_library' },
  73. { open: 'folder', close: 'end_folder' },
  74. { open: 'binaries', close: 'end_binaries' },
  75. { open: 'includes', close: 'end_includes' },
  76. { open: 'sources', close: 'end_sources' }
  77. ],
  78. surroundingPairs: [
  79. { open: '{', close: '}' },
  80. { open: '[', close: ']' },
  81. { open: '(', close: ')' },
  82. { open: '"', close: '"' },
  83. { open: "'", close: "'" },
  84. { open: 'var', close: 'end_var' },
  85. { open: 'var_input', close: 'end_var' },
  86. { open: 'var_output', close: 'end_var' },
  87. { open: 'var_in_out', close: 'end_var' },
  88. { open: 'var_temp', close: 'end_var' },
  89. { open: 'var_global', close: 'end_var' },
  90. { open: 'var_access', close: 'end_var' },
  91. { open: 'var_external', close: 'end_var' },
  92. { open: 'type', close: 'end_type' },
  93. { open: 'struct', close: 'end_struct' },
  94. { open: 'program', close: 'end_program' },
  95. { open: 'function', close: 'end_function' },
  96. { open: 'function_block', close: 'end_function_block' },
  97. { open: 'action', close: 'end_action' },
  98. { open: 'step', close: 'end_step' },
  99. { open: 'initial_step', close: 'end_step' },
  100. { open: 'transaction', close: 'end_transaction' },
  101. { open: 'configuration', close: 'end_configuration' },
  102. { open: 'tcp', close: 'end_tcp' },
  103. { open: 'recource', close: 'end_recource' },
  104. { open: 'channel', close: 'end_channel' },
  105. { open: 'library', close: 'end_library' },
  106. { open: 'folder', close: 'end_folder' },
  107. { open: 'binaries', close: 'end_binaries' },
  108. { open: 'includes', close: 'end_includes' },
  109. { open: 'sources', close: 'end_sources' }
  110. ],
  111. folding: {
  112. markers: {
  113. start: new RegExp('^\\s*#pragma\\s+region\\b'),
  114. end: new RegExp('^\\s*#pragma\\s+endregion\\b')
  115. }
  116. }
  117. };
  118. exports.language = {
  119. defaultToken: '',
  120. tokenPostfix: '.st',
  121. ignoreCase: true,
  122. brackets: [
  123. { token: 'delimiter.curly', open: '{', close: '}' },
  124. { token: 'delimiter.parenthesis', open: '(', close: ')' },
  125. { token: 'delimiter.square', open: '[', close: ']' }
  126. ],
  127. keywords: [
  128. 'if',
  129. 'end_if',
  130. 'elsif',
  131. 'else',
  132. 'case',
  133. 'of',
  134. 'to',
  135. '__try',
  136. '__catch',
  137. '__finally',
  138. 'do',
  139. 'with',
  140. 'by',
  141. 'while',
  142. 'repeat',
  143. 'end_while',
  144. 'end_repeat',
  145. 'end_case',
  146. 'for',
  147. 'end_for',
  148. 'task',
  149. 'retain',
  150. 'non_retain',
  151. 'constant',
  152. 'with',
  153. 'at',
  154. 'exit',
  155. 'return',
  156. 'interval',
  157. 'priority',
  158. 'address',
  159. 'port',
  160. 'on_channel',
  161. 'then',
  162. 'iec',
  163. 'file',
  164. 'uses',
  165. 'version',
  166. 'packagetype',
  167. 'displayname',
  168. 'copyright',
  169. 'summary',
  170. 'vendor',
  171. 'common_source',
  172. 'from',
  173. 'extends'
  174. ],
  175. constant: ['false', 'true', 'null'],
  176. defineKeywords: [
  177. 'var',
  178. 'var_input',
  179. 'var_output',
  180. 'var_in_out',
  181. 'var_temp',
  182. 'var_global',
  183. 'var_access',
  184. 'var_external',
  185. 'end_var',
  186. 'type',
  187. 'end_type',
  188. 'struct',
  189. 'end_struct',
  190. 'program',
  191. 'end_program',
  192. 'function',
  193. 'end_function',
  194. 'function_block',
  195. 'end_function_block',
  196. 'interface',
  197. 'end_interface',
  198. 'method',
  199. 'end_method',
  200. 'property',
  201. 'end_property',
  202. 'namespace',
  203. 'end_namespace',
  204. 'configuration',
  205. 'end_configuration',
  206. 'tcp',
  207. 'end_tcp',
  208. 'resource',
  209. 'end_resource',
  210. 'channel',
  211. 'end_channel',
  212. 'library',
  213. 'end_library',
  214. 'folder',
  215. 'end_folder',
  216. 'binaries',
  217. 'end_binaries',
  218. 'includes',
  219. 'end_includes',
  220. 'sources',
  221. 'end_sources',
  222. 'action',
  223. 'end_action',
  224. 'step',
  225. 'initial_step',
  226. 'end_step',
  227. 'transaction',
  228. 'end_transaction'
  229. ],
  230. typeKeywords: [
  231. 'int',
  232. 'sint',
  233. 'dint',
  234. 'lint',
  235. 'usint',
  236. 'uint',
  237. 'udint',
  238. 'ulint',
  239. 'real',
  240. 'lreal',
  241. 'time',
  242. 'date',
  243. 'time_of_day',
  244. 'date_and_time',
  245. 'string',
  246. 'bool',
  247. 'byte',
  248. 'word',
  249. 'dword',
  250. 'array',
  251. 'pointer',
  252. 'lword'
  253. ],
  254. operators: [
  255. '=',
  256. '>',
  257. '<',
  258. ':',
  259. ':=',
  260. '<=',
  261. '>=',
  262. '<>',
  263. '&',
  264. '+',
  265. '-',
  266. '*',
  267. '**',
  268. 'MOD',
  269. '^',
  270. 'or',
  271. 'and',
  272. 'not',
  273. 'xor',
  274. 'abs',
  275. 'acos',
  276. 'asin',
  277. 'atan',
  278. 'cos',
  279. 'exp',
  280. 'expt',
  281. 'ln',
  282. 'log',
  283. 'sin',
  284. 'sqrt',
  285. 'tan',
  286. 'sel',
  287. 'max',
  288. 'min',
  289. 'limit',
  290. 'mux',
  291. 'shl',
  292. 'shr',
  293. 'rol',
  294. 'ror',
  295. 'indexof',
  296. 'sizeof',
  297. 'adr',
  298. 'adrinst',
  299. 'bitadr',
  300. 'is_valid',
  301. 'ref',
  302. 'ref_to'
  303. ],
  304. builtinVariables: [],
  305. builtinFunctions: [
  306. 'sr',
  307. 'rs',
  308. 'tp',
  309. 'ton',
  310. 'tof',
  311. 'eq',
  312. 'ge',
  313. 'le',
  314. 'lt',
  315. 'ne',
  316. 'round',
  317. 'trunc',
  318. 'ctd',
  319. 'сtu',
  320. 'ctud',
  321. 'r_trig',
  322. 'f_trig',
  323. 'move',
  324. 'concat',
  325. 'delete',
  326. 'find',
  327. 'insert',
  328. 'left',
  329. 'len',
  330. 'replace',
  331. 'right',
  332. 'rtc'
  333. ],
  334. // we include these common regular expressions
  335. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  336. // C# style strings
  337. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  338. // The main tokenizer for our languages
  339. tokenizer: {
  340. root: [
  341. [/(\.\.)/, 'delimiter'],
  342. [/\b(16#[0-9A-Fa-f\_]*)+\b/, 'number.hex'],
  343. [/\b(2#[01\_]+)+\b/, 'number.binary'],
  344. [/\b(8#[0-9\_]*)+\b/, 'number.octal'],
  345. [/\b\d*\.\d+([eE][\-+]?\d+)?\b/, 'number.float'],
  346. [/\b(L?REAL)#[0-9\_\.e]+\b/, 'number.float'],
  347. [/\b(BYTE|(?:D|L)?WORD|U?(?:S|D|L)?INT)#[0-9\_]+\b/, 'number'],
  348. [/\d+/, 'number'],
  349. [/\b(T|DT|TOD)#[0-9:-_shmyd]+\b/, 'tag'],
  350. [/\%(I|Q|M)(X|B|W|D|L)[0-9\.]+/, 'tag'],
  351. [/\%(I|Q|M)[0-9\.]*/, 'tag'],
  352. [/\b[A-Za-z]{1,6}#[0-9]+\b/, 'tag'],
  353. [/\b(TO_|CTU_|CTD_|CTUD_|MUX_|SEL_)[A_Za-z]+\b/, 'predefined'],
  354. [/\b[A_Za-z]+(_TO_)[A_Za-z]+\b/, 'predefined'],
  355. [/[;]/, 'delimiter'],
  356. [/[.]/, { token: 'delimiter', next: '@params' }],
  357. // identifiers and keywords
  358. [
  359. /[a-zA-Z_]\w*/,
  360. {
  361. cases: {
  362. '@operators': 'operators',
  363. '@keywords': 'keyword',
  364. '@typeKeywords': 'type',
  365. '@defineKeywords': 'variable',
  366. '@constant': 'constant',
  367. '@builtinVariables': 'predefined',
  368. '@builtinFunctions': 'predefined',
  369. '@default': 'identifier'
  370. }
  371. }
  372. ],
  373. { include: '@whitespace' },
  374. [/[{}()\[\]]/, '@brackets'],
  375. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  376. [/"/, { token: 'string.quote', bracket: '@open', next: '@string_dq' }],
  377. [/'/, { token: 'string.quote', bracket: '@open', next: '@string_sq' }],
  378. [/'[^\\']'/, 'string'],
  379. [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
  380. [/'/, 'string.invalid']
  381. ],
  382. params: [
  383. [/\b[A-Za-z0-9_]+\b(?=\()/, { token: 'identifier', next: '@pop' }],
  384. [/\b[A-Za-z0-9_]+\b/, 'variable.name', '@pop']
  385. ],
  386. comment: [
  387. [/[^\/*]+/, 'comment'],
  388. [/\/\*/, 'comment', '@push'],
  389. ['\\*/', 'comment', '@pop'],
  390. [/[\/*]/, 'comment']
  391. ],
  392. comment2: [
  393. [/[^\(*]+/, 'comment'],
  394. [/\(\*/, 'comment', '@push'],
  395. ['\\*\\)', 'comment', '@pop'],
  396. [/[\(*]/, 'comment']
  397. ],
  398. whitespace: [
  399. [/[ \t\r\n]+/, 'white'],
  400. [/\/\/.*$/, 'comment'],
  401. [/\/\*/, 'comment', '@comment'],
  402. [/\(\*/, 'comment', '@comment2']
  403. ],
  404. string_dq: [
  405. [/[^\\"]+/, 'string'],
  406. [/@escapes/, 'string.escape'],
  407. [/\\./, 'string.escape.invalid'],
  408. [/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
  409. ],
  410. string_sq: [
  411. [/[^\\']+/, 'string'],
  412. [/@escapes/, 'string.escape'],
  413. [/\\./, 'string.escape.invalid'],
  414. [/'/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
  415. ]
  416. }
  417. };
  418. });