grammar-well 1.3.3 → 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.
- package/README.md +76 -560
- package/build/generator/artifacts/basic.d.ts +7 -0
- package/build/generator/artifacts/basic.js +24 -0
- package/build/generator/artifacts/basic.js.map +1 -0
- package/build/generator/artifacts/lexer.d.ts +13 -0
- package/build/generator/artifacts/lexer.js +204 -0
- package/build/generator/artifacts/lexer.js.map +1 -0
- package/build/{compiler/generator → generator}/artifacts/lr.d.ts +14 -14
- package/build/{compiler/generator → generator}/artifacts/lr.js +18 -22
- package/build/generator/artifacts/lr.js.map +1 -0
- package/build/generator/builtin/json.d.ts +183 -0
- package/build/generator/builtin/json.js +124 -0
- package/build/generator/builtin/json.js.map +1 -0
- package/build/generator/builtin/registry.json +1 -0
- package/build/generator/builtin/whitespace.d.ts +61 -0
- package/build/generator/builtin/whitespace.js +37 -0
- package/build/generator/builtin/whitespace.js.map +1 -0
- package/build/generator/generator.d.ts +38 -0
- package/build/generator/generator.js +368 -0
- package/build/generator/generator.js.map +1 -0
- package/build/generator/grammars/index.d.ts +2 -0
- package/build/generator/grammars/index.js +3 -0
- package/build/generator/grammars/index.js.map +1 -0
- package/build/generator/grammars/v1.d.ts +1190 -0
- package/build/generator/grammars/v1.js +614 -0
- package/build/generator/grammars/v1.js.map +1 -0
- package/build/generator/grammars/v2.d.ts +1367 -0
- package/build/generator/grammars/v2.js +695 -0
- package/build/generator/grammars/v2.js.map +1 -0
- package/build/generator/import-resolvers/auto.d.ts +2 -0
- package/build/generator/import-resolvers/auto.js +11 -0
- package/build/generator/import-resolvers/auto.js.map +1 -0
- package/build/generator/import-resolvers/browser.d.ts +7 -0
- package/build/generator/import-resolvers/browser.js +13 -0
- package/build/generator/import-resolvers/browser.js.map +1 -0
- package/build/generator/import-resolvers/default.d.ts +2 -0
- package/build/generator/import-resolvers/default.js +11 -0
- package/build/generator/import-resolvers/default.js.map +1 -0
- package/build/generator/import-resolvers/filesystem.d.ts +7 -0
- package/build/generator/import-resolvers/filesystem.js +15 -0
- package/build/generator/import-resolvers/filesystem.js.map +1 -0
- package/build/generator/index.d.ts +3 -0
- package/build/generator/index.js +4 -0
- package/build/generator/index.js.map +1 -0
- package/build/generator/state.d.ts +28 -0
- package/build/generator/state.js +73 -0
- package/build/generator/state.js.map +1 -0
- package/build/generator/stringify/common.d.ts +22 -0
- package/build/generator/stringify/common.js +83 -0
- package/build/generator/stringify/common.js.map +1 -0
- package/build/generator/stringify/exports/javascript.d.ts +3 -0
- package/build/generator/stringify/exports/javascript.js +26 -0
- package/build/generator/stringify/exports/javascript.js.map +1 -0
- package/build/generator/stringify/exports/json.d.ts +2 -0
- package/build/generator/stringify/exports/json.js +4 -0
- package/build/generator/stringify/exports/json.js.map +1 -0
- package/build/generator/stringify/exports/registry.d.ts +20 -0
- package/build/generator/stringify/exports/registry.js +17 -0
- package/build/generator/stringify/exports/registry.js.map +1 -0
- package/build/generator/stringify/exports/typescript.d.ts +2 -0
- package/build/generator/stringify/exports/typescript.js +16 -0
- package/build/generator/stringify/exports/typescript.js.map +1 -0
- package/build/generator/stringify/grammar/v2.d.ts +20 -0
- package/build/generator/stringify/grammar/v2.js +211 -0
- package/build/generator/stringify/grammar/v2.js.map +1 -0
- package/build/generator/stringify/javascript.d.ts +13 -0
- package/build/generator/stringify/javascript.js +83 -0
- package/build/generator/stringify/javascript.js.map +1 -0
- package/build/index.d.ts +7 -6
- package/build/index.js +7 -24
- package/build/index.js.map +1 -1
- package/build/lexers/character-lexer.d.ts +2 -2
- package/build/lexers/character-lexer.js +1 -5
- package/build/lexers/character-lexer.js.map +1 -1
- package/build/lexers/stateful-lexer.d.ts +12 -17
- package/build/lexers/stateful-lexer.js +38 -186
- package/build/lexers/stateful-lexer.js.map +1 -1
- package/build/lexers/token-buffer.d.ts +8 -8
- package/build/lexers/token-buffer.js +1 -5
- package/build/lexers/token-buffer.js.map +1 -1
- package/build/parser/algorithms/cyk.d.ts +6 -6
- package/build/parser/algorithms/cyk.js +10 -13
- package/build/parser/algorithms/cyk.js.map +1 -1
- package/build/parser/algorithms/earley.d.ts +7 -7
- package/build/parser/algorithms/earley.js +7 -11
- package/build/parser/algorithms/earley.js.map +1 -1
- package/build/parser/algorithms/lrk/algorithm.d.ts +3 -3
- package/build/parser/algorithms/lrk/algorithm.js +10 -13
- package/build/parser/algorithms/lrk/algorithm.js.map +1 -1
- package/build/parser/algorithms/lrk/bimap.js +1 -5
- package/build/parser/algorithms/lrk/bimap.js.map +1 -1
- package/build/parser/algorithms/lrk/canonical-collection.d.ts +7 -7
- package/build/parser/algorithms/lrk/canonical-collection.js +11 -15
- package/build/parser/algorithms/lrk/canonical-collection.js.map +1 -1
- package/build/parser/algorithms/lrk/closure.d.ts +3 -3
- package/build/parser/algorithms/lrk/closure.js +3 -7
- package/build/parser/algorithms/lrk/closure.js.map +1 -1
- package/build/parser/algorithms/lrk/stack.d.ts +6 -6
- package/build/parser/algorithms/lrk/stack.js +1 -5
- package/build/parser/algorithms/lrk/stack.js.map +1 -1
- package/build/parser/algorithms/lrk/state.d.ts +5 -5
- package/build/parser/algorithms/lrk/state.js +1 -2
- package/build/parser/parse.d.ts +10 -0
- package/build/parser/parse.js +34 -0
- package/build/parser/parse.js.map +1 -0
- package/build/parser/parser.d.ts +6 -17
- package/build/parser/parser.js +26 -42
- package/build/parser/parser.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build/typings/ast.d.ts +134 -0
- package/build/typings/ast.js +3 -0
- package/build/typings/ast.js.map +1 -0
- package/build/typings/common.d.ts +4 -0
- package/build/typings/common.js +2 -0
- package/build/typings/common.js.map +1 -0
- package/build/typings/generator.d.ts +58 -0
- package/build/typings/generator.js +3 -0
- package/build/typings/generator.js.map +1 -0
- package/build/typings/index.d.ts +43 -0
- package/build/typings/index.js +5 -0
- package/build/typings/index.js.map +1 -0
- package/build/typings/runtime.d.ts +70 -0
- package/build/typings/runtime.js +2 -0
- package/build/typings/runtime.js.map +1 -0
- package/build/utility/format.d.ts +1 -0
- package/build/utility/format.js +12 -0
- package/build/utility/format.js.map +1 -0
- package/build/utility/formatter.d.ts +1 -0
- package/build/utility/formatter.js +12 -0
- package/build/utility/formatter.js.map +1 -0
- package/build/utility/general.d.ts +1 -1
- package/build/utility/general.js +5 -13
- package/build/utility/general.js.map +1 -1
- package/build/utility/index.d.ts +4 -1
- package/build/utility/index.js +4 -17
- package/build/utility/index.js.map +1 -1
- package/build/utility/lint.d.ts +2 -2
- package/build/utility/lint.js +2 -6
- package/build/utility/lint.js.map +1 -1
- package/build/utility/migrate.d.ts +1 -0
- package/build/utility/migrate.js +10 -0
- package/build/utility/migrate.js.map +1 -0
- package/build/utility/monarch.d.ts +2 -2
- package/build/utility/monarch.js +33 -38
- package/build/utility/monarch.js.map +1 -1
- package/build/utility/parsing.d.ts +6 -0
- package/build/utility/parsing.js +26 -0
- package/build/utility/parsing.js.map +1 -0
- package/build/utility/text-format.d.ts +6 -6
- package/build/utility/text-format.js +2 -6
- package/build/utility/text-format.js.map +1 -1
- package/package.json +17 -24
- package/src/generator/artifacts/basic.ts +26 -0
- package/src/generator/artifacts/lexer.ts +228 -0
- package/src/{compiler/generator → generator}/artifacts/lr.ts +25 -24
- package/src/generator/builtin/character.well +7 -0
- package/src/generator/builtin/json.well +85 -0
- package/src/generator/builtin/number.well +21 -0
- package/src/generator/builtin/registry.json +1 -0
- package/src/generator/builtin/string.well +54 -0
- package/src/generator/builtin/whitespace.well +16 -0
- package/src/generator/generator.ts +401 -0
- package/src/generator/grammars/index.ts +2 -0
- package/src/generator/grammars/v1.ts +620 -0
- package/src/generator/grammars/v1.well +422 -0
- package/src/generator/grammars/v2.ts +701 -0
- package/src/generator/grammars/v2.well +413 -0
- package/src/generator/import-resolvers/auto.ts +12 -0
- package/src/generator/import-resolvers/browser.ts +13 -0
- package/src/generator/import-resolvers/filesystem.ts +18 -0
- package/src/generator/index.ts +3 -0
- package/src/generator/state.ts +89 -0
- package/src/generator/stringify/common.ts +90 -0
- package/src/generator/stringify/exports/javascript.ts +29 -0
- package/src/generator/stringify/exports/json.ts +5 -0
- package/src/generator/stringify/exports/registry.ts +20 -0
- package/src/generator/stringify/exports/typescript.ts +17 -0
- package/src/generator/stringify/grammar/v2.ts +223 -0
- package/src/generator/stringify/javascript.ts +94 -0
- package/src/index.ts +7 -6
- package/src/lexers/character-lexer.ts +2 -2
- package/src/lexers/stateful-lexer.ts +46 -203
- package/src/lexers/token-buffer.ts +3 -3
- package/src/parser/algorithms/cyk.ts +13 -12
- package/src/parser/algorithms/earley.ts +10 -10
- package/src/parser/algorithms/lrk/algorithm.ts +8 -7
- package/src/parser/algorithms/lrk/canonical-collection.ts +14 -14
- package/src/parser/algorithms/lrk/closure.ts +6 -6
- package/src/parser/algorithms/lrk/stack.ts +6 -6
- package/src/parser/algorithms/lrk/state.ts +5 -5
- package/src/parser/parse.ts +45 -0
- package/src/typings/ast.ts +148 -0
- package/src/typings/common.ts +2 -0
- package/src/typings/generator.ts +62 -0
- package/src/typings/index.ts +38 -0
- package/src/typings/runtime.ts +82 -0
- package/src/utility/format.ts +12 -0
- package/src/utility/general.ts +1 -2
- package/src/utility/index.ts +4 -1
- package/src/utility/lint.ts +5 -5
- package/src/utility/monarch.ts +34 -34
- package/src/utility/parsing.ts +30 -0
- package/src/utility/text-format.ts +7 -7
- package/.eslintrc.cjs +0 -14
- package/bootstrap.ts +0 -45
- package/build/compiler/builtin.json +0 -1
- package/build/compiler/compiler.d.ts +0 -50
- package/build/compiler/compiler.js +0 -249
- package/build/compiler/compiler.js.map +0 -1
- package/build/compiler/generator/artifacts/lr.js.map +0 -1
- package/build/compiler/generator/artifacts/standard.d.ts +0 -7
- package/build/compiler/generator/artifacts/standard.js +0 -28
- package/build/compiler/generator/artifacts/standard.js.map +0 -1
- package/build/compiler/generator/generator.d.ts +0 -24
- package/build/compiler/generator/generator.js +0 -217
- package/build/compiler/generator/generator.js.map +0 -1
- package/build/compiler/gwell.d.ts +0 -1112
- package/build/compiler/gwell.js +0 -576
- package/build/compiler/gwell.js.map +0 -1
- package/build/compiler/import-resolver.d.ts +0 -15
- package/build/compiler/import-resolver.js +0 -37
- package/build/compiler/import-resolver.js.map +0 -1
- package/build/compiler/index.d.ts +0 -2
- package/build/compiler/index.js +0 -19
- package/build/compiler/index.js.map +0 -1
- package/build/compiler/outputs/javascript.d.ts +0 -3
- package/build/compiler/outputs/javascript.js +0 -29
- package/build/compiler/outputs/javascript.js.map +0 -1
- package/build/compiler/outputs/json.d.ts +0 -2
- package/build/compiler/outputs/json.js +0 -8
- package/build/compiler/outputs/json.js.map +0 -1
- package/build/compiler/outputs/typescript.d.ts +0 -2
- package/build/compiler/outputs/typescript.js +0 -21
- package/build/compiler/outputs/typescript.js.map +0 -1
- package/build/parser/algorithms/lr.d.ts +0 -7
- package/build/parser/algorithms/lr.js +0 -108
- package/build/parser/algorithms/lr.js.map +0 -5
- package/build/parser/algorithms/lr0.d.ts +0 -7
- package/build/parser/algorithms/lr0.js +0 -156
- package/build/parser/algorithms/lr0.js.map +0 -1
- package/build/typings.d.ts +0 -226
- package/build/typings.js +0 -3
- package/build/typings.js.map +0 -1
- package/src/compiler/builtin/json.gwell +0 -74
- package/src/compiler/builtin/number.gwell +0 -20
- package/src/compiler/builtin/string.gwell +0 -48
- package/src/compiler/builtin/whitespace.gwell +0 -10
- package/src/compiler/builtin.json +0 -1
- package/src/compiler/compiler.ts +0 -265
- package/src/compiler/generator/artifacts/standard.ts +0 -26
- package/src/compiler/generator/generator.ts +0 -237
- package/src/compiler/gwell.gwell +0 -294
- package/src/compiler/gwell.js +0 -578
- package/src/compiler/import-resolver.ts +0 -36
- package/src/compiler/index.ts +0 -2
- package/src/compiler/outputs/javascript.ts +0 -27
- package/src/compiler/outputs/json.ts +0 -5
- package/src/compiler/outputs/typescript.ts +0 -18
- package/src/parser/parser.ts +0 -77
- package/src/typings.ts +0 -248
- package/testing.ts +0 -18
package/src/compiler/gwell.js
DELETED
|
@@ -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
|
-
}
|
package/src/compiler/index.ts
DELETED
|
@@ -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
|
-
}
|