systemverilog.js 13 KB

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