grammar-well 1.1.10 → 1.2.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 +209 -7
- package/bootstrap.ts +1 -1
- package/build/compiler/compiler.d.ts +1 -1
- package/build/compiler/compiler.js +2 -1
- package/build/compiler/compiler.js.map +1 -1
- package/build/compiler/generator/artifacts/lr.d.ts +51 -0
- package/build/{utility → compiler/generator/artifacts}/lr.js +53 -58
- package/build/compiler/generator/artifacts/lr.js.map +1 -0
- package/build/compiler/generator/artifacts/standard.d.ts +7 -0
- package/build/compiler/generator/artifacts/standard.js +28 -0
- package/build/compiler/generator/artifacts/standard.js.map +1 -0
- package/build/compiler/generator/generator.d.ts +24 -0
- package/build/compiler/{generator.js → generator/generator.js} +71 -75
- package/build/compiler/generator/generator.js.map +1 -0
- package/build/compiler/outputs/javascript.d.ts +1 -1
- package/build/compiler/outputs/json.d.ts +1 -1
- package/build/compiler/outputs/typescript.d.ts +1 -1
- package/build/grammars/gwell.js +1 -1
- package/build/parser/algorithms/lr.d.ts +2 -5
- package/build/parser/algorithms/lr.js +41 -14
- package/build/parser/algorithms/lr.js.map +1 -1
- package/build/typings.d.ts +18 -1
- package/build/utility/general.d.ts +3 -4
- package/build/utility/general.js +6 -10
- package/build/utility/general.js.map +1 -1
- package/package.json +1 -1
- package/src/compiler/compiler.ts +3 -2
- package/src/compiler/generator/artifacts/lr.ts +155 -0
- package/src/compiler/generator/artifacts/standard.ts +26 -0
- package/src/compiler/{generator.ts → generator/generator.ts} +75 -75
- package/src/compiler/outputs/javascript.ts +1 -1
- package/src/compiler/outputs/json.ts +1 -1
- package/src/compiler/outputs/typescript.ts +1 -1
- package/src/grammars/gwell.gwell +1 -1
- package/src/grammars/gwell.js +1 -1
- package/src/grammars/gwell.json +1 -1
- package/src/parser/algorithms/lr.ts +55 -18
- package/src/typings.ts +17 -1
- package/src/utility/general.ts +6 -9
- package/build/compiler/generator.d.ts +0 -23
- package/build/compiler/generator.js.map +0 -1
- package/build/utility/lr.d.ts +0 -52
- package/build/utility/lr.js.map +0 -1
- package/src/utility/lr.ts +0 -152
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Generator } from "../generator";
|
|
2
|
+
import { Dictionary, GeneratorGrammarRule, GeneratorGrammarSymbol, GrammarTypeRule } from "../../../typings";
|
|
3
|
+
import { Collection, GeneratorSymbolCollection } from "../../../utility/general";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class LRParseTableBuilder {
|
|
7
|
+
rules: Collection<GeneratorGrammarRule> = new Collection();
|
|
8
|
+
table: Dictionary<StateBuilder> = Object.create(null)
|
|
9
|
+
symbols: GeneratorSymbolCollection = new GeneratorSymbolCollection();
|
|
10
|
+
|
|
11
|
+
constructor(public generator: Generator) {
|
|
12
|
+
const augmented = { name: Symbol() as unknown as string, symbols: [{ rule: generator.state.grammar.start }] }
|
|
13
|
+
generator.state.grammar.rules[augmented.name] = [augmented];
|
|
14
|
+
this.addState([{ rule: augmented, dot: 0 }]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
addState(seed: StateItem[]) {
|
|
18
|
+
const id = this.encodeStateItems(seed);
|
|
19
|
+
if (id in this.table)
|
|
20
|
+
return this.table[id];
|
|
21
|
+
|
|
22
|
+
const state = new StateBuilder(this, seed);
|
|
23
|
+
this.table[id] = state;
|
|
24
|
+
for (const q in state.queue) {
|
|
25
|
+
this.addState(state.queue[q])
|
|
26
|
+
}
|
|
27
|
+
state.queue = {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
encodeRule(rule: GeneratorGrammarRule, dot: number) {
|
|
31
|
+
return this.rules.encode(rule) + '.' + dot;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
encodeStateItems(seed: StateItem[]) {
|
|
35
|
+
return Array.from(new Set(seed)).map(v => this.encodeRule(v.rule, v.dot)).sort().join()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
serialize(depth: number = 0) {
|
|
39
|
+
const map = {};
|
|
40
|
+
for (const key in this.table) {
|
|
41
|
+
map[key] = this.serializeState(this.table[key].serialize(), depth + 1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return Generator.Pretty(map, depth)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
serializeState(state: State, depth: number = 0) {
|
|
48
|
+
return Generator.Pretty({
|
|
49
|
+
actions: state.actions.map(v => this.serializeNext(v, depth + 1)),
|
|
50
|
+
goto: Generator.Pretty(state.goto, depth + 1),
|
|
51
|
+
reduce: state.reduce ? this.generator.serializeGrammarRule(state.reduce) : null,
|
|
52
|
+
isFinal: state.isFinal ? 'true' : 'false'
|
|
53
|
+
}, depth);
|
|
54
|
+
}
|
|
55
|
+
serializeNext(next: Next, depth: number) {
|
|
56
|
+
return Generator.Pretty({
|
|
57
|
+
symbol: Generator.SerializeSymbol(next.symbol),
|
|
58
|
+
next: JSON.stringify(next.next)
|
|
59
|
+
}, -1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
class StateBuilder {
|
|
64
|
+
isFinal = false;
|
|
65
|
+
|
|
66
|
+
outputs: StateOut = {
|
|
67
|
+
goto: {},
|
|
68
|
+
action: {}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
queue: { [key: string]: StateItem[] } = {};
|
|
72
|
+
actions: Map<GeneratorGrammarSymbol, string> = new Map();
|
|
73
|
+
goto: Map<GeneratorGrammarSymbol, string> = new Map();
|
|
74
|
+
reduce?: GeneratorGrammarRule;
|
|
75
|
+
|
|
76
|
+
constructor(private collection: LRParseTableBuilder, items: StateItem[]) {
|
|
77
|
+
const visited = new Set<GeneratorGrammarSymbol>();
|
|
78
|
+
for (const item of items) {
|
|
79
|
+
this.closure(item.rule, item.dot, visited);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.isFinal) {
|
|
83
|
+
this.reduce = items[0].rule;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
for (const k in this.outputs.goto) {
|
|
87
|
+
const seed = this.outputs.goto[k];
|
|
88
|
+
const stateId = this.collection.encodeStateItems(seed);
|
|
89
|
+
this.queue[stateId] = seed;
|
|
90
|
+
this.goto.set(this.collection.symbols.decode(k), stateId);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (const k in this.outputs.action) {
|
|
94
|
+
const seed = this.outputs.action[k];
|
|
95
|
+
const stateId = this.collection.encodeStateItems(seed);
|
|
96
|
+
this.queue[stateId] = seed;
|
|
97
|
+
this.actions.set(this.collection.symbols.decode(k), stateId);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private closure(rule: GeneratorGrammarRule, dot: number, visited: Set<GeneratorGrammarSymbol>) {
|
|
102
|
+
const isFinal = rule.symbols.length == dot;
|
|
103
|
+
this.isFinal = isFinal || this.isFinal;
|
|
104
|
+
const symbol = rule.symbols[dot];
|
|
105
|
+
|
|
106
|
+
if (isFinal || visited.has(symbol))
|
|
107
|
+
return;
|
|
108
|
+
|
|
109
|
+
visited.add(symbol);
|
|
110
|
+
const stateItem = { rule, dot: dot + 1 };
|
|
111
|
+
|
|
112
|
+
if (Generator.SymbolIsTerminal(symbol)) {
|
|
113
|
+
const id = this.collection.symbols.encode(symbol);
|
|
114
|
+
this.outputs.action[id] = this.outputs.action[id] || [];
|
|
115
|
+
this.outputs.action[id].push(stateItem);
|
|
116
|
+
} else {
|
|
117
|
+
const id = this.collection.symbols.encode(symbol);
|
|
118
|
+
const name = typeof symbol === 'string' ? symbol : (symbol as GrammarTypeRule).rule;
|
|
119
|
+
this.outputs.goto[id] = this.outputs.goto[id] || [];
|
|
120
|
+
this.outputs.goto[id].push(stateItem);
|
|
121
|
+
for (const rule of this.collection.generator.state.grammar.rules[name]) {
|
|
122
|
+
this.closure(rule, 0, visited)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
serialize(): State {
|
|
128
|
+
const actions: Next[] = [];
|
|
129
|
+
const goto: { [key: string]: string } = {}
|
|
130
|
+
for (const [symbol, next] of this.actions) {
|
|
131
|
+
actions.push({ symbol, next });
|
|
132
|
+
}
|
|
133
|
+
for (const [symbol, next] of this.goto) {
|
|
134
|
+
goto[typeof symbol == 'object' ? (symbol as any).rule : symbol] = JSON.stringify(next);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return { actions, goto, reduce: this.reduce, isFinal: this.isFinal };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
interface State {
|
|
142
|
+
actions: Next[];
|
|
143
|
+
goto: { [key: string]: string };
|
|
144
|
+
reduce: GeneratorGrammarRule;
|
|
145
|
+
isFinal: boolean;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
type Next = { symbol: GeneratorGrammarSymbol, next: string };
|
|
149
|
+
|
|
150
|
+
type StateItem = { rule: GeneratorGrammarRule, dot: number };
|
|
151
|
+
|
|
152
|
+
interface StateOut {
|
|
153
|
+
action: Dictionary<StateItem[]>;
|
|
154
|
+
goto: Dictionary<StateItem[]>;
|
|
155
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { GeneratorGrammarRule, } from "../../../typings";
|
|
2
|
+
import { Generator } from "../generator";
|
|
3
|
+
|
|
4
|
+
export class StandardGrammar {
|
|
5
|
+
|
|
6
|
+
constructor(private generator: Generator) { }
|
|
7
|
+
|
|
8
|
+
serialize(depth: number = 0) {
|
|
9
|
+
if (!this.generator.state.grammar) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return Generator.Pretty({
|
|
13
|
+
start: JSON.stringify(this.generator.state.grammar.start),
|
|
14
|
+
rules: this.serializeGrammarRules(depth + 1)
|
|
15
|
+
}, depth);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private serializeGrammarRules(depth: number = 0) {
|
|
19
|
+
const map = {};
|
|
20
|
+
for (const rule in this.generator.state.grammar.rules) {
|
|
21
|
+
map[rule] = this.generator.state.grammar.rules[rule].map(v => this.generator.serializeGrammarRule(v))
|
|
22
|
+
}
|
|
23
|
+
return Generator.Pretty(map, depth);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Dictionary, GeneratorState, GeneratorGrammarRule, GeneratorGrammarSymbol, LexerConfig, LexerStateDefinition } from "
|
|
1
|
+
import { Dictionary, GeneratorState, GeneratorGrammarRule, GeneratorGrammarSymbol, LexerConfig, LexerStateDefinition } from "../../typings";
|
|
2
|
+
import { LRParseTableBuilder } from "./artifacts/lr";
|
|
3
|
+
import { StandardGrammar } from "./artifacts/standard";
|
|
2
4
|
|
|
3
5
|
const PostProcessors = {
|
|
4
6
|
"join": "({data}) => data.join('')",
|
|
@@ -36,9 +38,21 @@ export class Generator {
|
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
serializeLanguage(depth: number = 0) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const serialier = new StandardGrammar(this);
|
|
42
|
+
let lr = null;
|
|
43
|
+
|
|
44
|
+
if ('lr' in this.state.config) {
|
|
45
|
+
const table = new LRParseTableBuilder(this);
|
|
46
|
+
lr = Generator.Pretty({
|
|
47
|
+
k: "0",
|
|
48
|
+
table: table.serialize(depth + 2)
|
|
49
|
+
}, depth + 1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return Generator.Pretty({
|
|
53
|
+
grammar: serialier.serialize(depth + 1),
|
|
54
|
+
lexer: this.serializeLexerConfig(depth + 1),
|
|
55
|
+
lr
|
|
42
56
|
}, depth);
|
|
43
57
|
}
|
|
44
58
|
|
|
@@ -80,59 +94,7 @@ export class Generator {
|
|
|
80
94
|
target.rules.push(...state.rules);
|
|
81
95
|
}
|
|
82
96
|
|
|
83
|
-
|
|
84
|
-
if (!this.state.grammar) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
return this.pretty({
|
|
88
|
-
start: JSON.stringify(this.state.grammar.start),
|
|
89
|
-
rules: this.serializeGrammarRules(depth + 1)
|
|
90
|
-
}, depth);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private serializeGrammarRules(depth: number = 0) {
|
|
94
|
-
const map = {};
|
|
95
|
-
for (const rule in this.state.grammar.rules) {
|
|
96
|
-
map[rule] = this.state.grammar.rules[rule].map(v => this.serializeGrammarRule(v))
|
|
97
|
-
}
|
|
98
|
-
return this.pretty(map, depth);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
private serializeSymbol(s: GeneratorGrammarSymbol) {
|
|
102
|
-
if (typeof s === 'string') {
|
|
103
|
-
return JSON.stringify(s);
|
|
104
|
-
} else if ('rule' in s) {
|
|
105
|
-
return JSON.stringify(s.rule);
|
|
106
|
-
} else if ('regex' in s) {
|
|
107
|
-
return `/${s.regex}/${s.flags || ''}`;
|
|
108
|
-
} else if ('token' in s) {
|
|
109
|
-
return `{ token: ${JSON.stringify(s.token)} }`;
|
|
110
|
-
} else if ('literal' in s) {
|
|
111
|
-
return `{ literal: ${JSON.stringify(s.literal)} }`;
|
|
112
|
-
} else if ('js' in s) {
|
|
113
|
-
return s.js;
|
|
114
|
-
} else {
|
|
115
|
-
return JSON.stringify(s);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
private serializeGrammarRule(rule: GeneratorGrammarRule) {
|
|
120
|
-
const symbols = [];
|
|
121
|
-
const alias = {};
|
|
122
|
-
for (let i = 0; i < rule.symbols.length; i++) {
|
|
123
|
-
symbols.push(this.serializeSymbol(rule.symbols[i]));
|
|
124
|
-
if (rule.symbols[i].alias) {
|
|
125
|
-
alias[rule.symbols[i].alias] = i;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return this.pretty({
|
|
129
|
-
name: JSON.stringify(rule.name),
|
|
130
|
-
symbols: this.pretty(symbols, -1),
|
|
131
|
-
postprocess: this.serializePostProcess(rule.postprocess, alias)
|
|
132
|
-
}, -1);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
private serializePostProcess(postprocess: GeneratorGrammarRule['postprocess'], alias: Dictionary<number>) {
|
|
97
|
+
serializePostProcess(postprocess: GeneratorGrammarRule['postprocess'], alias: Dictionary<number>) {
|
|
136
98
|
postprocess = this.state.grammar.config.postprocessorOverride || postprocess || this.state.grammar.config.postprocessorDefault;
|
|
137
99
|
if (!postprocess)
|
|
138
100
|
return null;
|
|
@@ -162,7 +124,7 @@ export class Generator {
|
|
|
162
124
|
if (typeof this.state.lexer === 'string')
|
|
163
125
|
return this.state.lexer;
|
|
164
126
|
|
|
165
|
-
return
|
|
127
|
+
return Generator.Pretty({
|
|
166
128
|
start: JSON.stringify(this.state.lexer.start),
|
|
167
129
|
states: this.serializeLexerConfigStates(depth + 1)
|
|
168
130
|
}, depth);
|
|
@@ -172,22 +134,22 @@ export class Generator {
|
|
|
172
134
|
const map = {};
|
|
173
135
|
for (const key in this.state.lexer.states) {
|
|
174
136
|
const state = this.state.lexer.states[key];
|
|
175
|
-
map[state.name] =
|
|
137
|
+
map[state.name] = Generator.Pretty({
|
|
176
138
|
name: JSON.stringify(state.name),
|
|
177
139
|
default: state.default ? JSON.stringify(state.default) : null,
|
|
178
140
|
unmatched: state.unmatched ? JSON.stringify(state.unmatched) : null,
|
|
179
141
|
rules: this.serializeLexerConfigStateRules(state.rules, depth + 2)
|
|
180
142
|
}, depth + 1);
|
|
181
143
|
}
|
|
182
|
-
return
|
|
144
|
+
return Generator.Pretty(map, depth);
|
|
183
145
|
}
|
|
184
146
|
|
|
185
147
|
private serializeLexerConfigStateRules(rules: LexerConfig['states'][0]['rules'], depth: number) {
|
|
186
148
|
const ary = rules.map(rule => {
|
|
187
149
|
if ('import' in rule)
|
|
188
|
-
return
|
|
189
|
-
return
|
|
190
|
-
when:
|
|
150
|
+
return Generator.Pretty({ import: JSON.stringify(rule.import) }, -1)
|
|
151
|
+
return Generator.Pretty({
|
|
152
|
+
when: Generator.SerializeSymbol(rule.when as any),
|
|
191
153
|
type: JSON.stringify(rule.type),
|
|
192
154
|
tag: JSON.stringify(rule.tag),
|
|
193
155
|
pop: JSON.stringify(rule.pop),
|
|
@@ -197,38 +159,76 @@ export class Generator {
|
|
|
197
159
|
goto: JSON.stringify(rule.goto),
|
|
198
160
|
}, -1);
|
|
199
161
|
});
|
|
200
|
-
return
|
|
162
|
+
return Generator.Pretty(ary, depth);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
serializeGrammarRule(rule: GeneratorGrammarRule) {
|
|
166
|
+
const symbols = [];
|
|
167
|
+
const alias = {};
|
|
168
|
+
for (let i = 0; i < rule.symbols.length; i++) {
|
|
169
|
+
symbols.push(Generator.SerializeSymbol(rule.symbols[i]));
|
|
170
|
+
if (rule.symbols[i].alias) {
|
|
171
|
+
alias[rule.symbols[i].alias] = i;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return Generator.Pretty({
|
|
176
|
+
name: JSON.stringify(rule.name),
|
|
177
|
+
symbols: Generator.Pretty(symbols, -1),
|
|
178
|
+
postprocess: this.serializePostProcess(rule.postprocess, alias)
|
|
179
|
+
}, -1);
|
|
201
180
|
}
|
|
202
181
|
|
|
203
|
-
|
|
182
|
+
static NewLine(depth: number) {
|
|
204
183
|
return '\n' + ' '.repeat(depth * 4);
|
|
205
184
|
}
|
|
206
185
|
|
|
207
|
-
|
|
186
|
+
static Pretty(obj: string[] | { [key: string]: string | (string[]) }, depth = 0) {
|
|
208
187
|
if (Array.isArray(obj)) {
|
|
209
188
|
let r = `[`;
|
|
210
189
|
for (let i = 0; i < obj.length; i++) {
|
|
211
190
|
const value = obj[i];
|
|
212
|
-
r += `${depth >= 0 ?
|
|
191
|
+
r += `${depth >= 0 ? Generator.NewLine(depth + 1) : ' '}${value}${(Generator.IsVal(obj[i + 1]) ? ',' : '')}`;
|
|
213
192
|
}
|
|
214
|
-
r += `${depth >= 0 ?
|
|
193
|
+
r += `${depth >= 0 ? Generator.NewLine(depth) : ' '}]`;
|
|
215
194
|
return r;
|
|
216
195
|
}
|
|
217
196
|
|
|
218
197
|
let r = `{`;
|
|
219
|
-
const keys = Object.keys(obj).filter(v =>
|
|
220
|
-
const prefix = depth >= 0 ?
|
|
198
|
+
const keys = Object.keys(obj).filter(v => Generator.IsVal(obj[v]));
|
|
199
|
+
const prefix = depth >= 0 ? Generator.NewLine(depth + 1) : ' ';
|
|
221
200
|
for (let i = 0; i < keys.length; i++) {
|
|
222
|
-
const key = /[a-z_][a-z\d_$]*/i.test(keys[i]) ? keys[i] : keys[i];
|
|
223
|
-
const value = Array.isArray(obj[keys[i]]) ?
|
|
224
|
-
const suffix = (
|
|
201
|
+
const key = /[a-z_][a-z\d_$]*/i.test(keys[i]) ? keys[i] : JSON.stringify(keys[i]);
|
|
202
|
+
const value = Array.isArray(obj[keys[i]]) ? Generator.Pretty(obj[keys[i]] as string[], depth >= 0 ? depth + 1 : -1) : obj[keys[i]];
|
|
203
|
+
const suffix = (Generator.IsVal(obj[keys[i + 1]]) ? ',' : '');
|
|
225
204
|
r += `${prefix}${key}: ${value}${suffix}`;
|
|
226
205
|
}
|
|
227
|
-
r += `${depth >= 0 ?
|
|
206
|
+
r += `${depth >= 0 ? Generator.NewLine(depth) : ' '}}`;
|
|
228
207
|
return r;
|
|
229
208
|
}
|
|
230
209
|
|
|
231
|
-
|
|
210
|
+
static IsVal(value) {
|
|
232
211
|
return typeof value !== 'undefined' && value !== null;
|
|
233
212
|
}
|
|
213
|
+
|
|
214
|
+
static SerializeSymbol(s: GeneratorGrammarSymbol) {
|
|
215
|
+
if (typeof s === 'string') {
|
|
216
|
+
return JSON.stringify(s);
|
|
217
|
+
} else if ('rule' in s) {
|
|
218
|
+
return JSON.stringify(s.rule);
|
|
219
|
+
} else if ('regex' in s) {
|
|
220
|
+
return `/${s.regex}/${s.flags || ''}`;
|
|
221
|
+
} else if ('token' in s) {
|
|
222
|
+
return `{ token: ${JSON.stringify(s.token)} }`;
|
|
223
|
+
} else if ('literal' in s) {
|
|
224
|
+
return `{ literal: ${JSON.stringify(s.literal)} }`;
|
|
225
|
+
} else {
|
|
226
|
+
return JSON.stringify(s);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
static SymbolIsTerminal(s: GeneratorGrammarSymbol) {
|
|
231
|
+
return !(typeof s === 'string' || 'rule' in s);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
234
|
}
|
package/src/grammars/gwell.gwell
CHANGED
|
@@ -115,7 +115,7 @@ grammar: {{
|
|
|
115
115
|
| section T_WS section_list : {{ [$0].concat($2) }}
|
|
116
116
|
|
|
117
117
|
section ->
|
|
118
|
-
K_CONFIG _ L_COLON _ L_TEMPLATEL _ kv_list _ L_TEMPLATER : {{ { config: Object.assign(...$
|
|
118
|
+
K_CONFIG _ L_COLON _ L_TEMPLATEL _ kv_list:list _ L_TEMPLATER : {{ { config: Object.assign(...$list) } }}
|
|
119
119
|
| K_IMPORT _ L_STAR _ K_FROM __ T_WORD:import _ L_SCOLON : {{ { import: $import } }}
|
|
120
120
|
| K_IMPORT _ L_STAR _ K_FROM __ T_STRING:import _ L_SCOLON : {{ { import: $import, path: true } }}
|
|
121
121
|
| K_LEXER _ L_COLON _ L_TEMPLATEL _ lexer:lexer _ L_TEMPLATER : {{ { lexer: Object.assign(...$lexer) } }}
|
package/src/grammars/gwell.js
CHANGED
|
@@ -15,7 +15,7 @@ function GWLanguage(){
|
|
|
15
15
|
{ name: "section_list", symbols: [ "section", "T_WS", "section_list" ], postprocess: ({data}) => { return [data[0]].concat(data[2]); } }
|
|
16
16
|
],
|
|
17
17
|
section: [
|
|
18
|
-
{ name: "section", symbols: [ "K_CONFIG", "_", "L_COLON", "_", "L_TEMPLATEL", "_", "kv_list", "_", "L_TEMPLATER" ], postprocess: ({data}) => { return { config: Object.assign(...data[
|
|
18
|
+
{ name: "section", symbols: [ "K_CONFIG", "_", "L_COLON", "_", "L_TEMPLATEL", "_", "kv_list", "_", "L_TEMPLATER" ], postprocess: ({data}) => { return { config: Object.assign(...data[6]) }; } },
|
|
19
19
|
{ name: "section", symbols: [ "K_IMPORT", "_", "L_STAR", "_", "K_FROM", "__", "T_WORD", "_", "L_SCOLON" ], postprocess: ({data}) => { return { import: data[6] }; } },
|
|
20
20
|
{ name: "section", symbols: [ "K_IMPORT", "_", "L_STAR", "_", "K_FROM", "__", "T_STRING", "_", "L_SCOLON" ], postprocess: ({data}) => { return { import: data[6], path: true }; } },
|
|
21
21
|
{ name: "section", symbols: [ "K_LEXER", "_", "L_COLON", "_", "L_TEMPLATEL", "_", "lexer", "_", "L_TEMPLATER" ], postprocess: ({data}) => { return { lexer: Object.assign(...data[6]) }; } },
|
package/src/grammars/gwell.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"state":{"grammar":{"start":"main","config":{},"rules":{"main":[{"name":"main","symbols":[{"rule":"_"},{"rule":"section_list"},{"rule":"_"}],"postprocess":{"template":"$1"}}],"section_list":[{"name":"section_list","symbols":[{"rule":"section"}],"postprocess":{"template":"[$0]"}},{"name":"section_list","symbols":[{"rule":"section"},{"rule":"T_WS"},{"rule":"section_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"section":[{"name":"section","symbols":[{"rule":"K_CONFIG"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"L_TEMPLATEL"},{"rule":"_"},{"rule":"kv_list"},{"rule":"_"},{"rule":"L_TEMPLATER"}],"postprocess":{"template":"{ config: Object.assign(...$4) }"}},{"name":"section","symbols":[{"rule":"K_IMPORT"},{"rule":"_"},{"rule":"L_STAR"},{"rule":"_"},{"rule":"K_FROM"},{"rule":"__"},{"rule":"T_WORD","alias":"import"},{"rule":"_"},{"rule":"L_SCOLON"}],"postprocess":{"template":"{ import: $import }"}},{"name":"section","symbols":[{"rule":"K_IMPORT"},{"rule":"_"},{"rule":"L_STAR"},{"rule":"_"},{"rule":"K_FROM"},{"rule":"__"},{"rule":"T_STRING","alias":"import"},{"rule":"_"},{"rule":"L_SCOLON"}],"postprocess":{"template":"{ import: $import, path: true }"}},{"name":"section","symbols":[{"rule":"K_LEXER"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"L_TEMPLATEL"},{"rule":"_"},{"rule":"lexer","alias":"lexer"},{"rule":"_"},{"rule":"L_TEMPLATER"}],"postprocess":{"template":"{ lexer: Object.assign(...$lexer) }"}},{"name":"section","symbols":[{"rule":"K_GRAMMAR"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"L_TEMPLATEL"},{"rule":"_"},{"rule":"grammar","alias":"grammar"},{"rule":"_"},{"rule":"L_TEMPLATER"}],"postprocess":{"template":"{ grammar: $grammar }"}},{"name":"section","symbols":[{"rule":"K_BODY"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_JS","alias":"js"}],"postprocess":{"template":"{ body: $js }"}},{"name":"section","symbols":[{"rule":"K_BODY"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_STRING","alias":"js"}],"postprocess":{"template":"{ body: $js, path: true }"}},{"name":"section","symbols":[{"rule":"K_HEAD"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_JS","alias":"js"}],"postprocess":{"template":"{ head: $js }"}},{"name":"section","symbols":[{"rule":"K_HEAD"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_STRING","alias":"js"}],"postprocess":{"template":"{ head: $js, path: true }"}}],"lexer":[{"name":"lexer","symbols":[{"rule":"kv_list"},{"rule":"_"},{"rule":"state_list"}],"postprocess":{"template":"$0.concat({ states: $2 })"}},{"name":"lexer","symbols":[{"rule":"state_list"}],"postprocess":{"template":"[{ states: $0 }]"}}],"state_list":[{"name":"state_list","symbols":[{"rule":"state"}],"postprocess":{"template":"data"}},{"name":"state_list","symbols":[{"rule":"state"},{"rule":"_"},{"rule":"state_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"state":[{"name":"state","symbols":[{"rule":"state_declare"},{"rule":"_"},{"rule":"state_definition"}],"postprocess":{"template":"Object.assign({ name: $0 }, $2)"}}],"state_declare":[{"name":"state_declare","symbols":[{"rule":"T_WORD"},{"rule":"_"},{"rule":"L_ARROW"}],"postprocess":{"template":"$0"}}],"state_definition":[{"name":"state_definition","symbols":[{"rule":"kv_list"},{"rule":"_"},{"rule":"token_list"}],"postprocess":{"template":"Object.assign(...$0, { rules: $2 })"}},{"name":"state_definition","symbols":[{"rule":"token_list"}],"postprocess":{"template":"{ rules: $0 }"}}],"token_list":[{"name":"token_list","symbols":[{"rule":"token"}],"postprocess":{"template":"data"}},{"name":"token_list","symbols":[{"rule":"token"},{"rule":"_"},{"rule":"token_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"token":[{"name":"token","symbols":[{"rule":"L_DASH"},{"rule":"_"},{"rule":"K_IMPORT"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"word_list"}],"postprocess":{"template":"{ import: $6 }"}},{"name":"token","symbols":[{"rule":"L_DASH"},{"rule":"_"},{"rule":"token_definition_list"}],"postprocess":{"template":"Object.assign(...$2)"}}],"token_definition_list":[{"name":"token_definition_list","symbols":[{"rule":"token_definition"}],"postprocess":{"template":"data"}},{"name":"token_definition_list","symbols":[{"rule":"token_definition"},{"rule":"_"},{"rule":"token_definition_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"token_definition":[{"name":"token_definition","symbols":[{"rule":"K_TAG"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"string_list"}],"postprocess":{"template":"{ tag: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_WHEN"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_STRING"}],"postprocess":{"template":"{ when: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_WHEN"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_REGEX"}],"postprocess":{"template":"{ when: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_POP"}],"postprocess":{"template":"{ pop: 1 }"}},{"name":"token_definition","symbols":[{"rule":"K_POP"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_INTEGER"}],"postprocess":{"template":"{ pop: parseInt($4) }"}},{"name":"token_definition","symbols":[{"rule":"K_POP"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"K_ALL"}],"postprocess":{"template":"{ pop: \"all\" }"}},{"name":"token_definition","symbols":[{"rule":"K_HIGHLIGHT"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_STRING"}],"postprocess":{"template":"{ highlight: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_INSET"}],"postprocess":{"template":"{ inset: 1 }"}},{"name":"token_definition","symbols":[{"rule":"K_INSET"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_INTEGER"}],"postprocess":{"template":"{ inset: parseInt($4) }"}},{"name":"token_definition","symbols":[{"rule":"K_SET"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_WORD"}],"postprocess":{"template":"{ set: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_GOTO"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_WORD"}],"postprocess":{"template":"{ goto: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_TYPE"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_STRING"}],"postprocess":{"template":"{ type: $4 }"}}],"grammar":[{"name":"grammar","symbols":[{"rule":"kv_list"},{"rule":"_"},{"rule":"grammar_rule_list"}],"postprocess":{"template":"{ config: Object.assign(...$0), rules: $2 }"}},{"name":"grammar","symbols":[{"rule":"grammar_rule_list"}],"postprocess":{"template":"{ rules: $0 }"}}],"grammar_rule_list":[{"name":"grammar_rule_list","symbols":[{"rule":"grammar_rule"}],"postprocess":{"template":"[$0]"}},{"name":"grammar_rule_list","symbols":[{"rule":"grammar_rule"},{"rule":"_"},{"rule":"grammar_rule_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"grammar_rule":[{"name":"grammar_rule","symbols":[{"rule":"T_WORD"},{"rule":"_"},{"rule":"L_ARROW"},{"rule":"_"},{"rule":"expression_list"}],"postprocess":{"template":"{ name: $0, expressions: $4 }"}},{"name":"grammar_rule","symbols":[{"rule":"T_WORD"},{"rule":"__"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_JS","alias":"js"},{"rule":"_"},{"rule":"L_ARROW"},{"rule":"_"},{"rule":"expression_list","alias":"expressions"}],"postprocess":{"template":"{ name: $0, expressions: $expressions, postprocess: $js }"}},{"name":"grammar_rule","symbols":[{"rule":"T_WORD"},{"rule":"__"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_GRAMMAR_TEMPLATE","alias":"template"},{"rule":"_"},{"rule":"L_ARROW"},{"rule":"_"},{"rule":"expression_list","alias":"expressions"}],"postprocess":{"template":"{ name: $0, expressions: $expressions, postprocess: $template }"}}],"expression_list":[{"name":"expression_list","symbols":[{"rule":"expression"}]},{"name":"expression_list","symbols":[{"rule":"expression_list"},{"rule":"_"},{"rule":"L_PIPE"},{"rule":"_"},{"rule":"expression"}],"postprocess":{"template":"$0.concat([$4])"}}],"expression":[{"name":"expression","symbols":[{"rule":"expression_symbol_list"}],"postprocess":{"template":"{ symbols: $0 }"}},{"name":"expression","symbols":[{"rule":"expression_symbol_list"},{"rule":"__"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_JS","alias":"js"}],"postprocess":{"template":"{ symbols: $0, postprocess: $js }"}},{"name":"expression","symbols":[{"rule":"expression_symbol_list"},{"rule":"__"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_GRAMMAR_TEMPLATE","alias":"template"}],"postprocess":{"template":"{ symbols: $0, postprocess: $template }"}}],"expression_symbol_list":[{"name":"expression_symbol_list","symbols":[{"rule":"expression_symbol"}]},{"name":"expression_symbol_list","symbols":[{"rule":"expression_symbol_list"},{"rule":"T_WS"},{"rule":"expression_symbol"}],"postprocess":{"template":"$0.concat([$2])"}}],"expression_symbol":[{"name":"expression_symbol","symbols":[{"rule":"expression_symbol_match"}],"postprocess":{"template":"$0"}},{"name":"expression_symbol","symbols":[{"rule":"expression_symbol_match"},{"rule":"L_COLON"},{"rule":"T_WORD"}],"postprocess":{"template":"{ ...$0, alias: $2 }"}},{"name":"expression_symbol","symbols":[{"rule":"expression_symbol_match"},{"rule":"expression_repeater"}],"postprocess":{"template":"{ expression: $0, repeat: $1 }"}},{"name":"expression_symbol","symbols":[{"rule":"expression_symbol_match"},{"rule":"expression_repeater"},{"rule":"L_COLON"},{"rule":"T_WORD"}],"postprocess":{"template":"{ expression: $0, repeat: $1, alias: $4 }"}}],"expression_symbol_match":[{"name":"expression_symbol_match","symbols":[{"rule":"T_WORD"}],"postprocess":{"template":"{ rule: $0 }"}},{"name":"expression_symbol_match","symbols":[{"rule":"T_STRING"},{"rule":"expression_symbol_match$RPT01x1"}],"postprocess":{"template":"{ literal: $0, insensitive: !!$1 }"}},{"name":"expression_symbol_match","symbols":[{"rule":"L_DSIGN"},{"rule":"T_WORD"}],"postprocess":{"template":"{ token: $1}"}},{"name":"expression_symbol_match","symbols":[{"rule":"L_DSIGN"},{"rule":"T_STRING"}],"postprocess":{"template":"{ token: $1}"}},{"name":"expression_symbol_match","symbols":[{"rule":"T_REGEX"}],"postprocess":{"template":"$0"}},{"name":"expression_symbol_match","symbols":[{"rule":"L_PARENL"},{"rule":"_"},{"rule":"expression_list"},{"rule":"_"},{"rule":"L_PARENR"}],"postprocess":{"template":"{ subexpression: $2 }"}},{"name":"expression_symbol_match","symbols":[{"rule":"T_JS"}],"postprocess":{"template":"$0"}}],"expression_symbol_match$RPT01x1":[{"name":"expression_symbol_match$RPT01x1","symbols":[{"literal":"i","insensitive":false}],"postprocess":{"builtin":"first"}},{"name":"expression_symbol_match$RPT01x1","symbols":[],"postprocess":{"builtin":"null"}}],"expression_repeater":[{"name":"expression_repeater","symbols":[{"rule":"L_QMARK"}],"postprocess":{"template":"$0[0].value"}},{"name":"expression_repeater","symbols":[{"rule":"L_PLUS"}],"postprocess":{"template":"$0[0].value"}},{"name":"expression_repeater","symbols":[{"rule":"L_STAR"}],"postprocess":{"template":"$0[0].value"}}],"kv_list":[{"name":"kv_list","symbols":[{"rule":"kv"}],"postprocess":{"template":"data"}},{"name":"kv_list","symbols":[{"rule":"kv"},{"rule":"_"},{"rule":"kv_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"kv$SUBx1":[{"name":"kv$SUBx1","symbols":[{"rule":"T_WORD"}]},{"name":"kv$SUBx1","symbols":[{"rule":"T_STRING"}]},{"name":"kv$SUBx1","symbols":[{"rule":"T_INTEGER"}]},{"name":"kv$SUBx1","symbols":[{"rule":"T_JS"}]},{"name":"kv$SUBx1","symbols":[{"rule":"T_GRAMMAR_TEMPLATE"}]}],"kv":[{"name":"kv","symbols":[{"rule":"T_WORD"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"kv$SUBx1"}],"postprocess":{"template":"{ [$0]: $4[0] }"}}],"string_list":[{"name":"string_list","symbols":[{"rule":"T_STRING"}],"postprocess":{"template":"[$0]"}},{"name":"string_list","symbols":[{"rule":"T_STRING"},{"rule":"_"},{"rule":"L_COMMA"},{"rule":"_"},{"rule":"string_list"}],"postprocess":{"template":"[$0].concat($4)"}}],"word_list":[{"name":"word_list","symbols":[{"rule":"T_WORD"}],"postprocess":{"template":"[$0]"}},{"name":"word_list","symbols":[{"rule":"T_WORD"},{"rule":"_"},{"rule":"L_COMMA"},{"rule":"_"},{"rule":"word_list"}],"postprocess":{"template":"[$0].concat($4)"}}],"_$RPT0Nx1":[{"name":"_$RPT0Nx1","symbols":[]},{"name":"_$RPT0Nx1","symbols":[{"rule":"_$RPT0Nx1"},{"rule":"_$RPT0Nx1$SUBx1"}],"postprocess":{"builtin":"concat"}}],"_$RPT0Nx1$SUBx1":[{"name":"_$RPT0Nx1$SUBx1","symbols":[{"rule":"T_WS"}]},{"name":"_$RPT0Nx1$SUBx1","symbols":[{"rule":"T_COMMENT"}]}],"_":[{"name":"_","symbols":[{"rule":"_$RPT0Nx1"}],"postprocess":{"template":"null"}}],"__$RPT1Nx1$SUBx1":[{"name":"__$RPT1Nx1$SUBx1","symbols":[{"rule":"T_WS"}]},{"name":"__$RPT1Nx1$SUBx1","symbols":[{"rule":"T_COMMENT"}]}],"__$RPT1Nx1":[{"name":"__$RPT1Nx1","symbols":[{"rule":"__$RPT1Nx1$SUBx1"}]},{"name":"__$RPT1Nx1","symbols":[{"rule":"__$RPT1Nx1"},{"rule":"__$RPT1Nx1$SUBx2"}],"postprocess":{"builtin":"concat"}}],"__$RPT1Nx1$SUBx2":[{"name":"__$RPT1Nx1$SUBx2","symbols":[{"rule":"T_WS"}]},{"name":"__$RPT1Nx1$SUBx2","symbols":[{"rule":"T_COMMENT"}]}],"__":[{"name":"__","symbols":[{"rule":"__$RPT1Nx1"}],"postprocess":{"template":"null"}}],"L_COLON":[{"name":"L_COLON","symbols":[{"token":"L_COLON"}]}],"L_SCOLON":[{"name":"L_SCOLON","symbols":[{"token":"L_SCOLON"}]}],"L_QMARK":[{"name":"L_QMARK","symbols":[{"token":"L_QMARK"}]}],"L_PLUS":[{"name":"L_PLUS","symbols":[{"token":"L_PLUS"}]}],"L_STAR":[{"name":"L_STAR","symbols":[{"token":"L_STAR"}]}],"L_COMMA":[{"name":"L_COMMA","symbols":[{"token":"L_COMMA"}]}],"L_PIPE":[{"name":"L_PIPE","symbols":[{"token":"L_PIPE"}]}],"L_PARENL":[{"name":"L_PARENL","symbols":[{"token":"L_PARENL"}]}],"L_PARENR":[{"name":"L_PARENR","symbols":[{"token":"L_PARENR"}]}],"L_TEMPLATEL":[{"name":"L_TEMPLATEL","symbols":[{"token":"L_TEMPLATEL"}]}],"L_TEMPLATER":[{"name":"L_TEMPLATER","symbols":[{"token":"L_TEMPLATER"}]}],"L_ARROW":[{"name":"L_ARROW","symbols":[{"token":"L_ARROW"}]}],"L_DSIGN":[{"name":"L_DSIGN","symbols":[{"token":"L_DSIGN"}]}],"L_DASH":[{"name":"L_DASH","symbols":[{"token":"L_DASH"}]}],"K_ALL":[{"name":"K_ALL","symbols":[{"literal":"all","insensitive":false}]}],"K_TAG":[{"name":"K_TAG","symbols":[{"literal":"tag","insensitive":false}]}],"K_FROM":[{"name":"K_FROM","symbols":[{"literal":"from","insensitive":false}]}],"K_TYPE":[{"name":"K_TYPE","symbols":[{"literal":"type","insensitive":false}]}],"K_WHEN":[{"name":"K_WHEN","symbols":[{"literal":"when","insensitive":false}]}],"K_POP":[{"name":"K_POP","symbols":[{"literal":"pop","insensitive":false}]}],"K_HIGHLIGHT":[{"name":"K_HIGHLIGHT","symbols":[{"literal":"highlight","insensitive":false}]}],"K_INSET":[{"name":"K_INSET","symbols":[{"literal":"inset","insensitive":false}]}],"K_SET":[{"name":"K_SET","symbols":[{"literal":"set","insensitive":false}]}],"K_GOTO":[{"name":"K_GOTO","symbols":[{"literal":"goto","insensitive":false}]}],"K_CONFIG":[{"name":"K_CONFIG","symbols":[{"literal":"config","insensitive":false}]}],"K_LEXER":[{"name":"K_LEXER","symbols":[{"literal":"lexer","insensitive":false}]}],"K_GRAMMAR":[{"name":"K_GRAMMAR","symbols":[{"literal":"grammar","insensitive":false}]}],"K_IMPORT":[{"name":"K_IMPORT","symbols":[{"literal":"import","insensitive":false}]}],"K_BODY":[{"name":"K_BODY","symbols":[{"literal":"body","insensitive":false}]}],"K_HEAD":[{"name":"K_HEAD","symbols":[{"literal":"head","insensitive":false}]}],"T_JS$RPT0Nx1":[{"name":"T_JS$RPT0Nx1","symbols":[]},{"name":"T_JS$RPT0Nx1","symbols":[{"rule":"T_JS$RPT0Nx1"},{"token":"T_JSBODY"}],"postprocess":{"builtin":"concat"}}],"T_JS":[{"name":"T_JS","symbols":[{"token":"L_JSL"},{"rule":"T_JS$RPT0Nx1"},{"token":"L_JSR"}],"postprocess":{"template":"{ js: $1.map(v=>v.value).join('') }"}}],"T_GRAMMAR_TEMPLATE$RPT0Nx1":[{"name":"T_GRAMMAR_TEMPLATE$RPT0Nx1","symbols":[]},{"name":"T_GRAMMAR_TEMPLATE$RPT0Nx1","symbols":[{"rule":"T_GRAMMAR_TEMPLATE$RPT0Nx1"},{"token":"T_JSBODY"}],"postprocess":{"builtin":"concat"}}],"T_GRAMMAR_TEMPLATE":[{"name":"T_GRAMMAR_TEMPLATE","symbols":[{"token":"L_TEMPLATEL"},{"rule":"_"},{"rule":"T_GRAMMAR_TEMPLATE$RPT0Nx1"},{"rule":"_"},{"token":"L_TEMPLATER"}],"postprocess":{"template":"{ template: $2.map(v=>v.value).join('').trim() }"}}],"T_STRING":[{"name":"T_STRING","symbols":[{"token":"T_STRING"}],"postprocess":{"template":"JSON.parse($0.value)"}}],"T_WORD":[{"name":"T_WORD","symbols":[{"token":"T_WORD"}],"postprocess":{"template":"$0.value"}}],"T_REGEX$RPT0Nx1":[{"name":"T_REGEX$RPT0Nx1","symbols":[]},{"name":"T_REGEX$RPT0Nx1","symbols":[{"rule":"T_REGEX$RPT0Nx1"},{"regex":"[gmiuy]","flags":""}],"postprocess":{"builtin":"concat"}}],"T_REGEX":[{"name":"T_REGEX","symbols":[{"token":"T_REGEX"},{"rule":"T_REGEX$RPT0Nx1"}],"postprocess":{"template":"{ regex: $0.value.replace(/\\\\\\\\\\//g,'/').slice(1,-1), flags: $1.map(v=>v.value).join('').trim() }"}}],"T_COMMENT":[{"name":"T_COMMENT","symbols":[{"token":"T_COMMENT"}]}],"T_INTEGER":[{"name":"T_INTEGER","symbols":[{"token":"T_INTEGER"}],"postprocess":{"template":"$0.value"}}],"T_WS":[{"name":"T_WS","symbols":[{"token":"T_WS"}],"postprocess":{"template":"null"}}]},"uuids":{"expression_symbol_match$RPT01":1,"kv$SUB":1,"_$RPT0N":1,"_$RPT0Nx1$SUB":1,"__$RPT1N":1,"__$RPT1Nx1$SUB":2,"T_JS$RPT0N":1,"T_GRAMMAR_TEMPLATE$RPT0N":1,"T_REGEX$RPT0N":1}},"lexer":{"start":"start","states":{"start":{"name":"start","rules":[{"import":["string","js","ws","comment","l_scolon","l_star"]},{"when":{"regex":"lexer(?![a-zA-Z\\d_])","flags":""},"tag":["T_WORD"],"goto":"lexer","highlight":"type"},{"when":{"regex":"grammar(?![a-zA-Z\\d_])","flags":""},"tag":["T_WORD"],"goto":"grammar","highlight":"type"},{"when":{"regex":"config(?![a-zA-Z\\d_])","flags":""},"tag":["T_WORD"],"goto":"config","highlight":"type"},{"import":["kv"]}]},"config":{"name":"config","rules":[{"import":["ws","l_colon"]},{"when":"{{","tag":["L_TEMPLATEL"],"set":"config_inner"}]},"config_inner":{"name":"config_inner","rules":[{"import":["comment","kv"]},{"when":"}}","tag":["L_TEMPLATER"],"pop":1}]},"grammar":{"name":"grammar","rules":[{"import":["ws","l_colon"]},{"when":"{{","tag":["L_TEMPLATEL"],"set":"grammar_inner"}]},"grammar_inner":{"name":"grammar_inner","rules":[{"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"]},{"when":"}}","tag":["L_TEMPLATER"],"pop":1}]},"lexer":{"name":"lexer","rules":[{"import":["ws","l_colon"]},{"when":"{{","tag":["L_TEMPLATEL"],"set":"lexer_inner"}]},"lexer_inner":{"name":"lexer_inner","rules":[{"import":["ws","comment","regex","l_comma","l_arrow","l_dash","kv","js"]},{"when":"}}","tag":["L_TEMPLATER"],"pop":1}]},"js":{"name":"js","rules":[{"when":"${","tag":["L_JSL"],"goto":"js_wrap"}]},"js_wrap":{"name":"js_wrap","rules":[{"import":["jsignore"]},{"when":"{","tag":["T_JSBODY"],"goto":"js_literal"},{"when":"}","tag":["L_JSR"],"pop":1}],"default":"T_JSBODY","unmatched":"T_JSBODY"},"js_literal":{"name":"js_literal","rules":[{"import":["jsignore"]},{"when":"{","tag":["T_JSBODY"],"goto":"js_literal"},{"when":"}","tag":["T_JSBODY"],"pop":1}],"default":"T_JSBODY","unmatched":"T_JSBODY"},"js_template":{"name":"js_template","rules":[{"when":"{{","tag":["L_TEMPLATEL"],"goto":"js_template_inner"}]},"js_template_inner":{"name":"js_template_inner","rules":[{"import":["jsignore"]},{"when":"{","tag":["T_JSBODY"],"goto":"js_literal"},{"when":"}}","tag":["L_TEMPLATER"],"pop":1}],"default":"T_JSBODY","unmatched":"T_JSBODY"},"kv":{"name":"kv","rules":[{"import":["string","ws","word","l_colon","integer"]}]},"jsignore":{"name":"jsignore","rules":[{"when":{"regex":"\"(?:[^\"\\\\\\r\\n]|\\\\.)*\"","flags":""},"tag":["T_JSBODY"]},{"when":{"regex":"'(?:[^'\\\\\\r\\n]|\\\\.)*'","flags":""},"tag":["T_JSBODY"]},{"when":{"regex":"`(?:[^`\\\\]|\\\\.)*`","flags":""},"tag":["T_JSBODY"]},{"when":{"regex":"\\/(?:[^\\/\\\\\\r\\n]|\\\\.)+\\/[gmiyu]*","flags":""},"tag":["T_JSBODY"]},{"when":{"regex":"\\/\\/[^\\n]*","flags":""},"tag":["T_JSBODY"]},{"when":{"regex":"\\/\\*.*\\*\\/","flags":""},"tag":["T_JSBODY"]}]},"string":{"name":"string","rules":[{"when":{"regex":"\"(?:[^\"\\\\\\r\\n]|\\\\.)*\"","flags":""},"tag":["T_STRING"],"highlight":"string"}]},"string2":{"name":"string2","rules":[{"when":{"regex":"'(?:[^'\\\\\\r\\n]|\\\\.)*'","flags":""},"tag":["T_STRING"],"highlight":"string"}]},"string3":{"name":"string3","rules":[{"when":{"regex":"`(?:[^`\\\\]|\\\\.)*`","flags":""},"tag":["T_STRING"],"highlight":"string"}]},"regex":{"name":"regex","rules":[{"when":{"regex":"\\/(?:[^\\/\\\\\\r\\n]|\\\\.)+\\/","flags":""},"tag":["T_REGEX"],"highlight":"regexp"}]},"integer":{"name":"integer","rules":[{"when":{"regex":"\\d+","flags":""},"tag":["T_INTEGER"],"highlight":"number"}]},"word":{"name":"word","rules":[{"when":{"regex":"[a-zA-Z_][a-zA-Z_\\d]*","flags":""},"tag":["T_WORD"]}]},"ws":{"name":"ws","rules":[{"when":{"regex":"\\s+","flags":""},"tag":["T_WS"]}]},"l_colon":{"name":"l_colon","rules":[{"when":":","tag":["L_COLON"],"highlight":"keyword"}]},"l_scolon":{"name":"l_scolon","rules":[{"when":";","tag":["L_SCOLON"]}]},"l_qmark":{"name":"l_qmark","rules":[{"when":"?","tag":["L_QMARK"]}]},"l_plus":{"name":"l_plus","rules":[{"when":"+","tag":["L_PLUS"]}]},"l_star":{"name":"l_star","rules":[{"when":"*","tag":["L_STAR"]}]},"l_comma":{"name":"l_comma","rules":[{"when":",","tag":["L_COMMA"]}]},"l_pipe":{"name":"l_pipe","rules":[{"when":"|","tag":["L_PIPE"],"highlight":"keyword"}]},"l_parenl":{"name":"l_parenl","rules":[{"when":"(","tag":["L_PARENL"]}]},"l_parenr":{"name":"l_parenr","rules":[{"when":")","tag":["L_PARENR"]}]},"l_templatel":{"name":"l_templatel","rules":[{"when":"{{","tag":["L_TEMPLATEL"]}]},"l_templater":{"name":"l_templater","rules":[{"when":"}}","tag":["L_TEMPLATER"]}]},"l_arrow":{"name":"l_arrow","rules":[{"when":"->","tag":["L_ARROW"],"highlight":"keyword"}]},"l_dsign":{"name":"l_dsign","rules":[{"when":"$","tag":["L_DSIGN"]}]},"l_dash":{"name":"l_dash","rules":[{"when":"-","tag":["L_DASH"]}]},"comment":{"name":"comment","rules":[{"when":{"regex":"\\/\\/[^\\n]*","flags":""},"tag":["T_COMMENT"],"highlight":"comment"}]},"commentmulti":{"name":"commentmulti","rules":[{"when":{"regex":"\\/\\*.*\\*\\/","flags":""},"tag":["T_COMMENT"],"highlight":"comment"}]}}},"head":[],"body":[],"config":{},"version":"unknown"},"exportName":"GWLanguage"}
|
|
1
|
+
{"state":{"grammar":{"start":"main","config":{},"rules":{"main":[{"name":"main","symbols":[{"rule":"_"},{"rule":"section_list"},{"rule":"_"}],"postprocess":{"template":"$1"}}],"section_list":[{"name":"section_list","symbols":[{"rule":"section"}],"postprocess":{"template":"[$0]"}},{"name":"section_list","symbols":[{"rule":"section"},{"rule":"T_WS"},{"rule":"section_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"section":[{"name":"section","symbols":[{"rule":"K_CONFIG"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"L_TEMPLATEL"},{"rule":"_"},{"rule":"kv_list","alias":"list"},{"rule":"_"},{"rule":"L_TEMPLATER"}],"postprocess":{"template":"{ config: Object.assign(...$list) }"}},{"name":"section","symbols":[{"rule":"K_IMPORT"},{"rule":"_"},{"rule":"L_STAR"},{"rule":"_"},{"rule":"K_FROM"},{"rule":"__"},{"rule":"T_WORD","alias":"import"},{"rule":"_"},{"rule":"L_SCOLON"}],"postprocess":{"template":"{ import: $import }"}},{"name":"section","symbols":[{"rule":"K_IMPORT"},{"rule":"_"},{"rule":"L_STAR"},{"rule":"_"},{"rule":"K_FROM"},{"rule":"__"},{"rule":"T_STRING","alias":"import"},{"rule":"_"},{"rule":"L_SCOLON"}],"postprocess":{"template":"{ import: $import, path: true }"}},{"name":"section","symbols":[{"rule":"K_LEXER"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"L_TEMPLATEL"},{"rule":"_"},{"rule":"lexer","alias":"lexer"},{"rule":"_"},{"rule":"L_TEMPLATER"}],"postprocess":{"template":"{ lexer: Object.assign(...$lexer) }"}},{"name":"section","symbols":[{"rule":"K_GRAMMAR"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"L_TEMPLATEL"},{"rule":"_"},{"rule":"grammar","alias":"grammar"},{"rule":"_"},{"rule":"L_TEMPLATER"}],"postprocess":{"template":"{ grammar: $grammar }"}},{"name":"section","symbols":[{"rule":"K_BODY"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_JS","alias":"js"}],"postprocess":{"template":"{ body: $js }"}},{"name":"section","symbols":[{"rule":"K_BODY"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_STRING","alias":"js"}],"postprocess":{"template":"{ body: $js, path: true }"}},{"name":"section","symbols":[{"rule":"K_HEAD"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_JS","alias":"js"}],"postprocess":{"template":"{ head: $js }"}},{"name":"section","symbols":[{"rule":"K_HEAD"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_STRING","alias":"js"}],"postprocess":{"template":"{ head: $js, path: true }"}}],"lexer":[{"name":"lexer","symbols":[{"rule":"kv_list"},{"rule":"_"},{"rule":"state_list"}],"postprocess":{"template":"$0.concat({ states: $2 })"}},{"name":"lexer","symbols":[{"rule":"state_list"}],"postprocess":{"template":"[{ states: $0 }]"}}],"state_list":[{"name":"state_list","symbols":[{"rule":"state"}],"postprocess":{"template":"data"}},{"name":"state_list","symbols":[{"rule":"state"},{"rule":"_"},{"rule":"state_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"state":[{"name":"state","symbols":[{"rule":"state_declare"},{"rule":"_"},{"rule":"state_definition"}],"postprocess":{"template":"Object.assign({ name: $0 }, $2)"}}],"state_declare":[{"name":"state_declare","symbols":[{"rule":"T_WORD"},{"rule":"_"},{"rule":"L_ARROW"}],"postprocess":{"template":"$0"}}],"state_definition":[{"name":"state_definition","symbols":[{"rule":"kv_list"},{"rule":"_"},{"rule":"token_list"}],"postprocess":{"template":"Object.assign(...$0, { rules: $2 })"}},{"name":"state_definition","symbols":[{"rule":"token_list"}],"postprocess":{"template":"{ rules: $0 }"}}],"token_list":[{"name":"token_list","symbols":[{"rule":"token"}],"postprocess":{"template":"data"}},{"name":"token_list","symbols":[{"rule":"token"},{"rule":"_"},{"rule":"token_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"token":[{"name":"token","symbols":[{"rule":"L_DASH"},{"rule":"_"},{"rule":"K_IMPORT"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"word_list"}],"postprocess":{"template":"{ import: $6 }"}},{"name":"token","symbols":[{"rule":"L_DASH"},{"rule":"_"},{"rule":"token_definition_list"}],"postprocess":{"template":"Object.assign(...$2)"}}],"token_definition_list":[{"name":"token_definition_list","symbols":[{"rule":"token_definition"}],"postprocess":{"template":"data"}},{"name":"token_definition_list","symbols":[{"rule":"token_definition"},{"rule":"_"},{"rule":"token_definition_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"token_definition":[{"name":"token_definition","symbols":[{"rule":"K_TAG"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"string_list"}],"postprocess":{"template":"{ tag: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_WHEN"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_STRING"}],"postprocess":{"template":"{ when: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_WHEN"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_REGEX"}],"postprocess":{"template":"{ when: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_POP"}],"postprocess":{"template":"{ pop: 1 }"}},{"name":"token_definition","symbols":[{"rule":"K_POP"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_INTEGER"}],"postprocess":{"template":"{ pop: parseInt($4) }"}},{"name":"token_definition","symbols":[{"rule":"K_POP"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"K_ALL"}],"postprocess":{"template":"{ pop: \"all\" }"}},{"name":"token_definition","symbols":[{"rule":"K_HIGHLIGHT"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_STRING"}],"postprocess":{"template":"{ highlight: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_INSET"}],"postprocess":{"template":"{ inset: 1 }"}},{"name":"token_definition","symbols":[{"rule":"K_INSET"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_INTEGER"}],"postprocess":{"template":"{ inset: parseInt($4) }"}},{"name":"token_definition","symbols":[{"rule":"K_SET"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_WORD"}],"postprocess":{"template":"{ set: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_GOTO"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_WORD"}],"postprocess":{"template":"{ goto: $4 }"}},{"name":"token_definition","symbols":[{"rule":"K_TYPE"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_STRING"}],"postprocess":{"template":"{ type: $4 }"}}],"grammar":[{"name":"grammar","symbols":[{"rule":"kv_list"},{"rule":"_"},{"rule":"grammar_rule_list"}],"postprocess":{"template":"{ config: Object.assign(...$0), rules: $2 }"}},{"name":"grammar","symbols":[{"rule":"grammar_rule_list"}],"postprocess":{"template":"{ rules: $0 }"}}],"grammar_rule_list":[{"name":"grammar_rule_list","symbols":[{"rule":"grammar_rule"}],"postprocess":{"template":"[$0]"}},{"name":"grammar_rule_list","symbols":[{"rule":"grammar_rule"},{"rule":"_"},{"rule":"grammar_rule_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"grammar_rule":[{"name":"grammar_rule","symbols":[{"rule":"T_WORD"},{"rule":"_"},{"rule":"L_ARROW"},{"rule":"_"},{"rule":"expression_list"}],"postprocess":{"template":"{ name: $0, expressions: $4 }"}},{"name":"grammar_rule","symbols":[{"rule":"T_WORD"},{"rule":"__"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_JS","alias":"js"},{"rule":"_"},{"rule":"L_ARROW"},{"rule":"_"},{"rule":"expression_list","alias":"expressions"}],"postprocess":{"template":"{ name: $0, expressions: $expressions, postprocess: $js }"}},{"name":"grammar_rule","symbols":[{"rule":"T_WORD"},{"rule":"__"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_GRAMMAR_TEMPLATE","alias":"template"},{"rule":"_"},{"rule":"L_ARROW"},{"rule":"_"},{"rule":"expression_list","alias":"expressions"}],"postprocess":{"template":"{ name: $0, expressions: $expressions, postprocess: $template }"}}],"expression_list":[{"name":"expression_list","symbols":[{"rule":"expression"}]},{"name":"expression_list","symbols":[{"rule":"expression_list"},{"rule":"_"},{"rule":"L_PIPE"},{"rule":"_"},{"rule":"expression"}],"postprocess":{"template":"$0.concat([$4])"}}],"expression":[{"name":"expression","symbols":[{"rule":"expression_symbol_list"}],"postprocess":{"template":"{ symbols: $0 }"}},{"name":"expression","symbols":[{"rule":"expression_symbol_list"},{"rule":"__"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_JS","alias":"js"}],"postprocess":{"template":"{ symbols: $0, postprocess: $js }"}},{"name":"expression","symbols":[{"rule":"expression_symbol_list"},{"rule":"__"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"T_GRAMMAR_TEMPLATE","alias":"template"}],"postprocess":{"template":"{ symbols: $0, postprocess: $template }"}}],"expression_symbol_list":[{"name":"expression_symbol_list","symbols":[{"rule":"expression_symbol"}]},{"name":"expression_symbol_list","symbols":[{"rule":"expression_symbol_list"},{"rule":"T_WS"},{"rule":"expression_symbol"}],"postprocess":{"template":"$0.concat([$2])"}}],"expression_symbol":[{"name":"expression_symbol","symbols":[{"rule":"expression_symbol_match"}],"postprocess":{"template":"$0"}},{"name":"expression_symbol","symbols":[{"rule":"expression_symbol_match"},{"rule":"L_COLON"},{"rule":"T_WORD"}],"postprocess":{"template":"{ ...$0, alias: $2 }"}},{"name":"expression_symbol","symbols":[{"rule":"expression_symbol_match"},{"rule":"expression_repeater"}],"postprocess":{"template":"{ expression: $0, repeat: $1 }"}},{"name":"expression_symbol","symbols":[{"rule":"expression_symbol_match"},{"rule":"expression_repeater"},{"rule":"L_COLON"},{"rule":"T_WORD"}],"postprocess":{"template":"{ expression: $0, repeat: $1, alias: $4 }"}}],"expression_symbol_match":[{"name":"expression_symbol_match","symbols":[{"rule":"T_WORD"}],"postprocess":{"template":"{ rule: $0 }"}},{"name":"expression_symbol_match","symbols":[{"rule":"T_STRING"},{"rule":"expression_symbol_match$RPT01x1"}],"postprocess":{"template":"{ literal: $0, insensitive: !!$1 }"}},{"name":"expression_symbol_match","symbols":[{"rule":"L_DSIGN"},{"rule":"T_WORD"}],"postprocess":{"template":"{ token: $1}"}},{"name":"expression_symbol_match","symbols":[{"rule":"L_DSIGN"},{"rule":"T_STRING"}],"postprocess":{"template":"{ token: $1}"}},{"name":"expression_symbol_match","symbols":[{"rule":"T_REGEX"}],"postprocess":{"template":"$0"}},{"name":"expression_symbol_match","symbols":[{"rule":"L_PARENL"},{"rule":"_"},{"rule":"expression_list"},{"rule":"_"},{"rule":"L_PARENR"}],"postprocess":{"template":"{ subexpression: $2 }"}},{"name":"expression_symbol_match","symbols":[{"rule":"T_JS"}],"postprocess":{"template":"$0"}}],"expression_symbol_match$RPT01x1":[{"name":"expression_symbol_match$RPT01x1","symbols":[{"literal":"i","insensitive":false}],"postprocess":{"builtin":"first"}},{"name":"expression_symbol_match$RPT01x1","symbols":[],"postprocess":{"builtin":"null"}}],"expression_repeater":[{"name":"expression_repeater","symbols":[{"rule":"L_QMARK"}],"postprocess":{"template":"$0[0].value"}},{"name":"expression_repeater","symbols":[{"rule":"L_PLUS"}],"postprocess":{"template":"$0[0].value"}},{"name":"expression_repeater","symbols":[{"rule":"L_STAR"}],"postprocess":{"template":"$0[0].value"}}],"kv_list":[{"name":"kv_list","symbols":[{"rule":"kv"}],"postprocess":{"template":"data"}},{"name":"kv_list","symbols":[{"rule":"kv"},{"rule":"_"},{"rule":"kv_list"}],"postprocess":{"template":"[$0].concat($2)"}}],"kv$SUBx1":[{"name":"kv$SUBx1","symbols":[{"rule":"T_WORD"}]},{"name":"kv$SUBx1","symbols":[{"rule":"T_STRING"}]},{"name":"kv$SUBx1","symbols":[{"rule":"T_INTEGER"}]},{"name":"kv$SUBx1","symbols":[{"rule":"T_JS"}]},{"name":"kv$SUBx1","symbols":[{"rule":"T_GRAMMAR_TEMPLATE"}]}],"kv":[{"name":"kv","symbols":[{"rule":"T_WORD"},{"rule":"_"},{"rule":"L_COLON"},{"rule":"_"},{"rule":"kv$SUBx1"}],"postprocess":{"template":"{ [$0]: $4[0] }"}}],"string_list":[{"name":"string_list","symbols":[{"rule":"T_STRING"}],"postprocess":{"template":"[$0]"}},{"name":"string_list","symbols":[{"rule":"T_STRING"},{"rule":"_"},{"rule":"L_COMMA"},{"rule":"_"},{"rule":"string_list"}],"postprocess":{"template":"[$0].concat($4)"}}],"word_list":[{"name":"word_list","symbols":[{"rule":"T_WORD"}],"postprocess":{"template":"[$0]"}},{"name":"word_list","symbols":[{"rule":"T_WORD"},{"rule":"_"},{"rule":"L_COMMA"},{"rule":"_"},{"rule":"word_list"}],"postprocess":{"template":"[$0].concat($4)"}}],"_$RPT0Nx1":[{"name":"_$RPT0Nx1","symbols":[]},{"name":"_$RPT0Nx1","symbols":[{"rule":"_$RPT0Nx1"},{"rule":"_$RPT0Nx1$SUBx1"}],"postprocess":{"builtin":"concat"}}],"_$RPT0Nx1$SUBx1":[{"name":"_$RPT0Nx1$SUBx1","symbols":[{"rule":"T_WS"}]},{"name":"_$RPT0Nx1$SUBx1","symbols":[{"rule":"T_COMMENT"}]}],"_":[{"name":"_","symbols":[{"rule":"_$RPT0Nx1"}],"postprocess":{"template":"null"}}],"__$RPT1Nx1$SUBx1":[{"name":"__$RPT1Nx1$SUBx1","symbols":[{"rule":"T_WS"}]},{"name":"__$RPT1Nx1$SUBx1","symbols":[{"rule":"T_COMMENT"}]}],"__$RPT1Nx1":[{"name":"__$RPT1Nx1","symbols":[{"rule":"__$RPT1Nx1$SUBx1"}]},{"name":"__$RPT1Nx1","symbols":[{"rule":"__$RPT1Nx1"},{"rule":"__$RPT1Nx1$SUBx2"}],"postprocess":{"builtin":"concat"}}],"__$RPT1Nx1$SUBx2":[{"name":"__$RPT1Nx1$SUBx2","symbols":[{"rule":"T_WS"}]},{"name":"__$RPT1Nx1$SUBx2","symbols":[{"rule":"T_COMMENT"}]}],"__":[{"name":"__","symbols":[{"rule":"__$RPT1Nx1"}],"postprocess":{"template":"null"}}],"L_COLON":[{"name":"L_COLON","symbols":[{"token":"L_COLON"}]}],"L_SCOLON":[{"name":"L_SCOLON","symbols":[{"token":"L_SCOLON"}]}],"L_QMARK":[{"name":"L_QMARK","symbols":[{"token":"L_QMARK"}]}],"L_PLUS":[{"name":"L_PLUS","symbols":[{"token":"L_PLUS"}]}],"L_STAR":[{"name":"L_STAR","symbols":[{"token":"L_STAR"}]}],"L_COMMA":[{"name":"L_COMMA","symbols":[{"token":"L_COMMA"}]}],"L_PIPE":[{"name":"L_PIPE","symbols":[{"token":"L_PIPE"}]}],"L_PARENL":[{"name":"L_PARENL","symbols":[{"token":"L_PARENL"}]}],"L_PARENR":[{"name":"L_PARENR","symbols":[{"token":"L_PARENR"}]}],"L_TEMPLATEL":[{"name":"L_TEMPLATEL","symbols":[{"token":"L_TEMPLATEL"}]}],"L_TEMPLATER":[{"name":"L_TEMPLATER","symbols":[{"token":"L_TEMPLATER"}]}],"L_ARROW":[{"name":"L_ARROW","symbols":[{"token":"L_ARROW"}]}],"L_DSIGN":[{"name":"L_DSIGN","symbols":[{"token":"L_DSIGN"}]}],"L_DASH":[{"name":"L_DASH","symbols":[{"token":"L_DASH"}]}],"K_ALL":[{"name":"K_ALL","symbols":[{"literal":"all","insensitive":false}]}],"K_TAG":[{"name":"K_TAG","symbols":[{"literal":"tag","insensitive":false}]}],"K_FROM":[{"name":"K_FROM","symbols":[{"literal":"from","insensitive":false}]}],"K_TYPE":[{"name":"K_TYPE","symbols":[{"literal":"type","insensitive":false}]}],"K_WHEN":[{"name":"K_WHEN","symbols":[{"literal":"when","insensitive":false}]}],"K_POP":[{"name":"K_POP","symbols":[{"literal":"pop","insensitive":false}]}],"K_HIGHLIGHT":[{"name":"K_HIGHLIGHT","symbols":[{"literal":"highlight","insensitive":false}]}],"K_INSET":[{"name":"K_INSET","symbols":[{"literal":"inset","insensitive":false}]}],"K_SET":[{"name":"K_SET","symbols":[{"literal":"set","insensitive":false}]}],"K_GOTO":[{"name":"K_GOTO","symbols":[{"literal":"goto","insensitive":false}]}],"K_CONFIG":[{"name":"K_CONFIG","symbols":[{"literal":"config","insensitive":false}]}],"K_LEXER":[{"name":"K_LEXER","symbols":[{"literal":"lexer","insensitive":false}]}],"K_GRAMMAR":[{"name":"K_GRAMMAR","symbols":[{"literal":"grammar","insensitive":false}]}],"K_IMPORT":[{"name":"K_IMPORT","symbols":[{"literal":"import","insensitive":false}]}],"K_BODY":[{"name":"K_BODY","symbols":[{"literal":"body","insensitive":false}]}],"K_HEAD":[{"name":"K_HEAD","symbols":[{"literal":"head","insensitive":false}]}],"T_JS$RPT0Nx1":[{"name":"T_JS$RPT0Nx1","symbols":[]},{"name":"T_JS$RPT0Nx1","symbols":[{"rule":"T_JS$RPT0Nx1"},{"token":"T_JSBODY"}],"postprocess":{"builtin":"concat"}}],"T_JS":[{"name":"T_JS","symbols":[{"token":"L_JSL"},{"rule":"T_JS$RPT0Nx1"},{"token":"L_JSR"}],"postprocess":{"template":"{ js: $1.map(v=>v.value).join('') }"}}],"T_GRAMMAR_TEMPLATE$RPT0Nx1":[{"name":"T_GRAMMAR_TEMPLATE$RPT0Nx1","symbols":[]},{"name":"T_GRAMMAR_TEMPLATE$RPT0Nx1","symbols":[{"rule":"T_GRAMMAR_TEMPLATE$RPT0Nx1"},{"token":"T_JSBODY"}],"postprocess":{"builtin":"concat"}}],"T_GRAMMAR_TEMPLATE":[{"name":"T_GRAMMAR_TEMPLATE","symbols":[{"token":"L_TEMPLATEL"},{"rule":"_"},{"rule":"T_GRAMMAR_TEMPLATE$RPT0Nx1"},{"rule":"_"},{"token":"L_TEMPLATER"}],"postprocess":{"template":"{ template: $2.map(v=>v.value).join('').trim() }"}}],"T_STRING":[{"name":"T_STRING","symbols":[{"token":"T_STRING"}],"postprocess":{"template":"JSON.parse($0.value)"}}],"T_WORD":[{"name":"T_WORD","symbols":[{"token":"T_WORD"}],"postprocess":{"template":"$0.value"}}],"T_REGEX$RPT0Nx1":[{"name":"T_REGEX$RPT0Nx1","symbols":[]},{"name":"T_REGEX$RPT0Nx1","symbols":[{"rule":"T_REGEX$RPT0Nx1"},{"regex":"[gmiuy]","flags":""}],"postprocess":{"builtin":"concat"}}],"T_REGEX":[{"name":"T_REGEX","symbols":[{"token":"T_REGEX"},{"rule":"T_REGEX$RPT0Nx1"}],"postprocess":{"template":"{ regex: $0.value.replace(/\\\\\\\\\\//g,'/').slice(1,-1), flags: $1.map(v=>v.value).join('').trim() }"}}],"T_COMMENT":[{"name":"T_COMMENT","symbols":[{"token":"T_COMMENT"}]}],"T_INTEGER":[{"name":"T_INTEGER","symbols":[{"token":"T_INTEGER"}],"postprocess":{"template":"$0.value"}}],"T_WS":[{"name":"T_WS","symbols":[{"token":"T_WS"}],"postprocess":{"template":"null"}}]},"uuids":{"expression_symbol_match$RPT01":1,"kv$SUB":1,"_$RPT0N":1,"_$RPT0Nx1$SUB":1,"__$RPT1N":1,"__$RPT1Nx1$SUB":2,"T_JS$RPT0N":1,"T_GRAMMAR_TEMPLATE$RPT0N":1,"T_REGEX$RPT0N":1}},"lexer":{"start":"start","states":{"start":{"name":"start","rules":[{"import":["string","js","ws","comment","l_scolon","l_star"]},{"when":{"regex":"lexer(?![a-zA-Z\\d_])","flags":""},"tag":["T_WORD"],"goto":"lexer","highlight":"type"},{"when":{"regex":"grammar(?![a-zA-Z\\d_])","flags":""},"tag":["T_WORD"],"goto":"grammar","highlight":"type"},{"when":{"regex":"config(?![a-zA-Z\\d_])","flags":""},"tag":["T_WORD"],"goto":"config","highlight":"type"},{"import":["kv"]}]},"config":{"name":"config","rules":[{"import":["ws","l_colon"]},{"when":"{{","tag":["L_TEMPLATEL"],"set":"config_inner"}]},"config_inner":{"name":"config_inner","rules":[{"import":["comment","kv"]},{"when":"}}","tag":["L_TEMPLATER"],"pop":1}]},"grammar":{"name":"grammar","rules":[{"import":["ws","l_colon"]},{"when":"{{","tag":["L_TEMPLATEL"],"set":"grammar_inner"}]},"grammar_inner":{"name":"grammar_inner","rules":[{"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"]},{"when":"}}","tag":["L_TEMPLATER"],"pop":1}]},"lexer":{"name":"lexer","rules":[{"import":["ws","l_colon"]},{"when":"{{","tag":["L_TEMPLATEL"],"set":"lexer_inner"}]},"lexer_inner":{"name":"lexer_inner","rules":[{"import":["ws","comment","regex","l_comma","l_arrow","l_dash","kv","js"]},{"when":"}}","tag":["L_TEMPLATER"],"pop":1}]},"js":{"name":"js","rules":[{"when":"${","tag":["L_JSL"],"goto":"js_wrap"}]},"js_wrap":{"name":"js_wrap","rules":[{"import":["jsignore"]},{"when":"{","tag":["T_JSBODY"],"goto":"js_literal"},{"when":"}","tag":["L_JSR"],"pop":1}],"default":"T_JSBODY","unmatched":"T_JSBODY"},"js_literal":{"name":"js_literal","rules":[{"import":["jsignore"]},{"when":"{","tag":["T_JSBODY"],"goto":"js_literal"},{"when":"}","tag":["T_JSBODY"],"pop":1}],"default":"T_JSBODY","unmatched":"T_JSBODY"},"js_template":{"name":"js_template","rules":[{"when":"{{","tag":["L_TEMPLATEL"],"goto":"js_template_inner"}]},"js_template_inner":{"name":"js_template_inner","rules":[{"import":["jsignore"]},{"when":"{","tag":["T_JSBODY"],"goto":"js_literal"},{"when":"}}","tag":["L_TEMPLATER"],"pop":1}],"default":"T_JSBODY","unmatched":"T_JSBODY"},"kv":{"name":"kv","rules":[{"import":["string","ws","word","l_colon","integer"]}]},"jsignore":{"name":"jsignore","rules":[{"when":{"regex":"\"(?:[^\"\\\\\\r\\n]|\\\\.)*\"","flags":""},"tag":["T_JSBODY"]},{"when":{"regex":"'(?:[^'\\\\\\r\\n]|\\\\.)*'","flags":""},"tag":["T_JSBODY"]},{"when":{"regex":"`(?:[^`\\\\]|\\\\.)*`","flags":""},"tag":["T_JSBODY"]},{"when":{"regex":"\\/(?:[^\\/\\\\\\r\\n]|\\\\.)+\\/[gmiyu]*","flags":""},"tag":["T_JSBODY"]},{"when":{"regex":"\\/\\/[^\\n]*","flags":""},"tag":["T_JSBODY"]},{"when":{"regex":"\\/\\*.*\\*\\/","flags":""},"tag":["T_JSBODY"]}]},"string":{"name":"string","rules":[{"when":{"regex":"\"(?:[^\"\\\\\\r\\n]|\\\\.)*\"","flags":""},"tag":["T_STRING"],"highlight":"string"}]},"string2":{"name":"string2","rules":[{"when":{"regex":"'(?:[^'\\\\\\r\\n]|\\\\.)*'","flags":""},"tag":["T_STRING"],"highlight":"string"}]},"string3":{"name":"string3","rules":[{"when":{"regex":"`(?:[^`\\\\]|\\\\.)*`","flags":""},"tag":["T_STRING"],"highlight":"string"}]},"regex":{"name":"regex","rules":[{"when":{"regex":"\\/(?:[^\\/\\\\\\r\\n]|\\\\.)+\\/","flags":""},"tag":["T_REGEX"],"highlight":"regexp"}]},"integer":{"name":"integer","rules":[{"when":{"regex":"\\d+","flags":""},"tag":["T_INTEGER"],"highlight":"number"}]},"word":{"name":"word","rules":[{"when":{"regex":"[a-zA-Z_][a-zA-Z_\\d]*","flags":""},"tag":["T_WORD"]}]},"ws":{"name":"ws","rules":[{"when":{"regex":"\\s+","flags":""},"tag":["T_WS"]}]},"l_colon":{"name":"l_colon","rules":[{"when":":","tag":["L_COLON"],"highlight":"keyword"}]},"l_scolon":{"name":"l_scolon","rules":[{"when":";","tag":["L_SCOLON"]}]},"l_qmark":{"name":"l_qmark","rules":[{"when":"?","tag":["L_QMARK"]}]},"l_plus":{"name":"l_plus","rules":[{"when":"+","tag":["L_PLUS"]}]},"l_star":{"name":"l_star","rules":[{"when":"*","tag":["L_STAR"]}]},"l_comma":{"name":"l_comma","rules":[{"when":",","tag":["L_COMMA"]}]},"l_pipe":{"name":"l_pipe","rules":[{"when":"|","tag":["L_PIPE"],"highlight":"keyword"}]},"l_parenl":{"name":"l_parenl","rules":[{"when":"(","tag":["L_PARENL"]}]},"l_parenr":{"name":"l_parenr","rules":[{"when":")","tag":["L_PARENR"]}]},"l_templatel":{"name":"l_templatel","rules":[{"when":"{{","tag":["L_TEMPLATEL"]}]},"l_templater":{"name":"l_templater","rules":[{"when":"}}","tag":["L_TEMPLATER"]}]},"l_arrow":{"name":"l_arrow","rules":[{"when":"->","tag":["L_ARROW"],"highlight":"keyword"}]},"l_dsign":{"name":"l_dsign","rules":[{"when":"$","tag":["L_DSIGN"]}]},"l_dash":{"name":"l_dash","rules":[{"when":"-","tag":["L_DASH"]}]},"comment":{"name":"comment","rules":[{"when":{"regex":"\\/\\/[^\\n]*","flags":""},"tag":["T_COMMENT"],"highlight":"comment"}]},"commentmulti":{"name":"commentmulti","rules":[{"when":{"regex":"\\/\\*.*\\*\\/","flags":""},"tag":["T_COMMENT"],"highlight":"comment"}]}}},"head":[],"body":[],"config":{},"version":"unknown"},"exportName":"GWLanguage"}
|