systemverilog.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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/systemverilog/systemverilog',["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. ['begin', 'end'],
  19. ['case', 'endcase'],
  20. ['casex', 'endcase'],
  21. ['casez', 'endcase'],
  22. ['checker', 'endchecker'],
  23. ['class', 'endclass'],
  24. ['clocking', 'endclocking'],
  25. ['config', 'endconfig'],
  26. ['function', 'endfunction'],
  27. ['generate', 'endgenerate'],
  28. ['group', 'endgroup'],
  29. ['interface', 'endinterface'],
  30. ['module', 'endmodule'],
  31. ['package', 'endpackage'],
  32. ['primitive', 'endprimitive'],
  33. ['program', 'endprogram'],
  34. ['property', 'endproperty'],
  35. ['specify', 'endspecify'],
  36. ['sequence', 'endsequence'],
  37. ['table', 'endtable'],
  38. ['task', 'endtask']
  39. ],
  40. autoClosingPairs: [
  41. { open: '[', close: ']' },
  42. { open: '{', close: '}' },
  43. { open: '(', close: ')' },
  44. { open: "'", close: "'", notIn: ['string', 'comment'] },
  45. { open: '"', close: '"', notIn: ['string'] }
  46. ],
  47. surroundingPairs: [
  48. { open: '{', close: '}' },
  49. { open: '[', close: ']' },
  50. { open: '(', close: ')' },
  51. { open: '"', close: '"' },
  52. { open: "'", close: "'" }
  53. ],
  54. folding: {
  55. offSide: false,
  56. markers: {
  57. start: new RegExp('^(?:\\s*|.*(?!\\/[\\/\\*])[^\\w])(?:begin|case(x|z)?|class|clocking|config|covergroup|function|generate|interface|module|package|primitive|property|program|sequence|specify|table|task)\\b'),
  58. end: new RegExp('^(?:\\s*|.*(?!\\/[\\/\\*])[^\\w])(?:end|endcase|endclass|endclocking|endconfig|endgroup|endfunction|endgenerate|endinterface|endmodule|endpackage|endprimitive|endproperty|endprogram|endsequence|endspecify|endtable|endtask)\\b')
  59. }
  60. }
  61. };
  62. exports.language = {
  63. defaultToken: '',
  64. tokenPostfix: '.sv',
  65. brackets: [
  66. { token: 'delimiter.curly', open: '{', close: '}' },
  67. { token: 'delimiter.parenthesis', open: '(', close: ')' },
  68. { token: 'delimiter.square', open: '[', close: ']' },
  69. { token: 'delimiter.angle', open: '<', close: '>' }
  70. ],
  71. keywords: [
  72. 'accept_on',
  73. 'alias',
  74. 'always',
  75. 'always_comb',
  76. 'always_ff',
  77. 'always_latch',
  78. 'and',
  79. 'assert',
  80. 'assign',
  81. 'assume',
  82. 'automatic',
  83. 'before',
  84. 'begin',
  85. 'bind',
  86. 'bins',
  87. 'binsof',
  88. 'bit',
  89. 'break',
  90. 'buf',
  91. 'bufif0',
  92. 'bufif1',
  93. 'byte',
  94. 'case',
  95. 'casex',
  96. 'casez',
  97. 'cell',
  98. 'chandle',
  99. 'checker',
  100. 'class',
  101. 'clocking',
  102. 'cmos',
  103. 'config',
  104. 'const',
  105. 'constraint',
  106. 'context',
  107. 'continue',
  108. 'cover',
  109. 'covergroup',
  110. 'coverpoint',
  111. 'cross',
  112. 'deassign',
  113. 'default',
  114. 'defparam',
  115. 'design',
  116. 'disable',
  117. 'dist',
  118. 'do',
  119. 'edge',
  120. 'else',
  121. 'end',
  122. 'endcase',
  123. 'endchecker',
  124. 'endclass',
  125. 'endclocking',
  126. 'endconfig',
  127. 'endfunction',
  128. 'endgenerate',
  129. 'endgroup',
  130. 'endinterface',
  131. 'endmodule',
  132. 'endpackage',
  133. 'endprimitive',
  134. 'endprogram',
  135. 'endproperty',
  136. 'endspecify',
  137. 'endsequence',
  138. 'endtable',
  139. 'endtask',
  140. 'enum',
  141. 'event',
  142. 'eventually',
  143. 'expect',
  144. 'export',
  145. 'extends',
  146. 'extern',
  147. 'final',
  148. 'first_match',
  149. 'for',
  150. 'force',
  151. 'foreach',
  152. 'forever',
  153. 'fork',
  154. 'forkjoin',
  155. 'function',
  156. 'generate',
  157. 'genvar',
  158. 'global',
  159. 'highz0',
  160. 'highz1',
  161. 'if',
  162. 'iff',
  163. 'ifnone',
  164. 'ignore_bins',
  165. 'illegal_bins',
  166. 'implements',
  167. 'implies',
  168. 'import',
  169. 'incdir',
  170. 'include',
  171. 'initial',
  172. 'inout',
  173. 'input',
  174. 'inside',
  175. 'instance',
  176. 'int',
  177. 'integer',
  178. 'interconnect',
  179. 'interface',
  180. 'intersect',
  181. 'join',
  182. 'join_any',
  183. 'join_none',
  184. 'large',
  185. 'let',
  186. 'liblist',
  187. 'library',
  188. 'local',
  189. 'localparam',
  190. 'logic',
  191. 'longint',
  192. 'macromodule',
  193. 'matches',
  194. 'medium',
  195. 'modport',
  196. 'module',
  197. 'nand',
  198. 'negedge',
  199. 'nettype',
  200. 'new',
  201. 'nexttime',
  202. 'nmos',
  203. 'nor',
  204. 'noshowcancelled',
  205. 'not',
  206. 'notif0',
  207. 'notif1',
  208. 'null',
  209. 'or',
  210. 'output',
  211. 'package',
  212. 'packed',
  213. 'parameter',
  214. 'pmos',
  215. 'posedge',
  216. 'primitive',
  217. 'priority',
  218. 'program',
  219. 'property',
  220. 'protected',
  221. 'pull0',
  222. 'pull1',
  223. 'pulldown',
  224. 'pullup',
  225. 'pulsestyle_ondetect',
  226. 'pulsestyle_onevent',
  227. 'pure',
  228. 'rand',
  229. 'randc',
  230. 'randcase',
  231. 'randsequence',
  232. 'rcmos',
  233. 'real',
  234. 'realtime',
  235. 'ref',
  236. 'reg',
  237. 'reject_on',
  238. 'release',
  239. 'repeat',
  240. 'restrict',
  241. 'return',
  242. 'rnmos',
  243. 'rpmos',
  244. 'rtran',
  245. 'rtranif0',
  246. 'rtranif1',
  247. 's_always',
  248. 's_eventually',
  249. 's_nexttime',
  250. 's_until',
  251. 's_until_with',
  252. 'scalared',
  253. 'sequence',
  254. 'shortint',
  255. 'shortreal',
  256. 'showcancelled',
  257. 'signed',
  258. 'small',
  259. 'soft',
  260. 'solve',
  261. 'specify',
  262. 'specparam',
  263. 'static',
  264. 'string',
  265. 'strong',
  266. 'strong0',
  267. 'strong1',
  268. 'struct',
  269. 'super',
  270. 'supply0',
  271. 'supply1',
  272. 'sync_accept_on',
  273. 'sync_reject_on',
  274. 'table',
  275. 'tagged',
  276. 'task',
  277. 'this',
  278. 'throughout',
  279. 'time',
  280. 'timeprecision',
  281. 'timeunit',
  282. 'tran',
  283. 'tranif0',
  284. 'tranif1',
  285. 'tri',
  286. 'tri0',
  287. 'tri1',
  288. 'triand',
  289. 'trior',
  290. 'trireg',
  291. 'type',
  292. 'typedef',
  293. 'union',
  294. 'unique',
  295. 'unique0',
  296. 'unsigned',
  297. 'until',
  298. 'until_with',
  299. 'untyped',
  300. 'use',
  301. 'uwire',
  302. 'var',
  303. 'vectored',
  304. 'virtual',
  305. 'void',
  306. 'wait',
  307. 'wait_order',
  308. 'wand',
  309. 'weak',
  310. 'weak0',
  311. 'weak1',
  312. 'while',
  313. 'wildcard',
  314. 'wire',
  315. 'with',
  316. 'within',
  317. 'wor',
  318. 'xnor',
  319. 'xor'
  320. ],
  321. builtin_gates: [
  322. 'and',
  323. 'nand',
  324. 'nor',
  325. 'or',
  326. 'xor',
  327. 'xnor',
  328. 'buf',
  329. 'not',
  330. 'bufif0',
  331. 'bufif1',
  332. 'notif1',
  333. 'notif0',
  334. 'cmos',
  335. 'nmos',
  336. 'pmos',
  337. 'rcmos',
  338. 'rnmos',
  339. 'rpmos',
  340. 'tran',
  341. 'tranif1',
  342. 'tranif0',
  343. 'rtran',
  344. 'rtranif1',
  345. 'rtranif0'
  346. ],
  347. operators: [
  348. // assignment operators
  349. '=',
  350. '+=',
  351. '-=',
  352. '*=',
  353. '/=',
  354. '%=',
  355. '&=',
  356. '|=',
  357. '^=',
  358. '<<=',
  359. '>>+',
  360. '<<<=',
  361. '>>>=',
  362. // conditional expression
  363. '?',
  364. ':',
  365. // Unary operators
  366. '+',
  367. '-',
  368. '!',
  369. '~',
  370. '&',
  371. '~&',
  372. '|',
  373. '~|',
  374. '^',
  375. '~^',
  376. '^~',
  377. //binary operators
  378. '+',
  379. '-',
  380. '*',
  381. '/',
  382. '%',
  383. '==',
  384. '!=',
  385. '===',
  386. '!==',
  387. '==?',
  388. '!=?',
  389. '&&',
  390. '||',
  391. '**',
  392. '<',
  393. '<=',
  394. '>',
  395. '>=',
  396. '&',
  397. '|',
  398. '^',
  399. '>>',
  400. '<<',
  401. '>>>',
  402. '<<<',
  403. // increment or decrement operator
  404. '++',
  405. '--',
  406. //binary logical operator
  407. '->',
  408. '<->',
  409. // binary set membership operator
  410. 'inside',
  411. // binary distrubution operator
  412. 'dist',
  413. '::',
  414. '+:',
  415. '-:',
  416. '*>',
  417. '&&&',
  418. '|->',
  419. '|=>',
  420. '#=#'
  421. ],
  422. // we include these common regular expressions
  423. symbols: /[=><!~?:&|+\-*\/\^%#]+/,
  424. escapes: /%%|\\(?:[antvf\\"']|x[0-9A-Fa-f]{1,2}|[0-7]{1,3})/,
  425. identifier: /(?:[a-zA-Z_][a-zA-Z0-9_$\.]*|\\\S+ )/,
  426. systemcall: /[$][a-zA-Z0-9_]+/,
  427. timeunits: /s|ms|us|ns|ps|fs/,
  428. // The main tokenizer for our languages
  429. tokenizer: {
  430. root: [
  431. // module instances
  432. [
  433. /^(\s*)(@identifier)/,
  434. [
  435. '',
  436. {
  437. cases: {
  438. '@builtin_gates': {
  439. token: 'keyword.$2',
  440. next: '@module_instance'
  441. },
  442. '@keywords': { token: 'keyword.$2' },
  443. '@default': {
  444. token: 'identifier',
  445. next: '@module_instance'
  446. }
  447. }
  448. }
  449. ]
  450. ],
  451. // include statements
  452. [/^\s*`include/, { token: 'keyword.directive.include', next: '@include' }],
  453. // Preprocessor directives
  454. [/^\s*`\s*\w+/, 'keyword'],
  455. // identifiers and keywords
  456. { include: '@identifier_or_keyword' },
  457. // whitespace
  458. { include: '@whitespace' },
  459. // (* attributes *).
  460. [/\(\*.*\*\)/, 'annotation'],
  461. // Systemcall
  462. [/@systemcall/, 'variable.predefined'],
  463. // delimiters and operators
  464. [/[{}()\[\]]/, '@brackets'],
  465. [/[<>](?!@symbols)/, '@brackets'],
  466. [
  467. /@symbols/,
  468. {
  469. cases: {
  470. '@operators': 'delimiter',
  471. '@default': ''
  472. }
  473. }
  474. ],
  475. // numbers
  476. { include: '@numbers' },
  477. // delimiter: after number because of .\d floats
  478. [/[;,.]/, 'delimiter'],
  479. // strings
  480. { include: '@strings' }
  481. ],
  482. identifier_or_keyword: [
  483. [
  484. /@identifier/,
  485. {
  486. cases: {
  487. '@keywords': { token: 'keyword.$0' },
  488. '@default': 'identifier'
  489. }
  490. }
  491. ]
  492. ],
  493. numbers: [
  494. [/\d+?[\d_]*(?:\.[\d_]+)?[eE][\-+]?\d+/, 'number.float'],
  495. [/\d+?[\d_]*\.[\d_]+(?:\s*@timeunits)?/, 'number.float'],
  496. [/(?:\d+?[\d_]*\s*)?'[sS]?[dD]\s*[0-9xXzZ?]+?[0-9xXzZ?_]*/, 'number'],
  497. [/(?:\d+?[\d_]*\s*)?'[sS]?[bB]\s*[0-1xXzZ?]+?[0-1xXzZ?_]*/, 'number.binary'],
  498. [/(?:\d+?[\d_]*\s*)?'[sS]?[oO]\s*[0-7xXzZ?]+?[0-7xXzZ?_]*/, 'number.octal'],
  499. [/(?:\d+?[\d_]*\s*)?'[sS]?[hH]\s*[0-9a-fA-FxXzZ?]+?[0-9a-fA-FxXzZ?_]*/, 'number.hex'],
  500. [/1step/, 'number'],
  501. [/[\dxXzZ]+?[\dxXzZ_]*(?:\s*@timeunits)?/, 'number'],
  502. [/'[01xXzZ]+/, 'number']
  503. ],
  504. module_instance: [
  505. { include: '@whitespace' },
  506. [/(#?)(\()/, ['', { token: '@brackets', next: '@port_connection' }]],
  507. [/@identifier\s*[;={}\[\],]/, { token: '@rematch', next: '@pop' }],
  508. [/@symbols|[;={}\[\],]/, { token: '@rematch', next: '@pop' }],
  509. [/@identifier/, 'type'],
  510. [/;/, 'delimiter', '@pop']
  511. ],
  512. port_connection: [
  513. { include: '@identifier_or_keyword' },
  514. { include: '@whitespace' },
  515. [/@systemcall/, 'variable.predefined'],
  516. { include: '@numbers' },
  517. { include: '@strings' },
  518. [/[,]/, 'delimiter'],
  519. [/\(/, '@brackets', '@port_connection'],
  520. [/\)/, '@brackets', '@pop']
  521. ],
  522. whitespace: [
  523. [/[ \t\r\n]+/, ''],
  524. [/\/\*/, 'comment', '@comment'],
  525. [/\/\/.*$/, 'comment']
  526. ],
  527. comment: [
  528. [/[^\/*]+/, 'comment'],
  529. [/\*\//, 'comment', '@pop'],
  530. [/[\/*]/, 'comment']
  531. ],
  532. strings: [
  533. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  534. [/"/, 'string', '@string']
  535. ],
  536. string: [
  537. [/[^\\"]+/, 'string'],
  538. [/@escapes/, 'string.escape'],
  539. [/\\./, 'string.escape.invalid'],
  540. [/"/, 'string', '@pop']
  541. ],
  542. include: [
  543. [
  544. /(\s*)(")([\w*\/*]*)(.\w*)(")/,
  545. [
  546. '',
  547. 'string.include.identifier',
  548. 'string.include.identifier',
  549. 'string.include.identifier',
  550. { token: 'string.include.identifier', next: '@pop' }
  551. ]
  552. ],
  553. [
  554. /(\s*)(<)([\w*\/*]*)(.\w*)(>)/,
  555. [
  556. '',
  557. 'string.include.identifier',
  558. 'string.include.identifier',
  559. 'string.include.identifier',
  560. { token: 'string.include.identifier', next: '@pop' }
  561. ]
  562. ]
  563. ]
  564. }
  565. };
  566. });