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
@@ -0,0 +1,620 @@
1
+ // Generated automatically by Grammar-Well, version unknown
2
+ // https://github.com/0x6563/grammar-well
3
+ // @ts-nocheck
4
+
5
+
6
+
7
+ class grammar {
8
+ artifacts = {
9
+ grammar: {
10
+ rules: {
11
+ K_ALL: [
12
+ { name: "K_ALL", symbols: [ { literal: "all" } ] }
13
+ ],
14
+ K_BEFORE: [
15
+ { name: "K_BEFORE", symbols: [ { literal: "before" } ] }
16
+ ],
17
+ K_BODY: [
18
+ { name: "K_BODY", symbols: [ { literal: "body" } ] }
19
+ ],
20
+ K_CLOSE: [
21
+ { name: "K_CLOSE", symbols: [ { literal: "close" } ] }
22
+ ],
23
+ K_CONFIG: [
24
+ { name: "K_CONFIG", symbols: [ { literal: "config" } ] }
25
+ ],
26
+ K_EMBED: [
27
+ { name: "K_EMBED", symbols: [ { literal: "embed" } ] }
28
+ ],
29
+ K_FROM: [
30
+ { name: "K_FROM", symbols: [ { literal: "from" } ] }
31
+ ],
32
+ K_GOTO: [
33
+ { name: "K_GOTO", symbols: [ { literal: "goto" } ] }
34
+ ],
35
+ K_GRAMMAR: [
36
+ { name: "K_GRAMMAR", symbols: [ { literal: "grammar" } ] }
37
+ ],
38
+ K_HEAD: [
39
+ { name: "K_HEAD", symbols: [ { literal: "head" } ] }
40
+ ],
41
+ K_HIGHLIGHT: [
42
+ { name: "K_HIGHLIGHT", symbols: [ { literal: "highlight" } ] }
43
+ ],
44
+ K_IMPORT: [
45
+ { name: "K_IMPORT", symbols: [ { literal: "import" } ] }
46
+ ],
47
+ K_INSET: [
48
+ { name: "K_INSET", symbols: [ { literal: "inset" } ] }
49
+ ],
50
+ K_LEXER: [
51
+ { name: "K_LEXER", symbols: [ { literal: "lexer" } ] }
52
+ ],
53
+ K_OPEN: [
54
+ { name: "K_OPEN", symbols: [ { literal: "open" } ] }
55
+ ],
56
+ K_POP: [
57
+ { name: "K_POP", symbols: [ { literal: "pop" } ] }
58
+ ],
59
+ K_SET: [
60
+ { name: "K_SET", symbols: [ { literal: "set" } ] }
61
+ ],
62
+ K_TAG: [
63
+ { name: "K_TAG", symbols: [ { literal: "tag" } ] }
64
+ ],
65
+ K_TYPE: [
66
+ { name: "K_TYPE", symbols: [ { literal: "type" } ] }
67
+ ],
68
+ K_UNEMBED: [
69
+ { name: "K_UNEMBED", symbols: [ { literal: "unembed" } ] }
70
+ ],
71
+ K_WHEN: [
72
+ { name: "K_WHEN", symbols: [ { literal: "when" } ] }
73
+ ],
74
+ L_ARROW: [
75
+ { name: "L_ARROW", symbols: [ { token: "L_ARROW" } ] }
76
+ ],
77
+ L_COLON: [
78
+ { name: "L_COLON", symbols: [ { token: "L_COLON" } ] }
79
+ ],
80
+ L_COMMA: [
81
+ { name: "L_COMMA", symbols: [ { token: "L_COMMA" } ] }
82
+ ],
83
+ L_DASH: [
84
+ { name: "L_DASH", symbols: [ { token: "L_DASH" } ] }
85
+ ],
86
+ L_DSIGN: [
87
+ { name: "L_DSIGN", symbols: [ { token: "L_DSIGN" } ] }
88
+ ],
89
+ L_PARENL: [
90
+ { name: "L_PARENL", symbols: [ { token: "L_PARENL" } ] }
91
+ ],
92
+ L_PARENR: [
93
+ { name: "L_PARENR", symbols: [ { token: "L_PARENR" } ] }
94
+ ],
95
+ L_PIPE: [
96
+ { name: "L_PIPE", symbols: [ { token: "L_PIPE" } ] }
97
+ ],
98
+ L_PLUS: [
99
+ { name: "L_PLUS", symbols: [ { token: "L_PLUS" } ] }
100
+ ],
101
+ L_QMARK: [
102
+ { name: "L_QMARK", symbols: [ { token: "L_QMARK" } ] }
103
+ ],
104
+ L_SCOLON: [
105
+ { name: "L_SCOLON", symbols: [ { token: "L_SCOLON" } ] }
106
+ ],
107
+ L_STAR: [
108
+ { name: "L_STAR", symbols: [ { token: "L_STAR" } ] }
109
+ ],
110
+ L_TEMPLATEL: [
111
+ { name: "L_TEMPLATEL", symbols: [ { token: "L_TEMPLATEL" } ] }
112
+ ],
113
+ L_TEMPLATER: [
114
+ { name: "L_TEMPLATER", symbols: [ { token: "L_TEMPLATER" } ] }
115
+ ],
116
+ T_COMMENT: [
117
+ { name: "T_COMMENT", symbols: [ { token: "T_COMMENT" } ] }
118
+ ],
119
+ T_GRAMMAR_TEMPLATE: [
120
+ { name: "T_GRAMMAR_TEMPLATE", postprocess: ({data}) => { return ({ template: '(' + data[2].map(v=>v.value).join('').trim() + ')' }); }, symbols: [ { token: "L_TEMPLATEL" }, "_", "T_GRAMMAR_TEMPLATE.RPT0Nx1", "_", { token: "L_TEMPLATER" } ] }
121
+ ],
122
+ "T_GRAMMAR_TEMPLATE.RPT0Nx1": [
123
+ { name: "T_GRAMMAR_TEMPLATE.RPT0Nx1", symbols: [ ] },
124
+ { name: "T_GRAMMAR_TEMPLATE.RPT0Nx1", postprocess: ({data}) => data[0].concat([data[1]]), symbols: [ "T_GRAMMAR_TEMPLATE.RPT0Nx1", { token: "T_JSBODY" } ] }
125
+ ],
126
+ T_INTEGER: [
127
+ { name: "T_INTEGER", postprocess: ({data}) => { return (data[0].value); }, symbols: [ { token: "T_INTEGER" } ] }
128
+ ],
129
+ T_JS: [
130
+ { name: "T_JS", postprocess: ({data}) => { return ({ js: data[1].map(v=>v.value).join('') }); }, symbols: [ { token: "L_JSL" }, "T_JS.RPT0Nx1", { token: "L_JSR" } ] }
131
+ ],
132
+ "T_JS.RPT0Nx1": [
133
+ { name: "T_JS.RPT0Nx1", symbols: [ ] },
134
+ { name: "T_JS.RPT0Nx1", postprocess: ({data}) => data[0].concat([data[1]]), symbols: [ "T_JS.RPT0Nx1", { token: "T_JSBODY" } ] }
135
+ ],
136
+ T_REGEX: [
137
+ { name: "T_REGEX", postprocess: ({data}) => { return ({ regex: data[0].value.slice(1,-1), flags: data[1].map(v=>v.value).join('').trim() }); }, symbols: [ { token: "T_REGEX" }, "T_REGEX.RPT0Nx1" ] }
138
+ ],
139
+ "T_REGEX.RPT0Nx1": [
140
+ { name: "T_REGEX.RPT0Nx1", symbols: [ ] },
141
+ { name: "T_REGEX.RPT0Nx1", postprocess: ({data}) => data[0].concat([data[1]]), symbols: [ "T_REGEX.RPT0Nx1", /[gmiuy]/ ] }
142
+ ],
143
+ T_STRING: [
144
+ { name: "T_STRING", postprocess: ({data}) => { return (JSON.parse(data[0].value)); }, symbols: [ { token: "T_STRING" } ] }
145
+ ],
146
+ T_WORD: [
147
+ { name: "T_WORD", postprocess: ({data}) => { return (data[0].value); }, symbols: [ { token: "T_WORD" } ] }
148
+ ],
149
+ T_WS: [
150
+ { name: "T_WS", postprocess: ({data}) => { return (null); }, symbols: [ { token: "T_WS" } ] }
151
+ ],
152
+ _: [
153
+ { name: "_", postprocess: ({data}) => { return (null); }, symbols: [ "_.RPT0Nx1" ] }
154
+ ],
155
+ "_.RPT0Nx1": [
156
+ { name: "_.RPT0Nx1", symbols: [ ] },
157
+ { name: "_.RPT0Nx1", postprocess: ({data}) => data[0].concat([data[1]]), symbols: [ "_.RPT0Nx1", "_.RPT0Nx1.SUBx1" ] }
158
+ ],
159
+ "_.RPT0Nx1.SUBx1": [
160
+ { name: "_.RPT0Nx1.SUBx1", symbols: [ "T_WS" ] },
161
+ { name: "_.RPT0Nx1.SUBx1", symbols: [ "T_COMMENT" ] }
162
+ ],
163
+ __: [
164
+ { name: "__", postprocess: ({data}) => { return (null); }, symbols: [ "__.RPT1Nx1" ] }
165
+ ],
166
+ "__.RPT1Nx1": [
167
+ { name: "__.RPT1Nx1", symbols: [ "__.RPT1Nx1.SUBx1" ] },
168
+ { name: "__.RPT1Nx1", postprocess: ({data}) => data[0].concat([data[1]]), symbols: [ "__.RPT1Nx1", "__.RPT1Nx1.SUBx2" ] }
169
+ ],
170
+ "__.RPT1Nx1.SUBx1": [
171
+ { name: "__.RPT1Nx1.SUBx1", symbols: [ "T_WS" ] },
172
+ { name: "__.RPT1Nx1.SUBx1", symbols: [ "T_COMMENT" ] }
173
+ ],
174
+ "__.RPT1Nx1.SUBx2": [
175
+ { name: "__.RPT1Nx1.SUBx2", symbols: [ "T_WS" ] },
176
+ { name: "__.RPT1Nx1.SUBx2", symbols: [ "T_COMMENT" ] }
177
+ ],
178
+ expression: [
179
+ { name: "expression", postprocess: ({data}) => { return ({ symbols: data[0] }); }, symbols: [ "expression_symbol_list" ] },
180
+ { name: "expression", postprocess: ({data}) => { return ({ symbols: data[0], postprocess: data[4] }); }, symbols: [ "expression_symbol_list", "__", "L_COLON", "_", "T_JS" ] },
181
+ { name: "expression", postprocess: ({data}) => { return ({ symbols: data[0], postprocess: data[4] }); }, symbols: [ "expression_symbol_list", "__", "L_COLON", "_", "T_GRAMMAR_TEMPLATE" ] }
182
+ ],
183
+ expression_list: [
184
+ { name: "expression_list", symbols: [ "expression" ] },
185
+ { name: "expression_list", postprocess: ({data}) => { return (data[0].concat([data[4]])); }, symbols: [ "expression_list", "_", "L_PIPE", "_", "expression" ] }
186
+ ],
187
+ expression_repeater: [
188
+ { name: "expression_repeater", postprocess: ({data}) => { return (data[0][0].value); }, symbols: [ "L_QMARK" ] },
189
+ { name: "expression_repeater", postprocess: ({data}) => { return (data[0][0].value); }, symbols: [ "L_PLUS" ] },
190
+ { name: "expression_repeater", postprocess: ({data}) => { return (data[0][0].value); }, symbols: [ "L_STAR" ] }
191
+ ],
192
+ expression_symbol: [
193
+ { name: "expression_symbol", postprocess: ({data}) => { return (data[0]); }, symbols: [ "expression_symbol_match" ] },
194
+ { name: "expression_symbol", postprocess: ({data}) => { return ({ ...data[0], alias: data[2] }); }, symbols: [ "expression_symbol_match", "L_COLON", "T_WORD" ] },
195
+ { name: "expression_symbol", postprocess: ({data}) => { return ({ expression: data[0], repeat: data[1] }); }, symbols: [ "expression_symbol_match", "expression_repeater" ] },
196
+ { name: "expression_symbol", postprocess: ({data}) => { return ({ expression: data[0], repeat: data[1], alias: data[4] }); }, symbols: [ "expression_symbol_match", "expression_repeater", "L_COLON", "T_WORD" ] }
197
+ ],
198
+ expression_symbol_list: [
199
+ { name: "expression_symbol_list", symbols: [ "expression_symbol" ] },
200
+ { name: "expression_symbol_list", postprocess: ({data}) => { return (data[0].concat([data[2]])); }, symbols: [ "expression_symbol_list", "T_WS", "expression_symbol" ] }
201
+ ],
202
+ expression_symbol_match: [
203
+ { name: "expression_symbol_match", postprocess: ({data}) => { return ({ rule: data[0] }); }, symbols: [ "T_WORD" ] },
204
+ { name: "expression_symbol_match", postprocess: ({data}) => { return ({ literal: data[0], insensitive: !!data[1] }); }, symbols: [ "T_STRING", "expression_symbol_match.RPT01x1" ] },
205
+ { name: "expression_symbol_match", postprocess: ({data}) => { return ({ token: data[1]}); }, symbols: [ "L_DSIGN", "T_WORD" ] },
206
+ { name: "expression_symbol_match", postprocess: ({data}) => { return ({ token: data[1]}); }, symbols: [ "L_DSIGN", "T_STRING" ] },
207
+ { name: "expression_symbol_match", postprocess: ({data}) => { return (data[0]); }, symbols: [ "T_REGEX" ] },
208
+ { name: "expression_symbol_match", postprocess: ({data}) => { return ({ subexpression: data[2] }); }, symbols: [ "L_PARENL", "_", "expression_list", "_", "L_PARENR" ] },
209
+ { name: "expression_symbol_match", postprocess: ({data}) => { return (data[0]); }, symbols: [ "T_JS" ] }
210
+ ],
211
+ "expression_symbol_match.RPT01x1": [
212
+ { name: "expression_symbol_match.RPT01x1", postprocess: ({data}) => data[0], symbols: [ { literal: "i" } ] },
213
+ { name: "expression_symbol_match.RPT01x1", postprocess: () => null, symbols: [ ] }
214
+ ],
215
+ grammar: [
216
+ { name: "grammar", postprocess: ({data}) => { return ({ config: Object.assign(...data[0]), rules: data[2] }); }, symbols: [ "kv_list", "_", "grammar_rule_list" ] },
217
+ { name: "grammar", postprocess: ({data}) => { return ({ rules: data[0] }); }, symbols: [ "grammar_rule_list" ] }
218
+ ],
219
+ grammar_rule: [
220
+ { name: "grammar_rule", postprocess: ({data}) => { return ({ name: data[0], expressions: data[4] }); }, symbols: [ "T_WORD", "_", "L_ARROW", "_", "expression_list" ] },
221
+ { name: "grammar_rule", postprocess: ({data}) => { return ({ name: data[0], expressions: data[8], postprocess: data[4] }); }, symbols: [ "T_WORD", "__", "L_COLON", "_", "T_JS", "_", "L_ARROW", "_", "expression_list" ] },
222
+ { name: "grammar_rule", postprocess: ({data}) => { return ({ name: data[0], expressions: data[8], postprocess: data[4] }); }, symbols: [ "T_WORD", "__", "L_COLON", "_", "T_GRAMMAR_TEMPLATE", "_", "L_ARROW", "_", "expression_list" ] }
223
+ ],
224
+ grammar_rule_list: [
225
+ { name: "grammar_rule_list", postprocess: ({data}) => { return ([data[0]]); }, symbols: [ "grammar_rule" ] },
226
+ { name: "grammar_rule_list", postprocess: ({data}) => { return ([data[0]].concat(data[2])); }, symbols: [ "grammar_rule", "_", "grammar_rule_list" ] }
227
+ ],
228
+ kv: [
229
+ { name: "kv", postprocess: ({data}) => { return ({ [data[0]]: data[4][0] }); }, symbols: [ "T_WORD", "_", "L_COLON", "_", "kv.SUBx1" ] }
230
+ ],
231
+ "kv.SUBx1": [
232
+ { name: "kv.SUBx1", symbols: [ "T_WORD" ] },
233
+ { name: "kv.SUBx1", symbols: [ "T_STRING" ] },
234
+ { name: "kv.SUBx1", symbols: [ "T_INTEGER" ] },
235
+ { name: "kv.SUBx1", symbols: [ "T_JS" ] },
236
+ { name: "kv.SUBx1", symbols: [ "T_GRAMMAR_TEMPLATE" ] }
237
+ ],
238
+ kv_list: [
239
+ { name: "kv_list", postprocess: ({data}) => { return (data); }, symbols: [ "kv" ] },
240
+ { name: "kv_list", postprocess: ({data}) => { return ([data[0]].concat(data[2])); }, symbols: [ "kv", "_", "kv_list" ] }
241
+ ],
242
+ lexer: [
243
+ { name: "lexer", postprocess: ({data}) => { return (data[0].concat({ states: data[2] })); }, symbols: [ "kv_list", "_", "state_list" ] },
244
+ { name: "lexer", postprocess: ({data}) => { return ([{ states: data[0] }]); }, symbols: [ "state_list" ] }
245
+ ],
246
+ main: [
247
+ { name: "main", postprocess: ({data}) => { return (data[1]); }, symbols: [ "_", "section_list", "_" ] }
248
+ ],
249
+ section: [
250
+ { name: "section", postprocess: ({data}) => { return ({ config: Object.assign(...data[6]) }); }, symbols: [ "K_CONFIG", "_", "L_COLON", "_", "L_TEMPLATEL", "_", "kv_list", "_", "L_TEMPLATER" ] },
251
+ { name: "section", postprocess: ({data}) => { return ({ import: data[6] }); }, symbols: [ "K_IMPORT", "_", "L_STAR", "_", "K_FROM", "__", "T_WORD", "_", "L_SCOLON" ] },
252
+ { name: "section", postprocess: ({data}) => { return ({ import: data[6], path: true }); }, symbols: [ "K_IMPORT", "_", "L_STAR", "_", "K_FROM", "__", "T_STRING", "_", "L_SCOLON" ] },
253
+ { name: "section", postprocess: ({data}) => { return ({ import: data[10], alias: data[6]}); }, symbols: [ "K_IMPORT", "_", "L_STAR", "_", { literal: "as" }, "_", "T_WORD", "_", "K_FROM", "__", "T_WORD", "_", "L_SCOLON" ] },
254
+ { name: "section", postprocess: ({data}) => { return ({ import: data[10], path: true, alias: data[6]}); }, symbols: [ "K_IMPORT", "_", "L_STAR", "_", { literal: "as" }, "_", "T_WORD", "_", "K_FROM", "__", "T_STRING", "_", "L_SCOLON" ] },
255
+ { name: "section", postprocess: ({data}) => { return ({ lexer: Object.assign(...data[6]) }); }, symbols: [ "K_LEXER", "_", "L_COLON", "_", "L_TEMPLATEL", "_", "lexer", "_", "L_TEMPLATER" ] },
256
+ { name: "section", postprocess: ({data}) => { return ({ grammar: data[6] }); }, symbols: [ "K_GRAMMAR", "_", "L_COLON", "_", "L_TEMPLATEL", "_", "grammar", "_", "L_TEMPLATER" ] },
257
+ { name: "section", postprocess: ({data}) => { return ({ lifecycle: "new", js: data[4] }); }, symbols: [ "K_BODY", "_", "L_COLON", "_", "T_JS" ] },
258
+ { name: "section", postprocess: ({data}) => { return ({ lifecycle: "new", js: data[4], path: true }); }, symbols: [ "K_BODY", "_", "L_COLON", "_", "T_STRING" ] },
259
+ { name: "section", postprocess: ({data}) => { return ({ lifecycle:"import", "js": data[4] }); }, symbols: [ "K_HEAD", "_", "L_COLON", "_", "T_JS" ] },
260
+ { name: "section", postprocess: ({data}) => { return ({ lifecycle:"import", "js": data[4], path: true }); }, symbols: [ "K_HEAD", "_", "L_COLON", "_", "T_STRING" ] }
261
+ ],
262
+ section_list: [
263
+ { name: "section_list", postprocess: ({data}) => { return ([data[0]]); }, symbols: [ "section" ] },
264
+ { name: "section_list", postprocess: ({data}) => { return ([data[0]].concat(data[2])); }, symbols: [ "section", "T_WS", "section_list" ] }
265
+ ],
266
+ state: [
267
+ { name: "state", postprocess: ({data}) => { return ({ name: data[0], state: data[2] }); }, symbols: [ "state_declare", "_", "state_definition" ] }
268
+ ],
269
+ state_declare: [
270
+ { name: "state_declare", postprocess: ({data}) => { return (data[0]); }, symbols: [ "T_WORD", "_", "L_ARROW" ] }
271
+ ],
272
+ state_definition: [
273
+ { name: "state_definition", postprocess: ({data}) => { return (Object.assign(...data[0], { rules: data[2] })); }, symbols: [ "state_definition_kv_list", "_", "token_list" ] },
274
+ { name: "state_definition", postprocess: ({data}) => { return ({ rules: data[0] }); }, symbols: [ "token_list" ] }
275
+ ],
276
+ state_definition_kv: [
277
+ { name: "state_definition_kv", postprocess: ({data}) => { return ({ tag: data[4] }); }, symbols: [ { literal: "default" }, "_", { literal: ":" }, "_", "T_WORD" ] },
278
+ { name: "state_definition_kv", postprocess: ({data}) => { return ({ tag: data[4] }); }, symbols: [ { literal: "default" }, "_", { literal: ":" }, "_", "T_STRING" ] },
279
+ { name: "state_definition_kv", postprocess: ({data}) => { return ({ tag: data[4] }); }, symbols: [ { literal: "unmatched" }, "_", { literal: ":" }, "_", "T_WORD" ] },
280
+ { name: "state_definition_kv", postprocess: ({data}) => { return ({ tag: data[4] }); }, symbols: [ { literal: "unmatched" }, "_", { literal: ":" }, "_", "T_STRING" ] }
281
+ ],
282
+ state_definition_kv_list: [
283
+ { name: "state_definition_kv_list", postprocess: ({data}) => { return (data); }, symbols: [ "state_definition_kv" ] },
284
+ { name: "state_definition_kv_list", postprocess: ({data}) => { return ([data[0]].concat(data[2])); }, symbols: [ "state_definition_kv", "_", "state_definition_kv_list" ] }
285
+ ],
286
+ state_list: [
287
+ { name: "state_list", postprocess: ({data}) => { return ([data[0]]); }, symbols: [ "state" ] },
288
+ { name: "state_list", postprocess: ({data}) => { return ([data[0]].concat(data[2])); }, symbols: [ "state", "_", "state_list" ] }
289
+ ],
290
+ string_list: [
291
+ { name: "string_list", postprocess: ({data}) => { return ([data[0]]); }, symbols: [ "T_STRING" ] },
292
+ { name: "string_list", postprocess: ({data}) => { return ([data[0]].concat(data[4])); }, symbols: [ "T_STRING", "_", "L_COMMA", "_", "string_list" ] }
293
+ ],
294
+ token: [
295
+ { name: "token", postprocess: ({data}) => { return ({ import: data[6] }); }, symbols: [ "L_DASH", "_", "K_IMPORT", "_", "L_COLON", "_", "word_list" ] },
296
+ { name: "token", postprocess: ({data}) => { return (Object.assign(...data[2])); }, symbols: [ "L_DASH", "_", "token_definition_list" ] }
297
+ ],
298
+ token_definition: [
299
+ { name: "token_definition", postprocess: ({data}) => { return ({ tag: data[4] }); }, symbols: [ "K_TAG", "_", "L_COLON", "_", "string_list" ] },
300
+ { name: "token_definition", postprocess: ({data}) => { return ({ when: data[4] }); }, symbols: [ "K_WHEN", "_", "L_COLON", "_", "T_STRING" ] },
301
+ { name: "token_definition", postprocess: ({data}) => { return ({ when: data[4] }); }, symbols: [ "K_WHEN", "_", "L_COLON", "_", "T_REGEX" ] },
302
+ { name: "token_definition", postprocess: ({data}) => { return ({ open: data[4] }); }, symbols: [ "K_OPEN", "_", "L_COLON", "_", "T_STRING" ] },
303
+ { name: "token_definition", postprocess: ({data}) => { return ({ close: data[4] }); }, symbols: [ "K_CLOSE", "_", "L_COLON", "_", "T_STRING" ] },
304
+ { name: "token_definition", postprocess: ({data}) => { return ({ when: data[4], before: true }); }, symbols: [ "K_BEFORE", "_", "L_COLON", "_", "T_STRING" ] },
305
+ { name: "token_definition", postprocess: ({data}) => { return ({ when: data[4], before: true }); }, symbols: [ "K_BEFORE", "_", "L_COLON", "_", "T_REGEX" ] },
306
+ { name: "token_definition", postprocess: ({data}) => { return ({ pop: 1 }); }, symbols: [ "K_POP" ] },
307
+ { name: "token_definition", postprocess: ({data}) => { return ({ pop: parseInt(data[4]) }); }, symbols: [ "K_POP", "_", "L_COLON", "_", "T_INTEGER" ] },
308
+ { name: "token_definition", postprocess: ({data}) => { return ({ pop: "all" }); }, symbols: [ "K_POP", "_", "L_COLON", "_", "K_ALL" ] },
309
+ { name: "token_definition", postprocess: ({data}) => { return ({ highlight: data[4] }); }, symbols: [ "K_HIGHLIGHT", "_", "L_COLON", "_", "T_STRING" ] },
310
+ { name: "token_definition", postprocess: ({data}) => { return ({ embed: data[4] }); }, symbols: [ "K_EMBED", "_", "L_COLON", "_", "T_STRING" ] },
311
+ { name: "token_definition", postprocess: ({data}) => { return ({ unembed: true }); }, symbols: [ "K_UNEMBED" ] },
312
+ { name: "token_definition", postprocess: ({data}) => { return ({ inset: 1 }); }, symbols: [ "K_INSET" ] },
313
+ { name: "token_definition", postprocess: ({data}) => { return ({ inset: parseInt(data[4]) }); }, symbols: [ "K_INSET", "_", "L_COLON", "_", "T_INTEGER" ] },
314
+ { name: "token_definition", postprocess: ({data}) => { return ({ set: data[4] }); }, symbols: [ "K_SET", "_", "L_COLON", "_", "T_WORD" ] },
315
+ { name: "token_definition", postprocess: ({data}) => { return ({ goto: data[4] }); }, symbols: [ "K_GOTO", "_", "L_COLON", "_", "T_WORD" ] },
316
+ { name: "token_definition", postprocess: ({data}) => { return ({ type: data[4] }); }, symbols: [ "K_TYPE", "_", "L_COLON", "_", "T_STRING" ] }
317
+ ],
318
+ token_definition_list: [
319
+ { name: "token_definition_list", postprocess: ({data}) => { return (data); }, symbols: [ "token_definition" ] },
320
+ { name: "token_definition_list", postprocess: ({data}) => { return ([data[0]].concat(data[2])); }, symbols: [ "token_definition", "_", "token_definition_list" ] }
321
+ ],
322
+ token_list: [
323
+ { name: "token_list", postprocess: ({data}) => { return (data); }, symbols: [ "token" ] },
324
+ { name: "token_list", postprocess: ({data}) => { return ([data[0]].concat(data[2])); }, symbols: [ "token", "_", "token_list" ] }
325
+ ],
326
+ word_list: [
327
+ { name: "word_list", postprocess: ({data}) => { return ([data[0]]); }, symbols: [ "T_WORD" ] },
328
+ { name: "word_list", postprocess: ({data}) => { return ([data[0]].concat(data[4])); }, symbols: [ "T_WORD", "_", "L_COMMA", "_", "word_list" ] }
329
+ ]
330
+ },
331
+ start: "main"
332
+ },
333
+ lexer: {
334
+ start: "start",
335
+ states: {
336
+ comment: {
337
+ regex: /(?:(?:(\/\/[^\n]*)))/ym,
338
+ rules: [
339
+ { highlight: "comment", tag: ["T_COMMENT"], when: /\/\/[^\n]*/ }
340
+ ]
341
+ },
342
+ config: {
343
+ regex: /(?:(?:(\s+))|(?:((?::)))|(?:((?:\{\{))))/ym,
344
+ rules: [
345
+ { tag: ["T_WS"], when: /\s+/ },
346
+ { highlight: "keyword", tag: ["L_COLON"], when: ":" },
347
+ { set: "config_inner", tag: ["L_TEMPLATEL"], when: "{{" }
348
+ ]
349
+ },
350
+ config_inner: {
351
+ regex: /(?:(?:(\/\/[^\n]*))|(?:("(?:[^"\\\r\n]|\\.)*"))|(?:(\s+))|(?:([a-zA-Z_][a-zA-Z_\d]*))|(?:((?::)))|(?:(\d+))|(?:((?:\}\}))))/ym,
352
+ rules: [
353
+ { highlight: "comment", tag: ["T_COMMENT"], when: /\/\/[^\n]*/ },
354
+ { highlight: "string", tag: ["T_STRING"], when: /"(?:[^"\\\r\n]|\\.)*"/ },
355
+ { tag: ["T_WS"], when: /\s+/ },
356
+ { tag: ["T_WORD"], when: /[a-zA-Z_][a-zA-Z_\d]*/ },
357
+ { highlight: "keyword", tag: ["L_COLON"], when: ":" },
358
+ { highlight: "number", tag: ["T_INTEGER"], when: /\d+/ },
359
+ { pop: 1, tag: ["L_TEMPLATER"], when: "}}" }
360
+ ]
361
+ },
362
+ grammar: {
363
+ regex: /(?:(?:(\s+))|(?:((?::)))|(?:((?:\{\{))))/ym,
364
+ rules: [
365
+ { tag: ["T_WS"], when: /\s+/ },
366
+ { highlight: "keyword", tag: ["L_COLON"], when: ":" },
367
+ { set: "grammar_inner", tag: ["L_TEMPLATEL"], when: "{{" }
368
+ ]
369
+ },
370
+ grammar_inner: {
371
+ regex: /(?:(?:(\/\/[^\n]*))|(?:((?:\$\{)))|(?:((?:\{\{)))|(?:(\s+))|(?:(\/(?:[^\/\\\r\n]|\\.)+\/))|(?:((?:\?)))|(?:((?:\+)))|(?:((?:\*)))|(?:("(?:[^"\\\r\n]|\\.)*"))|(?:([a-zA-Z_][a-zA-Z_\d]*))|(?:((?::)))|(?:(\d+))|(?:((?:,)))|(?:((?:\|)))|(?:((?:\()))|(?:((?:\))))|(?:((?:\->)))|(?:((?:\$)))|(?:((?:\-)))|(?:((?:\}\}))))/ym,
372
+ rules: [
373
+ { highlight: "comment", tag: ["T_COMMENT"], when: /\/\/[^\n]*/ },
374
+ { goto: "js_wrap", tag: ["L_JSL"], when: "${" },
375
+ { goto: "js_template_inner", tag: ["L_TEMPLATEL"], when: "{{" },
376
+ { tag: ["T_WS"], when: /\s+/ },
377
+ { highlight: "regexp", tag: ["T_REGEX"], when: /\/(?:[^\/\\\r\n]|\\.)+\// },
378
+ { tag: ["L_QMARK"], when: "?" },
379
+ { tag: ["L_PLUS"], when: "+" },
380
+ { tag: ["L_STAR"], when: "*" },
381
+ { highlight: "string", tag: ["T_STRING"], when: /"(?:[^"\\\r\n]|\\.)*"/ },
382
+ { tag: ["T_WORD"], when: /[a-zA-Z_][a-zA-Z_\d]*/ },
383
+ { highlight: "keyword", tag: ["L_COLON"], when: ":" },
384
+ { highlight: "number", tag: ["T_INTEGER"], when: /\d+/ },
385
+ { tag: ["L_COMMA"], when: "," },
386
+ { highlight: "keyword", tag: ["L_PIPE"], when: "|" },
387
+ { tag: ["L_PARENL"], when: "(" },
388
+ { tag: ["L_PARENR"], when: ")" },
389
+ { highlight: "keyword", tag: ["L_ARROW"], when: "->" },
390
+ { tag: ["L_DSIGN"], when: "$" },
391
+ { tag: ["L_DASH"], when: "-" },
392
+ { pop: 1, tag: ["L_TEMPLATER"], when: "}}" }
393
+ ]
394
+ },
395
+ integer: {
396
+ regex: /(?:(?:(\d+)))/ym,
397
+ rules: [
398
+ { highlight: "number", tag: ["T_INTEGER"], when: /\d+/ }
399
+ ]
400
+ },
401
+ js: {
402
+ regex: /(?:(?:((?:\$\{))))/ym,
403
+ rules: [
404
+ { goto: "js_wrap", tag: ["L_JSL"], when: "${" }
405
+ ]
406
+ },
407
+ js_literal: {
408
+ regex: /(?:(?:("(?:[^"\\\r\n]|\\.)*"))|(?:('(?:[^'\\\r\n]|\\.)*'))|(?:(`(?:[^`\\]|\\.)*`))|(?:(\/(?:[^/\\\r\n]|\\.)+\/[gmiyu]*))|(?:(\/\/[^\n]*))|(?:(\/\*.*\*\/))|(?:((?:\{)))|(?:((?:\}))))/gm,
409
+ rules: [
410
+ { tag: ["T_JSBODY"], when: /"(?:[^"\\\r\n]|\\.)*"/ },
411
+ { tag: ["T_JSBODY"], when: /'(?:[^'\\\r\n]|\\.)*'/ },
412
+ { tag: ["T_JSBODY"], when: /`(?:[^`\\]|\\.)*`/ },
413
+ { tag: ["T_JSBODY"], when: /\/(?:[^/\\\r\n]|\\.)+\/[gmiyu]*/ },
414
+ { tag: ["T_JSBODY"], when: /\/\/[^\n]*/ },
415
+ { tag: ["T_JSBODY"], when: /\/\*.*\*\// },
416
+ { goto: "js_literal", tag: ["T_JSBODY"], when: "{" },
417
+ { pop: 1, tag: ["T_JSBODY"], when: "}" }
418
+ ],
419
+ unmatched: { tag: ["T_JSBODY"] }
420
+ },
421
+ js_template: {
422
+ regex: /(?:(?:((?:\{\{))))/ym,
423
+ rules: [
424
+ { goto: "js_template_inner", tag: ["L_TEMPLATEL"], when: "{{" }
425
+ ]
426
+ },
427
+ js_template_inner: {
428
+ regex: /(?:(?:("(?:[^"\\\r\n]|\\.)*"))|(?:('(?:[^'\\\r\n]|\\.)*'))|(?:(`(?:[^`\\]|\\.)*`))|(?:(\/(?:[^/\\\r\n]|\\.)+\/[gmiyu]*))|(?:(\/\/[^\n]*))|(?:(\/\*.*\*\/))|(?:((?:\{)))|(?:((?:\}\}))))/gm,
429
+ rules: [
430
+ { tag: ["T_JSBODY"], when: /"(?:[^"\\\r\n]|\\.)*"/ },
431
+ { tag: ["T_JSBODY"], when: /'(?:[^'\\\r\n]|\\.)*'/ },
432
+ { tag: ["T_JSBODY"], when: /`(?:[^`\\]|\\.)*`/ },
433
+ { tag: ["T_JSBODY"], when: /\/(?:[^/\\\r\n]|\\.)+\/[gmiyu]*/ },
434
+ { tag: ["T_JSBODY"], when: /\/\/[^\n]*/ },
435
+ { tag: ["T_JSBODY"], when: /\/\*.*\*\// },
436
+ { goto: "js_literal", tag: ["T_JSBODY"], when: "{" },
437
+ { pop: 1, tag: ["L_TEMPLATER"], when: "}}" }
438
+ ],
439
+ unmatched: { tag: ["T_JSBODY"] }
440
+ },
441
+ js_wrap: {
442
+ regex: /(?:(?:("(?:[^"\\\r\n]|\\.)*"))|(?:('(?:[^'\\\r\n]|\\.)*'))|(?:(`(?:[^`\\]|\\.)*`))|(?:(\/(?:[^/\\\r\n]|\\.)+\/[gmiyu]*))|(?:(\/\/[^\n]*))|(?:(\/\*.*\*\/))|(?:((?:\{)))|(?:((?:\}))))/gm,
443
+ rules: [
444
+ { tag: ["T_JSBODY"], when: /"(?:[^"\\\r\n]|\\.)*"/ },
445
+ { tag: ["T_JSBODY"], when: /'(?:[^'\\\r\n]|\\.)*'/ },
446
+ { tag: ["T_JSBODY"], when: /`(?:[^`\\]|\\.)*`/ },
447
+ { tag: ["T_JSBODY"], when: /\/(?:[^/\\\r\n]|\\.)+\/[gmiyu]*/ },
448
+ { tag: ["T_JSBODY"], when: /\/\/[^\n]*/ },
449
+ { tag: ["T_JSBODY"], when: /\/\*.*\*\// },
450
+ { goto: "js_literal", tag: ["T_JSBODY"], when: "{" },
451
+ { pop: 1, tag: ["L_JSR"], when: "}" }
452
+ ],
453
+ unmatched: { tag: ["T_JSBODY"] }
454
+ },
455
+ jsignore: {
456
+ regex: /(?:(?:("(?:[^"\\\r\n]|\\.)*"))|(?:('(?:[^'\\\r\n]|\\.)*'))|(?:(`(?:[^`\\]|\\.)*`))|(?:(\/(?:[^/\\\r\n]|\\.)+\/[gmiyu]*))|(?:(\/\/[^\n]*))|(?:(\/\*.*\*\/)))/ym,
457
+ rules: [
458
+ { tag: ["T_JSBODY"], when: /"(?:[^"\\\r\n]|\\.)*"/ },
459
+ { tag: ["T_JSBODY"], when: /'(?:[^'\\\r\n]|\\.)*'/ },
460
+ { tag: ["T_JSBODY"], when: /`(?:[^`\\]|\\.)*`/ },
461
+ { tag: ["T_JSBODY"], when: /\/(?:[^/\\\r\n]|\\.)+\/[gmiyu]*/ },
462
+ { tag: ["T_JSBODY"], when: /\/\/[^\n]*/ },
463
+ { tag: ["T_JSBODY"], when: /\/\*.*\*\// }
464
+ ]
465
+ },
466
+ kv: {
467
+ regex: /(?:(?:("(?:[^"\\\r\n]|\\.)*"))|(?:(\s+))|(?:([a-zA-Z_][a-zA-Z_\d]*))|(?:((?::)))|(?:(\d+)))/ym,
468
+ rules: [
469
+ { highlight: "string", tag: ["T_STRING"], when: /"(?:[^"\\\r\n]|\\.)*"/ },
470
+ { tag: ["T_WS"], when: /\s+/ },
471
+ { tag: ["T_WORD"], when: /[a-zA-Z_][a-zA-Z_\d]*/ },
472
+ { highlight: "keyword", tag: ["L_COLON"], when: ":" },
473
+ { highlight: "number", tag: ["T_INTEGER"], when: /\d+/ }
474
+ ]
475
+ },
476
+ l_arrow: {
477
+ regex: /(?:(?:((?:\->))))/ym,
478
+ rules: [
479
+ { highlight: "keyword", tag: ["L_ARROW"], when: "->" }
480
+ ]
481
+ },
482
+ l_colon: {
483
+ regex: /(?:(?:((?::))))/ym,
484
+ rules: [
485
+ { highlight: "keyword", tag: ["L_COLON"], when: ":" }
486
+ ]
487
+ },
488
+ l_comma: {
489
+ regex: /(?:(?:((?:,))))/ym,
490
+ rules: [
491
+ { tag: ["L_COMMA"], when: "," }
492
+ ]
493
+ },
494
+ l_dash: {
495
+ regex: /(?:(?:((?:\-))))/ym,
496
+ rules: [
497
+ { tag: ["L_DASH"], when: "-" }
498
+ ]
499
+ },
500
+ l_dsign: {
501
+ regex: /(?:(?:((?:\$))))/ym,
502
+ rules: [
503
+ { tag: ["L_DSIGN"], when: "$" }
504
+ ]
505
+ },
506
+ l_parenl: {
507
+ regex: /(?:(?:((?:\())))/ym,
508
+ rules: [
509
+ { tag: ["L_PARENL"], when: "(" }
510
+ ]
511
+ },
512
+ l_parenr: {
513
+ regex: /(?:(?:((?:\)))))/ym,
514
+ rules: [
515
+ { tag: ["L_PARENR"], when: ")" }
516
+ ]
517
+ },
518
+ l_pipe: {
519
+ regex: /(?:(?:((?:\|))))/ym,
520
+ rules: [
521
+ { highlight: "keyword", tag: ["L_PIPE"], when: "|" }
522
+ ]
523
+ },
524
+ l_plus: {
525
+ regex: /(?:(?:((?:\+))))/ym,
526
+ rules: [
527
+ { tag: ["L_PLUS"], when: "+" }
528
+ ]
529
+ },
530
+ l_qmark: {
531
+ regex: /(?:(?:((?:\?))))/ym,
532
+ rules: [
533
+ { tag: ["L_QMARK"], when: "?" }
534
+ ]
535
+ },
536
+ l_scolon: {
537
+ regex: /(?:(?:((?:;))))/ym,
538
+ rules: [
539
+ { tag: ["L_SCOLON"], when: ";" }
540
+ ]
541
+ },
542
+ l_star: {
543
+ regex: /(?:(?:((?:\*))))/ym,
544
+ rules: [
545
+ { tag: ["L_STAR"], when: "*" }
546
+ ]
547
+ },
548
+ lexer: {
549
+ regex: /(?:(?:(\s+))|(?:((?::)))|(?:((?:\{\{))))/ym,
550
+ rules: [
551
+ { tag: ["T_WS"], when: /\s+/ },
552
+ { highlight: "keyword", tag: ["L_COLON"], when: ":" },
553
+ { set: "lexer_inner", tag: ["L_TEMPLATEL"], when: "{{" }
554
+ ]
555
+ },
556
+ lexer_inner: {
557
+ regex: /(?:(?:(\s+))|(?:(\/\/[^\n]*))|(?:(\/(?:[^\/\\\r\n]|\\.)+\/))|(?:((?:,)))|(?:((?:\->)))|(?:((?:\-)))|(?:("(?:[^"\\\r\n]|\\.)*"))|(?:([a-zA-Z_][a-zA-Z_\d]*))|(?:((?::)))|(?:(\d+))|(?:((?:\$\{)))|(?:((?:\}\}))))/ym,
558
+ rules: [
559
+ { tag: ["T_WS"], when: /\s+/ },
560
+ { highlight: "comment", tag: ["T_COMMENT"], when: /\/\/[^\n]*/ },
561
+ { highlight: "regexp", tag: ["T_REGEX"], when: /\/(?:[^\/\\\r\n]|\\.)+\// },
562
+ { tag: ["L_COMMA"], when: "," },
563
+ { highlight: "keyword", tag: ["L_ARROW"], when: "->" },
564
+ { tag: ["L_DASH"], when: "-" },
565
+ { highlight: "string", tag: ["T_STRING"], when: /"(?:[^"\\\r\n]|\\.)*"/ },
566
+ { tag: ["T_WORD"], when: /[a-zA-Z_][a-zA-Z_\d]*/ },
567
+ { highlight: "keyword", tag: ["L_COLON"], when: ":" },
568
+ { highlight: "number", tag: ["T_INTEGER"], when: /\d+/ },
569
+ { goto: "js_wrap", tag: ["L_JSL"], when: "${" },
570
+ { pop: 1, tag: ["L_TEMPLATER"], when: "}}" }
571
+ ]
572
+ },
573
+ regex: {
574
+ regex: /(?:(?:(\/(?:[^\/\\\r\n]|\\.)+\/)))/ym,
575
+ rules: [
576
+ { highlight: "regexp", tag: ["T_REGEX"], when: /\/(?:[^\/\\\r\n]|\\.)+\// }
577
+ ]
578
+ },
579
+ start: {
580
+ regex: /(?:(?:("(?:[^"\\\r\n]|\\.)*"))|(?:((?:\$\{)))|(?:(\s+))|(?:(\/\/[^\n]*))|(?:((?:;)))|(?:((?:\*)))|(?:(lexer(?![a-zA-Z\d_])))|(?:(grammar(?![a-zA-Z\d_])))|(?:(config(?![a-zA-Z\d_])))|(?:([a-zA-Z_][a-zA-Z_\d]*))|(?:((?::)))|(?:(\d+)))/ym,
581
+ rules: [
582
+ { highlight: "string", tag: ["T_STRING"], when: /"(?:[^"\\\r\n]|\\.)*"/ },
583
+ { goto: "js_wrap", tag: ["L_JSL"], when: "${" },
584
+ { tag: ["T_WS"], when: /\s+/ },
585
+ { highlight: "comment", tag: ["T_COMMENT"], when: /\/\/[^\n]*/ },
586
+ { tag: ["L_SCOLON"], when: ";" },
587
+ { tag: ["L_STAR"], when: "*" },
588
+ { goto: "lexer", highlight: "type", tag: ["T_WORD"], when: /lexer(?![a-zA-Z\d_])/ },
589
+ { goto: "grammar", highlight: "type", tag: ["T_WORD"], when: /grammar(?![a-zA-Z\d_])/ },
590
+ { goto: "config", highlight: "type", tag: ["T_WORD"], when: /config(?![a-zA-Z\d_])/ },
591
+ { tag: ["T_WORD"], when: /[a-zA-Z_][a-zA-Z_\d]*/ },
592
+ { highlight: "keyword", tag: ["L_COLON"], when: ":" },
593
+ { highlight: "number", tag: ["T_INTEGER"], when: /\d+/ }
594
+ ]
595
+ },
596
+ string: {
597
+ regex: /(?:(?:("(?:[^"\\\r\n]|\\.)*")))/ym,
598
+ rules: [
599
+ { highlight: "string", tag: ["T_STRING"], when: /"(?:[^"\\\r\n]|\\.)*"/ }
600
+ ]
601
+ },
602
+ word: {
603
+ regex: /(?:(?:([a-zA-Z_][a-zA-Z_\d]*)))/ym,
604
+ rules: [
605
+ { tag: ["T_WORD"], when: /[a-zA-Z_][a-zA-Z_\d]*/ }
606
+ ]
607
+ },
608
+ ws: {
609
+ regex: /(?:(?:(\s+)))/ym,
610
+ rules: [
611
+ { tag: ["T_WS"], when: /\s+/ }
612
+ ]
613
+ }
614
+ }
615
+ }
616
+ }
617
+ constructor(){}
618
+ }
619
+
620
+ export default grammar;