grammar-well 1.3.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +76 -560
  3. package/build/generator/artifacts/basic.d.ts +7 -0
  4. package/build/generator/artifacts/basic.js +24 -0
  5. package/build/generator/artifacts/basic.js.map +1 -0
  6. package/build/generator/artifacts/lexer.d.ts +13 -0
  7. package/build/generator/artifacts/lexer.js +204 -0
  8. package/build/generator/artifacts/lexer.js.map +1 -0
  9. package/build/{compiler/generator → generator}/artifacts/lr.d.ts +14 -14
  10. package/build/{compiler/generator → generator}/artifacts/lr.js +18 -22
  11. package/build/generator/artifacts/lr.js.map +1 -0
  12. package/build/generator/builtin/json.d.ts +183 -0
  13. package/build/generator/builtin/json.js +124 -0
  14. package/build/generator/builtin/json.js.map +1 -0
  15. package/build/generator/builtin/registry.json +1 -0
  16. package/build/generator/builtin/whitespace.d.ts +61 -0
  17. package/build/generator/builtin/whitespace.js +37 -0
  18. package/build/generator/builtin/whitespace.js.map +1 -0
  19. package/build/generator/generator.d.ts +38 -0
  20. package/build/generator/generator.js +368 -0
  21. package/build/generator/generator.js.map +1 -0
  22. package/build/generator/grammars/index.d.ts +2 -0
  23. package/build/generator/grammars/index.js +3 -0
  24. package/build/generator/grammars/index.js.map +1 -0
  25. package/build/generator/grammars/v1.d.ts +1190 -0
  26. package/build/generator/grammars/v1.js +614 -0
  27. package/build/generator/grammars/v1.js.map +1 -0
  28. package/build/generator/grammars/v2.d.ts +1367 -0
  29. package/build/generator/grammars/v2.js +695 -0
  30. package/build/generator/grammars/v2.js.map +1 -0
  31. package/build/generator/import-resolvers/auto.d.ts +2 -0
  32. package/build/generator/import-resolvers/auto.js +11 -0
  33. package/build/generator/import-resolvers/auto.js.map +1 -0
  34. package/build/generator/import-resolvers/browser.d.ts +7 -0
  35. package/build/generator/import-resolvers/browser.js +13 -0
  36. package/build/generator/import-resolvers/browser.js.map +1 -0
  37. package/build/generator/import-resolvers/default.d.ts +2 -0
  38. package/build/generator/import-resolvers/default.js +11 -0
  39. package/build/generator/import-resolvers/default.js.map +1 -0
  40. package/build/generator/import-resolvers/filesystem.d.ts +7 -0
  41. package/build/generator/import-resolvers/filesystem.js +15 -0
  42. package/build/generator/import-resolvers/filesystem.js.map +1 -0
  43. package/build/generator/index.d.ts +3 -0
  44. package/build/generator/index.js +4 -0
  45. package/build/generator/index.js.map +1 -0
  46. package/build/generator/state.d.ts +28 -0
  47. package/build/generator/state.js +73 -0
  48. package/build/generator/state.js.map +1 -0
  49. package/build/generator/stringify/common.d.ts +22 -0
  50. package/build/generator/stringify/common.js +83 -0
  51. package/build/generator/stringify/common.js.map +1 -0
  52. package/build/generator/stringify/exports/javascript.d.ts +3 -0
  53. package/build/generator/stringify/exports/javascript.js +26 -0
  54. package/build/generator/stringify/exports/javascript.js.map +1 -0
  55. package/build/generator/stringify/exports/json.d.ts +2 -0
  56. package/build/generator/stringify/exports/json.js +4 -0
  57. package/build/generator/stringify/exports/json.js.map +1 -0
  58. package/build/generator/stringify/exports/registry.d.ts +20 -0
  59. package/build/generator/stringify/exports/registry.js +17 -0
  60. package/build/generator/stringify/exports/registry.js.map +1 -0
  61. package/build/generator/stringify/exports/typescript.d.ts +2 -0
  62. package/build/generator/stringify/exports/typescript.js +16 -0
  63. package/build/generator/stringify/exports/typescript.js.map +1 -0
  64. package/build/generator/stringify/grammar/v2.d.ts +20 -0
  65. package/build/generator/stringify/grammar/v2.js +211 -0
  66. package/build/generator/stringify/grammar/v2.js.map +1 -0
  67. package/build/generator/stringify/javascript.d.ts +13 -0
  68. package/build/generator/stringify/javascript.js +83 -0
  69. package/build/generator/stringify/javascript.js.map +1 -0
  70. package/build/index.d.ts +7 -6
  71. package/build/index.js +7 -24
  72. package/build/index.js.map +1 -1
  73. package/build/lexers/character-lexer.d.ts +2 -2
  74. package/build/lexers/character-lexer.js +1 -5
  75. package/build/lexers/character-lexer.js.map +1 -1
  76. package/build/lexers/stateful-lexer.d.ts +12 -17
  77. package/build/lexers/stateful-lexer.js +38 -186
  78. package/build/lexers/stateful-lexer.js.map +1 -1
  79. package/build/lexers/token-buffer.d.ts +8 -8
  80. package/build/lexers/token-buffer.js +1 -5
  81. package/build/lexers/token-buffer.js.map +1 -1
  82. package/build/parser/algorithms/cyk.d.ts +6 -6
  83. package/build/parser/algorithms/cyk.js +10 -13
  84. package/build/parser/algorithms/cyk.js.map +1 -1
  85. package/build/parser/algorithms/earley.d.ts +7 -7
  86. package/build/parser/algorithms/earley.js +7 -11
  87. package/build/parser/algorithms/earley.js.map +1 -1
  88. package/build/parser/algorithms/lrk/algorithm.d.ts +3 -3
  89. package/build/parser/algorithms/lrk/algorithm.js +10 -13
  90. package/build/parser/algorithms/lrk/algorithm.js.map +1 -1
  91. package/build/parser/algorithms/lrk/bimap.js +1 -5
  92. package/build/parser/algorithms/lrk/bimap.js.map +1 -1
  93. package/build/parser/algorithms/lrk/canonical-collection.d.ts +7 -7
  94. package/build/parser/algorithms/lrk/canonical-collection.js +11 -15
  95. package/build/parser/algorithms/lrk/canonical-collection.js.map +1 -1
  96. package/build/parser/algorithms/lrk/closure.d.ts +3 -3
  97. package/build/parser/algorithms/lrk/closure.js +3 -7
  98. package/build/parser/algorithms/lrk/closure.js.map +1 -1
  99. package/build/parser/algorithms/lrk/stack.d.ts +6 -6
  100. package/build/parser/algorithms/lrk/stack.js +1 -5
  101. package/build/parser/algorithms/lrk/stack.js.map +1 -1
  102. package/build/parser/algorithms/lrk/state.d.ts +5 -5
  103. package/build/parser/algorithms/lrk/state.js +1 -2
  104. package/build/parser/parse.d.ts +10 -0
  105. package/build/parser/parse.js +34 -0
  106. package/build/parser/parse.js.map +1 -0
  107. package/build/parser/parser.d.ts +6 -17
  108. package/build/parser/parser.js +26 -42
  109. package/build/parser/parser.js.map +1 -1
  110. package/build/tsconfig.tsbuildinfo +1 -0
  111. package/build/typings/ast.d.ts +134 -0
  112. package/build/typings/ast.js +3 -0
  113. package/build/typings/ast.js.map +1 -0
  114. package/build/typings/common.d.ts +4 -0
  115. package/build/typings/common.js +2 -0
  116. package/build/typings/common.js.map +1 -0
  117. package/build/typings/generator.d.ts +58 -0
  118. package/build/typings/generator.js +3 -0
  119. package/build/typings/generator.js.map +1 -0
  120. package/build/typings/index.d.ts +43 -0
  121. package/build/typings/index.js +5 -0
  122. package/build/typings/index.js.map +1 -0
  123. package/build/typings/runtime.d.ts +70 -0
  124. package/build/typings/runtime.js +2 -0
  125. package/build/typings/runtime.js.map +1 -0
  126. package/build/utility/format.d.ts +1 -0
  127. package/build/utility/format.js +12 -0
  128. package/build/utility/format.js.map +1 -0
  129. package/build/utility/formatter.d.ts +1 -0
  130. package/build/utility/formatter.js +12 -0
  131. package/build/utility/formatter.js.map +1 -0
  132. package/build/utility/general.d.ts +1 -1
  133. package/build/utility/general.js +5 -13
  134. package/build/utility/general.js.map +1 -1
  135. package/build/utility/index.d.ts +4 -1
  136. package/build/utility/index.js +4 -17
  137. package/build/utility/index.js.map +1 -1
  138. package/build/utility/lint.d.ts +2 -2
  139. package/build/utility/lint.js +2 -6
  140. package/build/utility/lint.js.map +1 -1
  141. package/build/utility/migrate.d.ts +1 -0
  142. package/build/utility/migrate.js +10 -0
  143. package/build/utility/migrate.js.map +1 -0
  144. package/build/utility/monarch.d.ts +2 -2
  145. package/build/utility/monarch.js +33 -38
  146. package/build/utility/monarch.js.map +1 -1
  147. package/build/utility/parsing.d.ts +6 -0
  148. package/build/utility/parsing.js +26 -0
  149. package/build/utility/parsing.js.map +1 -0
  150. package/build/utility/text-format.d.ts +6 -6
  151. package/build/utility/text-format.js +2 -6
  152. package/build/utility/text-format.js.map +1 -1
  153. package/package.json +17 -24
  154. package/src/generator/artifacts/basic.ts +26 -0
  155. package/src/generator/artifacts/lexer.ts +228 -0
  156. package/src/{compiler/generator → generator}/artifacts/lr.ts +25 -24
  157. package/src/generator/builtin/character.well +7 -0
  158. package/src/generator/builtin/json.well +85 -0
  159. package/src/generator/builtin/number.well +21 -0
  160. package/src/generator/builtin/registry.json +1 -0
  161. package/src/generator/builtin/string.well +54 -0
  162. package/src/generator/builtin/whitespace.well +16 -0
  163. package/src/generator/generator.ts +401 -0
  164. package/src/generator/grammars/index.ts +2 -0
  165. package/src/generator/grammars/v1.ts +620 -0
  166. package/src/generator/grammars/v1.well +422 -0
  167. package/src/generator/grammars/v2.ts +701 -0
  168. package/src/generator/grammars/v2.well +413 -0
  169. package/src/generator/import-resolvers/auto.ts +12 -0
  170. package/src/generator/import-resolvers/browser.ts +13 -0
  171. package/src/generator/import-resolvers/filesystem.ts +18 -0
  172. package/src/generator/index.ts +3 -0
  173. package/src/generator/state.ts +89 -0
  174. package/src/generator/stringify/common.ts +90 -0
  175. package/src/generator/stringify/exports/javascript.ts +29 -0
  176. package/src/generator/stringify/exports/json.ts +5 -0
  177. package/src/generator/stringify/exports/registry.ts +20 -0
  178. package/src/generator/stringify/exports/typescript.ts +17 -0
  179. package/src/generator/stringify/grammar/v2.ts +223 -0
  180. package/src/generator/stringify/javascript.ts +94 -0
  181. package/src/index.ts +7 -6
  182. package/src/lexers/character-lexer.ts +2 -2
  183. package/src/lexers/stateful-lexer.ts +46 -203
  184. package/src/lexers/token-buffer.ts +3 -3
  185. package/src/parser/algorithms/cyk.ts +13 -12
  186. package/src/parser/algorithms/earley.ts +10 -10
  187. package/src/parser/algorithms/lrk/algorithm.ts +8 -7
  188. package/src/parser/algorithms/lrk/canonical-collection.ts +14 -14
  189. package/src/parser/algorithms/lrk/closure.ts +6 -6
  190. package/src/parser/algorithms/lrk/stack.ts +6 -6
  191. package/src/parser/algorithms/lrk/state.ts +5 -5
  192. package/src/parser/parse.ts +45 -0
  193. package/src/typings/ast.ts +148 -0
  194. package/src/typings/common.ts +2 -0
  195. package/src/typings/generator.ts +62 -0
  196. package/src/typings/index.ts +38 -0
  197. package/src/typings/runtime.ts +82 -0
  198. package/src/utility/format.ts +12 -0
  199. package/src/utility/general.ts +1 -2
  200. package/src/utility/index.ts +4 -1
  201. package/src/utility/lint.ts +5 -5
  202. package/src/utility/monarch.ts +34 -34
  203. package/src/utility/parsing.ts +30 -0
  204. package/src/utility/text-format.ts +7 -7
  205. package/.eslintrc.cjs +0 -14
  206. package/bootstrap.ts +0 -45
  207. package/build/compiler/builtin.json +0 -1
  208. package/build/compiler/compiler.d.ts +0 -50
  209. package/build/compiler/compiler.js +0 -249
  210. package/build/compiler/compiler.js.map +0 -1
  211. package/build/compiler/generator/artifacts/lr.js.map +0 -1
  212. package/build/compiler/generator/artifacts/standard.d.ts +0 -7
  213. package/build/compiler/generator/artifacts/standard.js +0 -28
  214. package/build/compiler/generator/artifacts/standard.js.map +0 -1
  215. package/build/compiler/generator/generator.d.ts +0 -24
  216. package/build/compiler/generator/generator.js +0 -217
  217. package/build/compiler/generator/generator.js.map +0 -1
  218. package/build/compiler/gwell.d.ts +0 -1112
  219. package/build/compiler/gwell.js +0 -576
  220. package/build/compiler/gwell.js.map +0 -1
  221. package/build/compiler/import-resolver.d.ts +0 -15
  222. package/build/compiler/import-resolver.js +0 -37
  223. package/build/compiler/import-resolver.js.map +0 -1
  224. package/build/compiler/index.d.ts +0 -2
  225. package/build/compiler/index.js +0 -19
  226. package/build/compiler/index.js.map +0 -1
  227. package/build/compiler/outputs/javascript.d.ts +0 -3
  228. package/build/compiler/outputs/javascript.js +0 -29
  229. package/build/compiler/outputs/javascript.js.map +0 -1
  230. package/build/compiler/outputs/json.d.ts +0 -2
  231. package/build/compiler/outputs/json.js +0 -8
  232. package/build/compiler/outputs/json.js.map +0 -1
  233. package/build/compiler/outputs/typescript.d.ts +0 -2
  234. package/build/compiler/outputs/typescript.js +0 -21
  235. package/build/compiler/outputs/typescript.js.map +0 -1
  236. package/build/parser/algorithms/lr.d.ts +0 -7
  237. package/build/parser/algorithms/lr.js +0 -108
  238. package/build/parser/algorithms/lr.js.map +0 -5
  239. package/build/parser/algorithms/lr0.d.ts +0 -7
  240. package/build/parser/algorithms/lr0.js +0 -156
  241. package/build/parser/algorithms/lr0.js.map +0 -1
  242. package/build/typings.d.ts +0 -226
  243. package/build/typings.js +0 -3
  244. package/build/typings.js.map +0 -1
  245. package/src/compiler/builtin/json.gwell +0 -74
  246. package/src/compiler/builtin/number.gwell +0 -20
  247. package/src/compiler/builtin/string.gwell +0 -48
  248. package/src/compiler/builtin/whitespace.gwell +0 -10
  249. package/src/compiler/builtin.json +0 -1
  250. package/src/compiler/compiler.ts +0 -265
  251. package/src/compiler/generator/artifacts/standard.ts +0 -26
  252. package/src/compiler/generator/generator.ts +0 -237
  253. package/src/compiler/gwell.gwell +0 -294
  254. package/src/compiler/gwell.js +0 -578
  255. package/src/compiler/import-resolver.ts +0 -36
  256. package/src/compiler/index.ts +0 -2
  257. package/src/compiler/outputs/javascript.ts +0 -27
  258. package/src/compiler/outputs/json.ts +0 -5
  259. package/src/compiler/outputs/typescript.ts +0 -18
  260. package/src/parser/parser.ts +0 -77
  261. package/src/typings.ts +0 -248
  262. package/testing.ts +0 -18
@@ -1,578 +0,0 @@
1
- // Generated automatically by Grammar-Well, version unknown
2
- // https://github.com/0x6563/grammar-well
3
-
4
- function GWLanguage(){
5
-
6
- return {
7
- grammar: {
8
- start: "main",
9
- rules: {
10
- main: [
11
- { name: "main", symbols: [ "_", "section_list", "_" ], postprocess: ({data}) => { return data[1]; } }
12
- ],
13
- section_list: [
14
- { name: "section_list", symbols: [ "section" ], postprocess: ({data}) => { return [data[0]]; } },
15
- { name: "section_list", symbols: [ "section", "T_WS", "section_list" ], postprocess: ({data}) => { return [data[0]].concat(data[2]); } }
16
- ],
17
- section: [
18
- { name: "section", symbols: [ "K_CONFIG", "_", "L_COLON", "_", "L_TEMPLATEL", "_", "kv_list", "_", "L_TEMPLATER" ], postprocess: ({data}) => { return { config: Object.assign(...data[6]) }; } },
19
- { name: "section", symbols: [ "K_IMPORT", "_", "L_STAR", "_", "K_FROM", "__", "T_WORD", "_", "L_SCOLON" ], postprocess: ({data}) => { return { import: data[6] }; } },
20
- { name: "section", symbols: [ "K_IMPORT", "_", "L_STAR", "_", "K_FROM", "__", "T_STRING", "_", "L_SCOLON" ], postprocess: ({data}) => { return { import: data[6], path: true }; } },
21
- { name: "section", symbols: [ "K_IMPORT", "_", "L_STAR", "_", { literal: "as" }, "_", "T_WORD", "_", "K_FROM", "__", "T_WORD", "_", "L_SCOLON" ], postprocess: ({data}) => { return { import: data[10], alias: data[6]}; } },
22
- { name: "section", symbols: [ "K_IMPORT", "_", "L_STAR", "_", { literal: "as" }, "_", "T_WORD", "_", "K_FROM", "__", "T_STRING", "_", "L_SCOLON" ], postprocess: ({data}) => { return { import: data[10], path: true, alias: data[6]}; } },
23
- { name: "section", symbols: [ "K_LEXER", "_", "L_COLON", "_", "L_TEMPLATEL", "_", "lexer", "_", "L_TEMPLATER" ], postprocess: ({data}) => { return { lexer: Object.assign(...data[6]) }; } },
24
- { name: "section", symbols: [ "K_GRAMMAR", "_", "L_COLON", "_", "L_TEMPLATEL", "_", "grammar", "_", "L_TEMPLATER" ], postprocess: ({data}) => { return { grammar: data[6] }; } },
25
- { name: "section", symbols: [ "K_BODY", "_", "L_COLON", "_", "T_JS" ], postprocess: ({data}) => { return { body: data[4] }; } },
26
- { name: "section", symbols: [ "K_BODY", "_", "L_COLON", "_", "T_STRING" ], postprocess: ({data}) => { return { body: data[4], path: true }; } },
27
- { name: "section", symbols: [ "K_HEAD", "_", "L_COLON", "_", "T_JS" ], postprocess: ({data}) => { return { head: data[4] }; } },
28
- { name: "section", symbols: [ "K_HEAD", "_", "L_COLON", "_", "T_STRING" ], postprocess: ({data}) => { return { head: data[4], path: true }; } }
29
- ],
30
- lexer: [
31
- { name: "lexer", symbols: [ "kv_list", "_", "state_list" ], postprocess: ({data}) => { return data[0].concat({ states: data[2] }); } },
32
- { name: "lexer", symbols: [ "state_list" ], postprocess: ({data}) => { return [{ states: data[0] }]; } }
33
- ],
34
- state_list: [
35
- { name: "state_list", symbols: [ "state" ], postprocess: ({data}) => { return data; } },
36
- { name: "state_list", symbols: [ "state", "_", "state_list" ], postprocess: ({data}) => { return [data[0]].concat(data[2]); } }
37
- ],
38
- state: [
39
- { name: "state", symbols: [ "state_declare", "_", "state_definition" ], postprocess: ({data}) => { return Object.assign({ name: data[0] }, data[2]); } }
40
- ],
41
- state_declare: [
42
- { name: "state_declare", symbols: [ "T_WORD", "_", "L_ARROW" ], postprocess: ({data}) => { return data[0]; } }
43
- ],
44
- state_definition: [
45
- { name: "state_definition", symbols: [ "kv_list", "_", "token_list" ], postprocess: ({data}) => { return Object.assign(...data[0], { rules: data[2] }); } },
46
- { name: "state_definition", symbols: [ "token_list" ], postprocess: ({data}) => { return { rules: data[0] }; } }
47
- ],
48
- token_list: [
49
- { name: "token_list", symbols: [ "token" ], postprocess: ({data}) => { return data; } },
50
- { name: "token_list", symbols: [ "token", "_", "token_list" ], postprocess: ({data}) => { return [data[0]].concat(data[2]); } }
51
- ],
52
- token: [
53
- { name: "token", symbols: [ "L_DASH", "_", "K_IMPORT", "_", "L_COLON", "_", "word_list" ], postprocess: ({data}) => { return { import: data[6] }; } },
54
- { name: "token", symbols: [ "L_DASH", "_", "token_definition_list" ], postprocess: ({data}) => { return Object.assign(...data[2]); } }
55
- ],
56
- token_definition_list: [
57
- { name: "token_definition_list", symbols: [ "token_definition" ], postprocess: ({data}) => { return data; } },
58
- { name: "token_definition_list", symbols: [ "token_definition", "_", "token_definition_list" ], postprocess: ({data}) => { return [data[0]].concat(data[2]); } }
59
- ],
60
- token_definition: [
61
- { name: "token_definition", symbols: [ "K_TAG", "_", "L_COLON", "_", "string_list" ], postprocess: ({data}) => { return { tag: data[4] }; } },
62
- { name: "token_definition", symbols: [ "K_WHEN", "_", "L_COLON", "_", "T_STRING" ], postprocess: ({data}) => { return { when: data[4] }; } },
63
- { name: "token_definition", symbols: [ "K_WHEN", "_", "L_COLON", "_", "T_REGEX" ], postprocess: ({data}) => { return { when: data[4] }; } },
64
- { name: "token_definition", symbols: [ "K_OPEN", "_", "L_COLON", "_", "T_STRING" ], postprocess: ({data}) => { return { open: data[4] }; } },
65
- { name: "token_definition", symbols: [ "K_CLOSE", "_", "L_COLON", "_", "T_STRING" ], postprocess: ({data}) => { return { close: data[4] }; } },
66
- { name: "token_definition", symbols: [ "K_BEFORE", "_", "L_COLON", "_", "T_STRING" ], postprocess: ({data}) => { return { when: data[4], before:true }; } },
67
- { name: "token_definition", symbols: [ "K_BEFORE", "_", "L_COLON", "_", "T_REGEX" ], postprocess: ({data}) => { return { when: data[4], before:true }; } },
68
- { name: "token_definition", symbols: [ "K_POP" ], postprocess: ({data}) => { return { pop: 1 }; } },
69
- { name: "token_definition", symbols: [ "K_POP", "_", "L_COLON", "_", "T_INTEGER" ], postprocess: ({data}) => { return { pop: parseInt(data[4]) }; } },
70
- { name: "token_definition", symbols: [ "K_POP", "_", "L_COLON", "_", "K_ALL" ], postprocess: ({data}) => { return { pop: "all" }; } },
71
- { name: "token_definition", symbols: [ "K_HIGHLIGHT", "_", "L_COLON", "_", "T_STRING" ], postprocess: ({data}) => { return { highlight: data[4] }; } },
72
- { name: "token_definition", symbols: [ "K_EMBED", "_", "L_COLON", "_", "T_STRING" ], postprocess: ({data}) => { return { embed: data[4] }; } },
73
- { name: "token_definition", symbols: [ "K_UNEMBED" ], postprocess: ({data}) => { return { unembed: true }; } },
74
- { name: "token_definition", symbols: [ "K_INSET" ], postprocess: ({data}) => { return { inset: 1 }; } },
75
- { name: "token_definition", symbols: [ "K_INSET", "_", "L_COLON", "_", "T_INTEGER" ], postprocess: ({data}) => { return { inset: parseInt(data[4]) }; } },
76
- { name: "token_definition", symbols: [ "K_SET", "_", "L_COLON", "_", "T_WORD" ], postprocess: ({data}) => { return { set: data[4] }; } },
77
- { name: "token_definition", symbols: [ "K_GOTO", "_", "L_COLON", "_", "T_WORD" ], postprocess: ({data}) => { return { goto: data[4] }; } },
78
- { name: "token_definition", symbols: [ "K_TYPE", "_", "L_COLON", "_", "T_STRING" ], postprocess: ({data}) => { return { type: data[4] }; } }
79
- ],
80
- grammar: [
81
- { name: "grammar", symbols: [ "kv_list", "_", "grammar_rule_list" ], postprocess: ({data}) => { return { config: Object.assign(...data[0]), rules: data[2] }; } },
82
- { name: "grammar", symbols: [ "grammar_rule_list" ], postprocess: ({data}) => { return { rules: data[0] }; } }
83
- ],
84
- grammar_rule_list: [
85
- { name: "grammar_rule_list", symbols: [ "grammar_rule" ], postprocess: ({data}) => { return [data[0]]; } },
86
- { name: "grammar_rule_list", symbols: [ "grammar_rule", "_", "grammar_rule_list" ], postprocess: ({data}) => { return [data[0]].concat(data[2]); } }
87
- ],
88
- grammar_rule: [
89
- { name: "grammar_rule", symbols: [ "T_WORD", "_", "L_ARROW", "_", "expression_list" ], postprocess: ({data}) => { return { name: data[0], expressions: data[4] }; } },
90
- { name: "grammar_rule", symbols: [ "T_WORD", "__", "L_COLON", "_", "T_JS", "_", "L_ARROW", "_", "expression_list" ], postprocess: ({data}) => { return { name: data[0], expressions: data[8], postprocess: data[4] }; } },
91
- { name: "grammar_rule", symbols: [ "T_WORD", "__", "L_COLON", "_", "T_GRAMMAR_TEMPLATE", "_", "L_ARROW", "_", "expression_list" ], postprocess: ({data}) => { return { name: data[0], expressions: data[8], postprocess: data[4] }; } }
92
- ],
93
- expression_list: [
94
- { name: "expression_list", symbols: [ "expression" ] },
95
- { name: "expression_list", symbols: [ "expression_list", "_", "L_PIPE", "_", "expression" ], postprocess: ({data}) => { return data[0].concat([data[4]]); } }
96
- ],
97
- expression: [
98
- { name: "expression", symbols: [ "expression_symbol_list" ], postprocess: ({data}) => { return { symbols: data[0] }; } },
99
- { name: "expression", symbols: [ "expression_symbol_list", "__", "L_COLON", "_", "T_JS" ], postprocess: ({data}) => { return { symbols: data[0], postprocess: data[4] }; } },
100
- { name: "expression", symbols: [ "expression_symbol_list", "__", "L_COLON", "_", "T_GRAMMAR_TEMPLATE" ], postprocess: ({data}) => { return { symbols: data[0], postprocess: data[4] }; } }
101
- ],
102
- expression_symbol_list: [
103
- { name: "expression_symbol_list", symbols: [ "expression_symbol" ] },
104
- { name: "expression_symbol_list", symbols: [ "expression_symbol_list", "T_WS", "expression_symbol" ], postprocess: ({data}) => { return data[0].concat([data[2]]); } }
105
- ],
106
- expression_symbol: [
107
- { name: "expression_symbol", symbols: [ "expression_symbol_match" ], postprocess: ({data}) => { return data[0]; } },
108
- { name: "expression_symbol", symbols: [ "expression_symbol_match", "L_COLON", "T_WORD" ], postprocess: ({data}) => { return { ...data[0], alias: data[2] }; } },
109
- { name: "expression_symbol", symbols: [ "expression_symbol_match", "expression_repeater" ], postprocess: ({data}) => { return { expression: data[0], repeat: data[1] }; } },
110
- { name: "expression_symbol", symbols: [ "expression_symbol_match", "expression_repeater", "L_COLON", "T_WORD" ], postprocess: ({data}) => { return { expression: data[0], repeat: data[1], alias: data[4] }; } }
111
- ],
112
- expression_symbol_match: [
113
- { name: "expression_symbol_match", symbols: [ "T_WORD" ], postprocess: ({data}) => { return { rule: data[0] }; } },
114
- { name: "expression_symbol_match", symbols: [ "T_STRING", "expression_symbol_match$RPT01x1" ], postprocess: ({data}) => { return { literal: data[0], insensitive: !!data[1] }; } },
115
- { name: "expression_symbol_match", symbols: [ "L_DSIGN", "T_WORD" ], postprocess: ({data}) => { return { token: data[1]}; } },
116
- { name: "expression_symbol_match", symbols: [ "L_DSIGN", "T_STRING" ], postprocess: ({data}) => { return { token: data[1]}; } },
117
- { name: "expression_symbol_match", symbols: [ "T_REGEX" ], postprocess: ({data}) => { return data[0]; } },
118
- { name: "expression_symbol_match", symbols: [ "L_PARENL", "_", "expression_list", "_", "L_PARENR" ], postprocess: ({data}) => { return { subexpression: data[2] }; } },
119
- { name: "expression_symbol_match", symbols: [ "T_JS" ], postprocess: ({data}) => { return data[0]; } }
120
- ],
121
- expression_symbol_match$RPT01x1: [
122
- { name: "expression_symbol_match$RPT01x1", symbols: [ { literal: "i" } ], postprocess: ({data}) => data[0] },
123
- { name: "expression_symbol_match$RPT01x1", symbols: [ ], postprocess: () => null }
124
- ],
125
- expression_repeater: [
126
- { name: "expression_repeater", symbols: [ "L_QMARK" ], postprocess: ({data}) => { return data[0][0].value; } },
127
- { name: "expression_repeater", symbols: [ "L_PLUS" ], postprocess: ({data}) => { return data[0][0].value; } },
128
- { name: "expression_repeater", symbols: [ "L_STAR" ], postprocess: ({data}) => { return data[0][0].value; } }
129
- ],
130
- kv_list: [
131
- { name: "kv_list", symbols: [ "kv" ], postprocess: ({data}) => { return data; } },
132
- { name: "kv_list", symbols: [ "kv", "_", "kv_list" ], postprocess: ({data}) => { return [data[0]].concat(data[2]); } }
133
- ],
134
- kv$SUBx1: [
135
- { name: "kv$SUBx1", symbols: [ "T_WORD" ] },
136
- { name: "kv$SUBx1", symbols: [ "T_STRING" ] },
137
- { name: "kv$SUBx1", symbols: [ "T_INTEGER" ] },
138
- { name: "kv$SUBx1", symbols: [ "T_JS" ] },
139
- { name: "kv$SUBx1", symbols: [ "T_GRAMMAR_TEMPLATE" ] }
140
- ],
141
- kv: [
142
- { name: "kv", symbols: [ "T_WORD", "_", "L_COLON", "_", "kv$SUBx1" ], postprocess: ({data}) => { return { [data[0]]: data[4][0] }; } }
143
- ],
144
- string_list: [
145
- { name: "string_list", symbols: [ "T_STRING" ], postprocess: ({data}) => { return [data[0]]; } },
146
- { name: "string_list", symbols: [ "T_STRING", "_", "L_COMMA", "_", "string_list" ], postprocess: ({data}) => { return [data[0]].concat(data[4]); } }
147
- ],
148
- word_list: [
149
- { name: "word_list", symbols: [ "T_WORD" ], postprocess: ({data}) => { return [data[0]]; } },
150
- { name: "word_list", symbols: [ "T_WORD", "_", "L_COMMA", "_", "word_list" ], postprocess: ({data}) => { return [data[0]].concat(data[4]); } }
151
- ],
152
- _$RPT0Nx1: [
153
- { name: "_$RPT0Nx1", symbols: [ ] },
154
- { name: "_$RPT0Nx1", symbols: [ "_$RPT0Nx1", "_$RPT0Nx1$SUBx1" ], postprocess: ({data}) => data[0].concat([data[1]]) }
155
- ],
156
- _$RPT0Nx1$SUBx1: [
157
- { name: "_$RPT0Nx1$SUBx1", symbols: [ "T_WS" ] },
158
- { name: "_$RPT0Nx1$SUBx1", symbols: [ "T_COMMENT" ] }
159
- ],
160
- _: [
161
- { name: "_", symbols: [ "_$RPT0Nx1" ], postprocess: ({data}) => { return null; } }
162
- ],
163
- __$RPT1Nx1$SUBx1: [
164
- { name: "__$RPT1Nx1$SUBx1", symbols: [ "T_WS" ] },
165
- { name: "__$RPT1Nx1$SUBx1", symbols: [ "T_COMMENT" ] }
166
- ],
167
- __$RPT1Nx1: [
168
- { name: "__$RPT1Nx1", symbols: [ "__$RPT1Nx1$SUBx1" ] },
169
- { name: "__$RPT1Nx1", symbols: [ "__$RPT1Nx1", "__$RPT1Nx1$SUBx2" ], postprocess: ({data}) => data[0].concat([data[1]]) }
170
- ],
171
- __$RPT1Nx1$SUBx2: [
172
- { name: "__$RPT1Nx1$SUBx2", symbols: [ "T_WS" ] },
173
- { name: "__$RPT1Nx1$SUBx2", symbols: [ "T_COMMENT" ] }
174
- ],
175
- __: [
176
- { name: "__", symbols: [ "__$RPT1Nx1" ], postprocess: ({data}) => { return null; } }
177
- ],
178
- L_COLON: [
179
- { name: "L_COLON", symbols: [ { token: "L_COLON" } ] }
180
- ],
181
- L_SCOLON: [
182
- { name: "L_SCOLON", symbols: [ { token: "L_SCOLON" } ] }
183
- ],
184
- L_QMARK: [
185
- { name: "L_QMARK", symbols: [ { token: "L_QMARK" } ] }
186
- ],
187
- L_PLUS: [
188
- { name: "L_PLUS", symbols: [ { token: "L_PLUS" } ] }
189
- ],
190
- L_STAR: [
191
- { name: "L_STAR", symbols: [ { token: "L_STAR" } ] }
192
- ],
193
- L_COMMA: [
194
- { name: "L_COMMA", symbols: [ { token: "L_COMMA" } ] }
195
- ],
196
- L_PIPE: [
197
- { name: "L_PIPE", symbols: [ { token: "L_PIPE" } ] }
198
- ],
199
- L_PARENL: [
200
- { name: "L_PARENL", symbols: [ { token: "L_PARENL" } ] }
201
- ],
202
- L_PARENR: [
203
- { name: "L_PARENR", symbols: [ { token: "L_PARENR" } ] }
204
- ],
205
- L_TEMPLATEL: [
206
- { name: "L_TEMPLATEL", symbols: [ { token: "L_TEMPLATEL" } ] }
207
- ],
208
- L_TEMPLATER: [
209
- { name: "L_TEMPLATER", symbols: [ { token: "L_TEMPLATER" } ] }
210
- ],
211
- L_ARROW: [
212
- { name: "L_ARROW", symbols: [ { token: "L_ARROW" } ] }
213
- ],
214
- L_DSIGN: [
215
- { name: "L_DSIGN", symbols: [ { token: "L_DSIGN" } ] }
216
- ],
217
- L_DASH: [
218
- { name: "L_DASH", symbols: [ { token: "L_DASH" } ] }
219
- ],
220
- K_ALL: [
221
- { name: "K_ALL", symbols: [ { literal: "all" } ] }
222
- ],
223
- K_TAG: [
224
- { name: "K_TAG", symbols: [ { literal: "tag" } ] }
225
- ],
226
- K_FROM: [
227
- { name: "K_FROM", symbols: [ { literal: "from" } ] }
228
- ],
229
- K_TYPE: [
230
- { name: "K_TYPE", symbols: [ { literal: "type" } ] }
231
- ],
232
- K_WHEN: [
233
- { name: "K_WHEN", symbols: [ { literal: "when" } ] }
234
- ],
235
- K_POP: [
236
- { name: "K_POP", symbols: [ { literal: "pop" } ] }
237
- ],
238
- K_BEFORE: [
239
- { name: "K_BEFORE", symbols: [ { literal: "before" } ] }
240
- ],
241
- K_OPEN: [
242
- { name: "K_OPEN", symbols: [ { literal: "open" } ] }
243
- ],
244
- K_CLOSE: [
245
- { name: "K_CLOSE", symbols: [ { literal: "close" } ] }
246
- ],
247
- K_HIGHLIGHT: [
248
- { name: "K_HIGHLIGHT", symbols: [ { literal: "highlight" } ] }
249
- ],
250
- K_EMBED: [
251
- { name: "K_EMBED", symbols: [ { literal: "embed" } ] }
252
- ],
253
- K_UNEMBED: [
254
- { name: "K_UNEMBED", symbols: [ { literal: "unembed" } ] }
255
- ],
256
- K_INSET: [
257
- { name: "K_INSET", symbols: [ { literal: "inset" } ] }
258
- ],
259
- K_SET: [
260
- { name: "K_SET", symbols: [ { literal: "set" } ] }
261
- ],
262
- K_GOTO: [
263
- { name: "K_GOTO", symbols: [ { literal: "goto" } ] }
264
- ],
265
- K_CONFIG: [
266
- { name: "K_CONFIG", symbols: [ { literal: "config" } ] }
267
- ],
268
- K_LEXER: [
269
- { name: "K_LEXER", symbols: [ { literal: "lexer" } ] }
270
- ],
271
- K_GRAMMAR: [
272
- { name: "K_GRAMMAR", symbols: [ { literal: "grammar" } ] }
273
- ],
274
- K_IMPORT: [
275
- { name: "K_IMPORT", symbols: [ { literal: "import" } ] }
276
- ],
277
- K_BODY: [
278
- { name: "K_BODY", symbols: [ { literal: "body" } ] }
279
- ],
280
- K_HEAD: [
281
- { name: "K_HEAD", symbols: [ { literal: "head" } ] }
282
- ],
283
- T_JS$RPT0Nx1: [
284
- { name: "T_JS$RPT0Nx1", symbols: [ ] },
285
- { name: "T_JS$RPT0Nx1", symbols: [ "T_JS$RPT0Nx1", { token: "T_JSBODY" } ], postprocess: ({data}) => data[0].concat([data[1]]) }
286
- ],
287
- T_JS: [
288
- { name: "T_JS", symbols: [ { token: "L_JSL" }, "T_JS$RPT0Nx1", { token: "L_JSR" } ], postprocess: ({data}) => { return { js: data[1].map(v=>v.value).join('') }; } }
289
- ],
290
- T_GRAMMAR_TEMPLATE$RPT0Nx1: [
291
- { name: "T_GRAMMAR_TEMPLATE$RPT0Nx1", symbols: [ ] },
292
- { name: "T_GRAMMAR_TEMPLATE$RPT0Nx1", symbols: [ "T_GRAMMAR_TEMPLATE$RPT0Nx1", { token: "T_JSBODY" } ], postprocess: ({data}) => data[0].concat([data[1]]) }
293
- ],
294
- T_GRAMMAR_TEMPLATE: [
295
- { name: "T_GRAMMAR_TEMPLATE", symbols: [ { token: "L_TEMPLATEL" }, "_", "T_GRAMMAR_TEMPLATE$RPT0Nx1", "_", { token: "L_TEMPLATER" } ], postprocess: ({data}) => { return { template: data[2].map(v=>v.value).join('').trim() }; } }
296
- ],
297
- T_STRING: [
298
- { name: "T_STRING", symbols: [ { token: "T_STRING" } ], postprocess: ({data}) => { return JSON.parse(data[0].value); } }
299
- ],
300
- T_WORD: [
301
- { name: "T_WORD", symbols: [ { token: "T_WORD" } ], postprocess: ({data}) => { return data[0].value; } }
302
- ],
303
- T_REGEX$RPT0Nx1: [
304
- { name: "T_REGEX$RPT0Nx1", symbols: [ ] },
305
- { name: "T_REGEX$RPT0Nx1", symbols: [ "T_REGEX$RPT0Nx1", /[gmiuy]/ ], postprocess: ({data}) => data[0].concat([data[1]]) }
306
- ],
307
- T_REGEX: [
308
- { name: "T_REGEX", symbols: [ { token: "T_REGEX" }, "T_REGEX$RPT0Nx1" ], postprocess: ({data}) => { return { regex: data[0].value.replace(/\\\\\//g,'/').slice(1,-1), flags: data[1].map(v=>v.value).join('').trim() }; } }
309
- ],
310
- T_COMMENT: [
311
- { name: "T_COMMENT", symbols: [ { token: "T_COMMENT" } ] }
312
- ],
313
- T_INTEGER: [
314
- { name: "T_INTEGER", symbols: [ { token: "T_INTEGER" } ], postprocess: ({data}) => { return data[0].value; } }
315
- ],
316
- T_WS: [
317
- { name: "T_WS", symbols: [ { token: "T_WS" } ], postprocess: ({data}) => { return null; } }
318
- ]
319
- }
320
- },
321
- lexer: {
322
- start: "start",
323
- states: {
324
- start: {
325
- name: "start",
326
- rules: [
327
- { import: ["string","js","ws","comment","l_scolon","l_star"] },
328
- { when: /lexer(?![a-zA-Z\d_])/, tag: ["T_WORD"], highlight: "type", goto: "lexer" },
329
- { when: /grammar(?![a-zA-Z\d_])/, tag: ["T_WORD"], highlight: "type", goto: "grammar" },
330
- { when: /config(?![a-zA-Z\d_])/, tag: ["T_WORD"], highlight: "type", goto: "config" },
331
- { import: ["kv"] }
332
- ]
333
- },
334
- config: {
335
- name: "config",
336
- rules: [
337
- { import: ["ws","l_colon"] },
338
- { when: "{{", tag: ["L_TEMPLATEL"], set: "config_inner" }
339
- ]
340
- },
341
- config_inner: {
342
- name: "config_inner",
343
- rules: [
344
- { import: ["comment","kv"] },
345
- { when: "}}", tag: ["L_TEMPLATER"], pop: 1 }
346
- ]
347
- },
348
- grammar: {
349
- name: "grammar",
350
- rules: [
351
- { import: ["ws","l_colon"] },
352
- { when: "{{", tag: ["L_TEMPLATEL"], set: "grammar_inner" }
353
- ]
354
- },
355
- grammar_inner: {
356
- name: "grammar_inner",
357
- rules: [
358
- { import: ["comment","js","js_template","ws","regex","l_qmark","l_plus","l_star","kv","l_colon","l_comma","l_pipe","l_parenl","l_parenr","l_arrow","l_dsign","l_dash"] },
359
- { when: "}}", tag: ["L_TEMPLATER"], pop: 1 }
360
- ]
361
- },
362
- lexer: {
363
- name: "lexer",
364
- rules: [
365
- { import: ["ws","l_colon"] },
366
- { when: "{{", tag: ["L_TEMPLATEL"], set: "lexer_inner" }
367
- ]
368
- },
369
- lexer_inner: {
370
- name: "lexer_inner",
371
- rules: [
372
- { import: ["ws","comment","regex","l_comma","l_arrow","l_dash","kv","js"] },
373
- { when: "}}", tag: ["L_TEMPLATER"], pop: 1 }
374
- ]
375
- },
376
- js: {
377
- name: "js",
378
- rules: [
379
- { when: "${", tag: ["L_JSL"], goto: "js_wrap" }
380
- ]
381
- },
382
- js_wrap: {
383
- name: "js_wrap",
384
- default: "T_JSBODY",
385
- unmatched: "T_JSBODY",
386
- rules: [
387
- { import: ["jsignore"] },
388
- { when: "{", tag: ["T_JSBODY"], goto: "js_literal" },
389
- { when: "}", tag: ["L_JSR"], pop: 1 }
390
- ]
391
- },
392
- js_literal: {
393
- name: "js_literal",
394
- default: "T_JSBODY",
395
- unmatched: "T_JSBODY",
396
- rules: [
397
- { import: ["jsignore"] },
398
- { when: "{", tag: ["T_JSBODY"], goto: "js_literal" },
399
- { when: "}", tag: ["T_JSBODY"], pop: 1 }
400
- ]
401
- },
402
- js_template: {
403
- name: "js_template",
404
- rules: [
405
- { when: "{{", tag: ["L_TEMPLATEL"], goto: "js_template_inner" }
406
- ]
407
- },
408
- js_template_inner: {
409
- name: "js_template_inner",
410
- default: "T_JSBODY",
411
- unmatched: "T_JSBODY",
412
- rules: [
413
- { import: ["jsignore"] },
414
- { when: "{", tag: ["T_JSBODY"], goto: "js_literal" },
415
- { when: "}}", tag: ["L_TEMPLATER"], pop: 1 }
416
- ]
417
- },
418
- kv: {
419
- name: "kv",
420
- rules: [
421
- { import: ["string","ws","word","l_colon","integer"] }
422
- ]
423
- },
424
- jsignore: {
425
- name: "jsignore",
426
- rules: [
427
- { when: /"(?:[^"\\\r\n]|\\.)*"/, tag: ["T_JSBODY"] },
428
- { when: /'(?:[^'\\\r\n]|\\.)*'/, tag: ["T_JSBODY"] },
429
- { when: /`(?:[^`\\]|\\.)*`/, tag: ["T_JSBODY"] },
430
- { when: /\/(?:[^\/\\\r\n]|\\.)+\/[gmiyu]*/, tag: ["T_JSBODY"] },
431
- { when: /\/\/[^\n]*/, tag: ["T_JSBODY"] },
432
- { when: /\/\*.*\*\//, tag: ["T_JSBODY"] }
433
- ]
434
- },
435
- string: {
436
- name: "string",
437
- rules: [
438
- { when: /"(?:[^"\\\r\n]|\\.)*"/, tag: ["T_STRING"], highlight: "string" }
439
- ]
440
- },
441
- string2: {
442
- name: "string2",
443
- rules: [
444
- { when: /'(?:[^'\\\r\n]|\\.)*'/, tag: ["T_STRING"], highlight: "string" }
445
- ]
446
- },
447
- string3: {
448
- name: "string3",
449
- rules: [
450
- { when: /`(?:[^`\\]|\\.)*`/, tag: ["T_STRING"], highlight: "string" }
451
- ]
452
- },
453
- regex: {
454
- name: "regex",
455
- rules: [
456
- { when: /\/(?:[^\/\\\r\n]|\\.)+\//, tag: ["T_REGEX"], highlight: "regexp" }
457
- ]
458
- },
459
- integer: {
460
- name: "integer",
461
- rules: [
462
- { when: /\d+/, tag: ["T_INTEGER"], highlight: "number" }
463
- ]
464
- },
465
- word: {
466
- name: "word",
467
- rules: [
468
- { when: /[a-zA-Z_][a-zA-Z_\d]*/, tag: ["T_WORD"] }
469
- ]
470
- },
471
- ws: {
472
- name: "ws",
473
- rules: [
474
- { when: /\s+/, tag: ["T_WS"] }
475
- ]
476
- },
477
- l_colon: {
478
- name: "l_colon",
479
- rules: [
480
- { when: ":", tag: ["L_COLON"], highlight: "keyword" }
481
- ]
482
- },
483
- l_scolon: {
484
- name: "l_scolon",
485
- rules: [
486
- { when: ";", tag: ["L_SCOLON"] }
487
- ]
488
- },
489
- l_qmark: {
490
- name: "l_qmark",
491
- rules: [
492
- { when: "?", tag: ["L_QMARK"] }
493
- ]
494
- },
495
- l_plus: {
496
- name: "l_plus",
497
- rules: [
498
- { when: "+", tag: ["L_PLUS"] }
499
- ]
500
- },
501
- l_star: {
502
- name: "l_star",
503
- rules: [
504
- { when: "*", tag: ["L_STAR"] }
505
- ]
506
- },
507
- l_comma: {
508
- name: "l_comma",
509
- rules: [
510
- { when: ",", tag: ["L_COMMA"] }
511
- ]
512
- },
513
- l_pipe: {
514
- name: "l_pipe",
515
- rules: [
516
- { when: "|", tag: ["L_PIPE"], highlight: "keyword" }
517
- ]
518
- },
519
- l_parenl: {
520
- name: "l_parenl",
521
- rules: [
522
- { when: "(", tag: ["L_PARENL"] }
523
- ]
524
- },
525
- l_parenr: {
526
- name: "l_parenr",
527
- rules: [
528
- { when: ")", tag: ["L_PARENR"] }
529
- ]
530
- },
531
- l_templatel: {
532
- name: "l_templatel",
533
- rules: [
534
- { when: "{{", tag: ["L_TEMPLATEL"] }
535
- ]
536
- },
537
- l_templater: {
538
- name: "l_templater",
539
- rules: [
540
- { when: "}}", tag: ["L_TEMPLATER"] }
541
- ]
542
- },
543
- l_arrow: {
544
- name: "l_arrow",
545
- rules: [
546
- { when: "->", tag: ["L_ARROW"], highlight: "keyword" }
547
- ]
548
- },
549
- l_dsign: {
550
- name: "l_dsign",
551
- rules: [
552
- { when: "$", tag: ["L_DSIGN"] }
553
- ]
554
- },
555
- l_dash: {
556
- name: "l_dash",
557
- rules: [
558
- { when: "-", tag: ["L_DASH"] }
559
- ]
560
- },
561
- comment: {
562
- name: "comment",
563
- rules: [
564
- { when: /\/\/[^\n]*/, tag: ["T_COMMENT"], highlight: "comment" }
565
- ]
566
- },
567
- commentmulti: {
568
- name: "commentmulti",
569
- rules: [
570
- { when: /\/\*.*\*\//, tag: ["T_COMMENT"], highlight: "comment" }
571
- ]
572
- }
573
- }
574
- }
575
- }
576
- }
577
-
578
- export default GWLanguage;
@@ -1,36 +0,0 @@
1
- /// <reference types="typescript/lib/lib.webworker" />
2
- import { ImportResolver } from "../typings";
3
- export class FileSystemResolver implements ImportResolver {
4
- private baseDir: string;
5
- private readFile: (path: string, type: string) => Promise<string>;
6
- private resolve: (path: string, ...paths: string[]) => string;
7
-
8
- constructor(baseDir: string) {
9
- const { readFile } = require('fs');
10
- const { resolve, dirname } = require('path');
11
- const { promisify } = require('util');
12
- this.readFile = promisify(readFile);
13
- this.resolve = resolve;
14
- this.baseDir = baseDir ? dirname(baseDir) : process?.cwd();
15
- }
16
-
17
- path(path: string) {
18
- return this.resolve(this.baseDir, path);
19
- }
20
-
21
- body(path: string) {
22
- return this.readFile(path, 'utf-8');
23
- }
24
- }
25
-
26
- export class BrowserImportResolver implements ImportResolver {
27
- constructor(private baseURL: string) { }
28
-
29
- path(path: string) {
30
- return (new URL(path, this.baseURL)).href;
31
- }
32
-
33
- async body(path: string) {
34
- return (await fetch(path)).text();
35
- }
36
- }
@@ -1,2 +0,0 @@
1
- export * from './compiler';
2
- export * from './import-resolver';
@@ -1,27 +0,0 @@
1
- import { Generator } from "../generator/generator";
2
-
3
- export function JavascriptOutput(generator: Generator, exportName: string) {
4
- return `${Generate(generator, exportName)}
5
-
6
- if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
7
- module.exports = ${exportName};
8
- } else {
9
- window.${exportName} = ${exportName};
10
- }`;
11
- }
12
-
13
- export function ESMOutput(generator: Generator, exportName: string) {
14
- return `${Generate(generator, exportName)}
15
-
16
- export default ${exportName};`;
17
- }
18
-
19
- function Generate(generator: Generator, exportName: string) {
20
- return `// Generated automatically by Grammar-Well, version ${generator.state.version}
21
- // https://github.com/0x6563/grammar-well
22
- ${generator.serializeHead()}
23
- function ${exportName}(){
24
- ${generator.serializeBody()}
25
- return ${generator.serializeLanguage(1)}
26
- }`;
27
- }
@@ -1,5 +0,0 @@
1
- import { Generator } from "../generator/generator";
2
-
3
- export function JSONFormatter(generator: Generator, exportName) {
4
- return JSON.stringify({ state: generator.state, exportName });
5
- }