pla.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. // src/basic-languages/pla/pla.ts
  8. var conf = {
  9. comments: {
  10. lineComment: "#"
  11. },
  12. brackets: [
  13. ["[", "]"],
  14. ["<", ">"],
  15. ["(", ")"]
  16. ],
  17. autoClosingPairs: [
  18. { open: "[", close: "]" },
  19. { open: "<", close: ">" },
  20. { open: "(", close: ")" }
  21. ],
  22. surroundingPairs: [
  23. { open: "[", close: "]" },
  24. { open: "<", close: ">" },
  25. { open: "(", close: ")" }
  26. ]
  27. };
  28. var language = {
  29. defaultToken: "",
  30. tokenPostfix: ".pla",
  31. brackets: [
  32. { open: "[", close: "]", token: "delimiter.square" },
  33. { open: "<", close: ">", token: "delimiter.angle" },
  34. { open: "(", close: ")", token: "delimiter.parenthesis" }
  35. ],
  36. keywords: [
  37. ".i",
  38. ".o",
  39. ".mv",
  40. ".ilb",
  41. ".ob",
  42. ".label",
  43. ".type",
  44. ".phase",
  45. ".pair",
  46. ".symbolic",
  47. ".symbolic-output",
  48. ".kiss",
  49. ".p",
  50. ".e",
  51. ".end"
  52. ],
  53. comment: /#.*$/,
  54. identifier: /[a-zA-Z]+[a-zA-Z0-9_\-]*/,
  55. plaContent: /[01\-~\|]+/,
  56. tokenizer: {
  57. root: [
  58. { include: "@whitespace" },
  59. [/@comment/, "comment"],
  60. [
  61. /\.([a-zA-Z_\-]+)/,
  62. {
  63. cases: {
  64. "@eos": { token: "keyword.$1" },
  65. "@keywords": {
  66. cases: {
  67. ".type": { token: "keyword.$1", next: "@type" },
  68. "@default": { token: "keyword.$1", next: "@keywordArg" }
  69. }
  70. },
  71. "@default": { token: "keyword.$1" }
  72. }
  73. }
  74. ],
  75. [/@identifier/, "identifier"],
  76. [/@plaContent/, "string"]
  77. ],
  78. whitespace: [[/[ \t\r\n]+/, ""]],
  79. type: [{ include: "@whitespace" }, [/\w+/, { token: "type", next: "@pop" }]],
  80. keywordArg: [
  81. [
  82. /[ \t\r\n]+/,
  83. {
  84. cases: {
  85. "@eos": { token: "", next: "@pop" },
  86. "@default": ""
  87. }
  88. }
  89. ],
  90. [/@comment/, "comment", "@pop"],
  91. [
  92. /[<>()\[\]]/,
  93. {
  94. cases: {
  95. "@eos": { token: "@brackets", next: "@pop" },
  96. "@default": "@brackets"
  97. }
  98. }
  99. ],
  100. [
  101. /\-?\d+/,
  102. {
  103. cases: {
  104. "@eos": { token: "number", next: "@pop" },
  105. "@default": "number"
  106. }
  107. }
  108. ],
  109. [
  110. /@identifier/,
  111. {
  112. cases: {
  113. "@eos": { token: "identifier", next: "@pop" },
  114. "@default": "identifier"
  115. }
  116. }
  117. ],
  118. [
  119. /[;=]/,
  120. {
  121. cases: {
  122. "@eos": { token: "delimiter", next: "@pop" },
  123. "@default": "delimiter"
  124. }
  125. }
  126. ]
  127. ]
  128. }
  129. };
  130. export {
  131. conf,
  132. language
  133. };