bobe 0.0.48 → 0.0.50
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/dist/bobe.cjs.js +145 -64
- package/dist/bobe.cjs.js.map +1 -1
- package/dist/bobe.compiler.cjs.js +153 -86
- package/dist/bobe.compiler.cjs.js.map +1 -1
- package/dist/bobe.compiler.esm.js +154 -87
- package/dist/bobe.compiler.esm.js.map +1 -1
- package/dist/bobe.esm.js +146 -65
- package/dist/bobe.esm.js.map +1 -1
- package/dist/index.d.ts +40 -17
- package/dist/index.umd.js +145 -64
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
|
@@ -106,10 +106,13 @@ class Tokenizer {
|
|
|
106
106
|
this.hook = hook;
|
|
107
107
|
this.useDedentAsEof = useDedentAsEof;
|
|
108
108
|
if (useDedentAsEof) {
|
|
109
|
-
this.
|
|
110
|
-
this.isFirstToken = true;
|
|
109
|
+
this.initIndentWhenUseDedentAsEof();
|
|
111
110
|
}
|
|
112
111
|
}
|
|
112
|
+
initIndentWhenUseDedentAsEof() {
|
|
113
|
+
this.setToken(TokenType.Indent, '');
|
|
114
|
+
this.isFirstToken = true;
|
|
115
|
+
}
|
|
113
116
|
next() {
|
|
114
117
|
{
|
|
115
118
|
const char = this.code[this.i];
|
|
@@ -148,16 +151,23 @@ class Tokenizer {
|
|
|
148
151
|
throwUnclosed(code, message, startOffset, startLine, startCol) {
|
|
149
152
|
throw new ParseSyntaxError(code, message, this.unclosedLoc(startOffset, startLine, startCol));
|
|
150
153
|
}
|
|
151
|
-
resume(
|
|
154
|
+
resume({
|
|
155
|
+
dentStack,
|
|
156
|
+
waitingTokens,
|
|
157
|
+
..._snapshot
|
|
158
|
+
}) {
|
|
152
159
|
this.token = undefined;
|
|
153
160
|
this.needIndent = false;
|
|
154
161
|
this.isFirstToken = true;
|
|
155
|
-
this.dentStack = [0];
|
|
162
|
+
this.dentStack = dentStack ? dentStack.slice() : [0];
|
|
163
|
+
if (waitingTokens) {
|
|
164
|
+
this.waitingTokens = waitingTokens.clone();
|
|
165
|
+
}
|
|
156
166
|
Object.assign(this, _snapshot);
|
|
157
167
|
}
|
|
158
|
-
snapshot(keys) {
|
|
168
|
+
snapshot(keys, dtI = 0) {
|
|
159
169
|
const snap = {
|
|
160
|
-
i: this.i,
|
|
170
|
+
i: this.i + dtI,
|
|
161
171
|
waitingTokens: this.waitingTokens.clone()
|
|
162
172
|
};
|
|
163
173
|
if (keys) {
|
|
@@ -170,8 +180,10 @@ class Tokenizer {
|
|
|
170
180
|
}
|
|
171
181
|
return snap;
|
|
172
182
|
}
|
|
173
|
-
skip() {
|
|
174
|
-
|
|
183
|
+
skip(targetDentLen) {
|
|
184
|
+
if (targetDentLen == undefined) {
|
|
185
|
+
targetDentLen = this.dentStack[this.dentStack.length - 1];
|
|
186
|
+
}
|
|
175
187
|
let needIndent = false;
|
|
176
188
|
let skipFragment = ``;
|
|
177
189
|
this.token = undefined;
|
|
@@ -194,7 +206,7 @@ class Tokenizer {
|
|
|
194
206
|
isEmptyLine = _this$getDentValue.isEmptyLine;
|
|
195
207
|
const currLen = value.length;
|
|
196
208
|
if (isEmptyLine) continue;
|
|
197
|
-
if (currLen >
|
|
209
|
+
if (currLen > targetDentLen) {
|
|
198
210
|
skipFragment += value;
|
|
199
211
|
} else {
|
|
200
212
|
for (let i = this.dentStack.length - 1; i >= 0; i--) {
|
|
@@ -207,6 +219,9 @@ class Tokenizer {
|
|
|
207
219
|
break;
|
|
208
220
|
}
|
|
209
221
|
this.dentStack.pop();
|
|
222
|
+
if (expLen > targetDentLen) {
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
210
225
|
if (!this.token) {
|
|
211
226
|
this.setToken(TokenType.Dedent, String(expLen));
|
|
212
227
|
} else {
|
|
@@ -273,33 +288,31 @@ class Tokenizer {
|
|
|
273
288
|
}
|
|
274
289
|
outer: while (1) {
|
|
275
290
|
if (this.needIndent) {
|
|
291
|
+
this.locStart();
|
|
276
292
|
this.dent();
|
|
293
|
+
this.locEnd();
|
|
277
294
|
} else {
|
|
278
295
|
const char = this.code[this.i];
|
|
279
296
|
switch (char) {
|
|
280
297
|
case '\t':
|
|
281
298
|
case ' ':
|
|
282
299
|
break;
|
|
283
|
-
case '\n':
|
|
284
|
-
this.newLine();
|
|
285
|
-
this.needIndent = true;
|
|
286
|
-
break;
|
|
287
|
-
case '=':
|
|
288
|
-
this.assignment();
|
|
289
|
-
break;
|
|
290
|
-
case '|':
|
|
291
|
-
this.pipe();
|
|
292
|
-
break;
|
|
293
|
-
case ';':
|
|
294
|
-
this.setToken(TokenType.Semicolon, ';');
|
|
295
|
-
break;
|
|
296
300
|
default:
|
|
297
|
-
|
|
298
|
-
this.preI = this.i;
|
|
299
|
-
this.preCol = this.column;
|
|
300
|
-
this.needLoc = true;
|
|
301
|
-
}
|
|
301
|
+
this.locStart();
|
|
302
302
|
switch (char) {
|
|
303
|
+
case '\n':
|
|
304
|
+
this.newLine();
|
|
305
|
+
this.needIndent = true;
|
|
306
|
+
break;
|
|
307
|
+
case '=':
|
|
308
|
+
this.assignment();
|
|
309
|
+
break;
|
|
310
|
+
case '|':
|
|
311
|
+
this.pipe();
|
|
312
|
+
break;
|
|
313
|
+
case ';':
|
|
314
|
+
this.setToken(TokenType.Semicolon, ';');
|
|
315
|
+
break;
|
|
303
316
|
case '/':
|
|
304
317
|
this.comment();
|
|
305
318
|
break;
|
|
@@ -324,9 +337,7 @@ class Tokenizer {
|
|
|
324
337
|
}
|
|
325
338
|
break;
|
|
326
339
|
}
|
|
327
|
-
|
|
328
|
-
this.needLoc = false;
|
|
329
|
-
}
|
|
340
|
+
this.locEnd();
|
|
330
341
|
break;
|
|
331
342
|
}
|
|
332
343
|
this.next();
|
|
@@ -342,6 +353,18 @@ class Tokenizer {
|
|
|
342
353
|
this.handledTokens.push(this.token);
|
|
343
354
|
}
|
|
344
355
|
}
|
|
356
|
+
locStart() {
|
|
357
|
+
{
|
|
358
|
+
this.preCol = this.column;
|
|
359
|
+
this.preI = this.i;
|
|
360
|
+
this.needLoc = true;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
locEnd() {
|
|
364
|
+
{
|
|
365
|
+
this.needLoc = false;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
345
368
|
getComment() {
|
|
346
369
|
let value = '/';
|
|
347
370
|
let nextC = this.code[this.i + 1];
|
|
@@ -358,11 +381,7 @@ class Tokenizer {
|
|
|
358
381
|
this.getComment();
|
|
359
382
|
}
|
|
360
383
|
condExp() {
|
|
361
|
-
|
|
362
|
-
this.preCol = this.column;
|
|
363
|
-
this.preI = this.i;
|
|
364
|
-
this.needLoc = true;
|
|
365
|
-
}
|
|
384
|
+
this.locStart();
|
|
366
385
|
let value = '';
|
|
367
386
|
this.token = null;
|
|
368
387
|
let char = this.code[this.i];
|
|
@@ -377,20 +396,14 @@ class Tokenizer {
|
|
|
377
396
|
const trimmed = value.replace(/\/\/[\s\S]+/, '').trim();
|
|
378
397
|
this.setToken(TokenType.Identifier, trimmed ? trimmed : true, 0);
|
|
379
398
|
this.handledTokens.push(this.token);
|
|
380
|
-
|
|
381
|
-
this.needLoc = false;
|
|
382
|
-
}
|
|
399
|
+
this.locEnd();
|
|
383
400
|
return this.token;
|
|
384
401
|
}
|
|
385
402
|
isEol(i) {
|
|
386
403
|
return this.code[i] === '\n' || this.code[i] === '/';
|
|
387
404
|
}
|
|
388
405
|
jsExp() {
|
|
389
|
-
|
|
390
|
-
this.preCol = this.column;
|
|
391
|
-
this.preI = this.i;
|
|
392
|
-
this.needLoc = true;
|
|
393
|
-
}
|
|
406
|
+
this.locStart();
|
|
394
407
|
this.token = null;
|
|
395
408
|
let value = '';
|
|
396
409
|
let char = this.code[this.i];
|
|
@@ -404,9 +417,7 @@ class Tokenizer {
|
|
|
404
417
|
}
|
|
405
418
|
this.setToken(TokenType.Identifier, value, 0);
|
|
406
419
|
this.handledTokens.push(this.token);
|
|
407
|
-
|
|
408
|
-
this.needLoc = false;
|
|
409
|
-
}
|
|
420
|
+
this.locEnd();
|
|
410
421
|
return this.token;
|
|
411
422
|
}
|
|
412
423
|
peekChar() {
|
|
@@ -594,7 +605,7 @@ class Tokenizer {
|
|
|
594
605
|
const prevLen = this.dentStack[this.dentStack.length - 1];
|
|
595
606
|
if (currLen > prevLen) {
|
|
596
607
|
this.dentStack.push(currLen);
|
|
597
|
-
this.setToken(TokenType.Indent, currLen);
|
|
608
|
+
this.setToken(TokenType.Indent, currLen, 0);
|
|
598
609
|
return indentHasLen;
|
|
599
610
|
}
|
|
600
611
|
if (currLen < prevLen) {
|
|
@@ -609,7 +620,7 @@ class Tokenizer {
|
|
|
609
620
|
}
|
|
610
621
|
this.dentStack.pop();
|
|
611
622
|
if (!this.token) {
|
|
612
|
-
this.setToken(TokenType.Dedent, String(expLen));
|
|
623
|
+
this.setToken(TokenType.Dedent, String(expLen), 0);
|
|
613
624
|
} else {
|
|
614
625
|
this.waitingTokens.push({
|
|
615
626
|
type: TokenType.Dedent,
|
|
@@ -1016,7 +1027,7 @@ var NodeType = function (NodeType) {
|
|
|
1016
1027
|
let _initProto;
|
|
1017
1028
|
class Compiler {
|
|
1018
1029
|
static {
|
|
1019
|
-
var _applyDecs$e = _slicedToArray(_applyDecs2311(this, [], [[NodeHook, 2, "parseProgram"], [[NodeHook, NodeLoc], 2, "parseComponentNode"], [[NodeHook, NodeLoc], 2, "parseElementNode"], [[NodeHook, NodeLoc], 2, "parseConditionalNode"], [[NodeHook, NodeLoc], 2, "parseLoopNode"], [NodeHook, 2, "parseProperty"], [[NodeHook, TokenLoc], 2, "parsePropertyKey"], [[NodeHook, TokenLoc], 2, "parseJsExp"], [[NodeHook, TokenLoc], 2, "parsePropertyValue"], [[NodeHook, TokenLoc], 2, "parseName"]]).e, 1);
|
|
1030
|
+
var _applyDecs$e = _slicedToArray(_applyDecs2311(this, [], [[NodeHook, 2, "parseProgram"], [[NodeHook, NodeLoc], 2, "parseComponentNode"], [[NodeHook, NodeLoc], 2, "parseElementNode"], [[NodeHook, NodeLoc], 2, "parseConditionalNode"], [[NodeHook, NodeLoc], 2, "parseLoopNode"], [NodeHook, 2, "parseProperty"], [[NodeHook, TokenLoc], 2, "parsePropertyKey"], [[NodeHook, TokenLoc], 2, "parseJsExp"], [[NodeHook, TokenLoc], 2, "parsePropertyValue"], [[NodeHook, NodeLoc], 2, "parsePropertyInlineFragment"], [[NodeHook, TokenLoc], 2, "parseName"]]).e, 1);
|
|
1020
1031
|
_initProto = _applyDecs$e[0];
|
|
1021
1032
|
}
|
|
1022
1033
|
errors = (_initProto(this), []);
|
|
@@ -1118,9 +1129,9 @@ class Compiler {
|
|
|
1118
1129
|
parseComponentNode(node) {
|
|
1119
1130
|
const name = this.parseName();
|
|
1120
1131
|
this.tokenizer.nextToken();
|
|
1121
|
-
const props = this.headerLineAndExtensions();
|
|
1122
1132
|
node.type = NodeType.Component;
|
|
1123
1133
|
node.componentName = name;
|
|
1134
|
+
const props = this.headerLineAndExtensions();
|
|
1124
1135
|
node.props = props;
|
|
1125
1136
|
this.hooks.parseComponentNode?.propsAdded?.call(this, node);
|
|
1126
1137
|
const children = this.handleChildren();
|
|
@@ -1138,9 +1149,9 @@ class Compiler {
|
|
|
1138
1149
|
}
|
|
1139
1150
|
const tagName = tagToken.value;
|
|
1140
1151
|
this.tokenizer.nextToken();
|
|
1141
|
-
const props = this.headerLineAndExtensions();
|
|
1142
1152
|
node.type = NodeType.Element;
|
|
1143
1153
|
node.tagName = tagName;
|
|
1154
|
+
const props = this.headerLineAndExtensions();
|
|
1144
1155
|
node.props = props;
|
|
1145
1156
|
this.hooks.parseElementNode?.propsAdded?.call(this, node);
|
|
1146
1157
|
const children = this.handleChildren();
|
|
@@ -1214,17 +1225,17 @@ class Compiler {
|
|
|
1214
1225
|
}
|
|
1215
1226
|
headerLineAndExtensions() {
|
|
1216
1227
|
const props = [];
|
|
1217
|
-
|
|
1218
|
-
if (this.tokenizer.token.type & TokenType.NewLine) {
|
|
1219
|
-
this.tokenizer.nextToken();
|
|
1220
|
-
}
|
|
1221
|
-
while (this.tokenizer.token.type & TokenType.Pipe) {
|
|
1222
|
-
this.tokenizer.nextToken();
|
|
1228
|
+
do {
|
|
1223
1229
|
props.push(...this.attributeList());
|
|
1224
1230
|
if (this.tokenizer.token.type & TokenType.NewLine) {
|
|
1225
1231
|
this.tokenizer.nextToken();
|
|
1226
1232
|
}
|
|
1227
|
-
|
|
1233
|
+
if ((this.tokenizer.token.type & TokenType.Pipe) === 0) {
|
|
1234
|
+
break;
|
|
1235
|
+
} else {
|
|
1236
|
+
this.tokenizer.nextToken();
|
|
1237
|
+
}
|
|
1238
|
+
} while (true);
|
|
1228
1239
|
return props;
|
|
1229
1240
|
}
|
|
1230
1241
|
attributeList() {
|
|
@@ -1248,25 +1259,35 @@ class Compiler {
|
|
|
1248
1259
|
const token = this.tokenizer.nextToken();
|
|
1249
1260
|
if (token.value !== '=') {
|
|
1250
1261
|
this.addError(ParseErrorCode.MISSING_ASSIGN, `属性 "${node.key.key}" 缺少 "=" 赋值符号`, node.key.loc ?? this.tokenizer.emptyLoc(), node);
|
|
1251
|
-
|
|
1252
|
-
node.loc.end = node.key.loc.end;
|
|
1253
|
-
node.loc.source = this.tokenizer.code.slice(node.loc.start.offset, node.loc.end.offset);
|
|
1262
|
+
this.handleOnlyKeyLoc(node);
|
|
1254
1263
|
return node;
|
|
1255
1264
|
}
|
|
1256
1265
|
const valueToken = this.tokenizer.nextToken();
|
|
1266
|
+
if (valueToken.type & TokenType.NewLine) {
|
|
1267
|
+
this.tokenizer.nextToken();
|
|
1268
|
+
node.value = this.parsePropertyInlineFragment();
|
|
1269
|
+
this.handleKeyValueLoc(node);
|
|
1270
|
+
return node;
|
|
1271
|
+
}
|
|
1257
1272
|
if ((valueToken.type & ValueTokenType) === 0) {
|
|
1258
1273
|
this.addError(ParseErrorCode.MISSING_PROP_ASSIGNMENT, `属性值不合法, "${valueToken.value}" 不合法`, valueToken.loc ?? this.tokenizer.emptyLoc(), node);
|
|
1259
|
-
|
|
1260
|
-
node.loc.end = node.key.loc.end;
|
|
1261
|
-
node.loc.source = this.tokenizer.code.slice(node.loc.start.offset, node.loc.end.offset);
|
|
1274
|
+
this.handleOnlyKeyLoc(node);
|
|
1262
1275
|
return node;
|
|
1263
1276
|
}
|
|
1264
1277
|
node.value = this.parsePropertyValue();
|
|
1265
1278
|
this.tokenizer.nextToken();
|
|
1279
|
+
this.handleKeyValueLoc(node);
|
|
1280
|
+
return node;
|
|
1281
|
+
}
|
|
1282
|
+
handleOnlyKeyLoc(node) {
|
|
1283
|
+
node.loc.start = node.key.loc.start;
|
|
1284
|
+
node.loc.end = node.key.loc.end;
|
|
1285
|
+
node.loc.source = this.tokenizer.code.slice(node.loc.start.offset, node.loc.end.offset);
|
|
1286
|
+
}
|
|
1287
|
+
handleKeyValueLoc(node) {
|
|
1266
1288
|
node.loc.start = node.key.loc.start;
|
|
1267
1289
|
node.loc.end = node.value.loc.end;
|
|
1268
1290
|
node.loc.source = this.tokenizer.code.slice(node.loc.start.offset, node.loc.end.offset);
|
|
1269
|
-
return node;
|
|
1270
1291
|
}
|
|
1271
1292
|
parsePropertyKey(node) {
|
|
1272
1293
|
node.type = NodeType.PropertyKey;
|
|
@@ -1291,6 +1312,12 @@ class Compiler {
|
|
|
1291
1312
|
node.value = value;
|
|
1292
1313
|
return node;
|
|
1293
1314
|
}
|
|
1315
|
+
parsePropertyInlineFragment(node) {
|
|
1316
|
+
const list = this.handleChildren();
|
|
1317
|
+
node.type = NodeType.StaticValue;
|
|
1318
|
+
node.value = list;
|
|
1319
|
+
return node;
|
|
1320
|
+
}
|
|
1294
1321
|
parseName(node) {
|
|
1295
1322
|
const _this$tokenizer$_hook7 = this.tokenizer._hook({}),
|
|
1296
1323
|
_this$tokenizer$_hook8 = _slicedToArray(_this$tokenizer$_hook7, 2),
|
|
@@ -1514,6 +1541,9 @@ class Interpreter {
|
|
|
1514
1541
|
}
|
|
1515
1542
|
if (sort & NodeSort.TokenizerSwitcher) {
|
|
1516
1543
|
const switcher = stack.peekByType(NodeSort.TokenizerSwitcher)?.node;
|
|
1544
|
+
if (parent.resumeSnapshot) {
|
|
1545
|
+
this.tokenizer.resume(parent.resumeSnapshot);
|
|
1546
|
+
}
|
|
1517
1547
|
this.tokenizer = switcher.tokenizer;
|
|
1518
1548
|
}
|
|
1519
1549
|
if (parent.__logicType === FakeType.ForItem) {
|
|
@@ -1608,7 +1638,7 @@ class Interpreter {
|
|
|
1608
1638
|
} else {
|
|
1609
1639
|
const valueIsMapKey = Reflect.has(data[aoye.Keys.Raw], value);
|
|
1610
1640
|
const val = data[aoye.Keys.Raw][value];
|
|
1611
|
-
if (typeof val === 'function') {
|
|
1641
|
+
if (typeof val === 'function' || val instanceof InlineFragment) {
|
|
1612
1642
|
_node = this.componentOrFragmentDeclaration(val, ctx);
|
|
1613
1643
|
} else {
|
|
1614
1644
|
const str = valueIsMapKey ? value : this.getFn(data, value);
|
|
@@ -1620,11 +1650,15 @@ class Interpreter {
|
|
|
1620
1650
|
_node = this.createNode(value);
|
|
1621
1651
|
}
|
|
1622
1652
|
this.tokenizer.nextToken();
|
|
1623
|
-
this.
|
|
1624
|
-
this.extensionLines(_node);
|
|
1653
|
+
this.headerLineAndExtensions(_node);
|
|
1625
1654
|
this.onePropParsed = this.oneRealPropParsed;
|
|
1626
1655
|
if (_node.__logicType & TokenizerSwitcherBit) {
|
|
1627
1656
|
this.tokenizer = _node.tokenizer;
|
|
1657
|
+
if (_node.fragmentSnapshot) {
|
|
1658
|
+
this.tokenizer.resume(_node.fragmentSnapshot);
|
|
1659
|
+
this.tokenizer.useDedentAsEof = true;
|
|
1660
|
+
this.tokenizer.initIndentWhenUseDedentAsEof();
|
|
1661
|
+
}
|
|
1628
1662
|
}
|
|
1629
1663
|
return _node;
|
|
1630
1664
|
}
|
|
@@ -2000,16 +2034,25 @@ class Interpreter {
|
|
|
2000
2034
|
}
|
|
2001
2035
|
oneRealPropParsed = this.onePropParsed.bind(this);
|
|
2002
2036
|
componentOrFragmentDeclaration(ComponentOrRender, ctx) {
|
|
2003
|
-
let Component,
|
|
2037
|
+
let Component, tokenizer, child, fragmentSnapshot, resumeSnapshot;
|
|
2004
2038
|
const isCC = ComponentOrRender.prototype instanceof aoye.Store;
|
|
2005
2039
|
if (isCC) {
|
|
2006
2040
|
Component = ComponentOrRender;
|
|
2007
2041
|
child = Component.new();
|
|
2042
|
+
tokenizer = child.ui(true);
|
|
2043
|
+
} else if (ComponentOrRender instanceof InlineFragment) {
|
|
2044
|
+
const conf = ComponentOrRender;
|
|
2045
|
+
child = aoye.deepSignal({}, aoye.getPulling(), true);
|
|
2046
|
+
Object.setPrototypeOf(child, conf.data);
|
|
2047
|
+
tokenizer = conf.tokenizer;
|
|
2048
|
+
fragmentSnapshot = conf.snapshot;
|
|
2049
|
+
resumeSnapshot = tokenizer.snapshot(['token', 'needIndent', 'isFirstToken', 'dentStack', 'isFirstToken', 'useDedentAsEof']);
|
|
2008
2050
|
} else {
|
|
2009
|
-
render = ComponentOrRender;
|
|
2051
|
+
const render = ComponentOrRender;
|
|
2010
2052
|
const boundStore = render.boundStore;
|
|
2011
2053
|
child = aoye.deepSignal({}, aoye.getPulling(), true);
|
|
2012
2054
|
Object.setPrototypeOf(child, boundStore);
|
|
2055
|
+
tokenizer = render(true);
|
|
2013
2056
|
}
|
|
2014
2057
|
const node = {
|
|
2015
2058
|
__logicType: isCC ? FakeType.Component : FakeType.Fragment,
|
|
@@ -2017,7 +2060,9 @@ class Interpreter {
|
|
|
2017
2060
|
realBefore: null,
|
|
2018
2061
|
realAfter: null,
|
|
2019
2062
|
data: child,
|
|
2020
|
-
tokenizer
|
|
2063
|
+
tokenizer,
|
|
2064
|
+
fragmentSnapshot,
|
|
2065
|
+
resumeSnapshot
|
|
2021
2066
|
};
|
|
2022
2067
|
this.onePropParsed = createStoreOnePropParsed(child);
|
|
2023
2068
|
node.realAfter = this.insertAfterAnchor('component-after');
|
|
@@ -2154,26 +2199,38 @@ class Interpreter {
|
|
|
2154
2199
|
point = next;
|
|
2155
2200
|
}
|
|
2156
2201
|
}
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2202
|
+
headerLineAndExtensions(_node) {
|
|
2203
|
+
const tokenizer = this.tokenizer;
|
|
2204
|
+
do {
|
|
2205
|
+
const isComponent = _node.__logicType & TokenizerSwitcherBit;
|
|
2206
|
+
let snapshot, dentLen;
|
|
2207
|
+
const data = this.getData();
|
|
2208
|
+
const unHandledKey = this.attributeList(_node, data);
|
|
2209
|
+
if (isComponent) {
|
|
2210
|
+
snapshot = tokenizer.snapshot(undefined, -1);
|
|
2211
|
+
dentLen = tokenizer.dentStack[tokenizer.dentStack.length - 1];
|
|
2161
2212
|
}
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2213
|
+
tokenizer.nextToken();
|
|
2214
|
+
if ((tokenizer.token.type & TokenType.Pipe) === 0) {
|
|
2215
|
+
if (isComponent && tokenizer.token.type & TokenType.Indent) {
|
|
2216
|
+
this.inlineFragment(_node, snapshot, data, unHandledKey);
|
|
2217
|
+
tokenizer.skip(dentLen);
|
|
2218
|
+
if ((tokenizer.token.type & TokenType.Pipe) === 0) {
|
|
2219
|
+
break;
|
|
2220
|
+
}
|
|
2221
|
+
} else {
|
|
2222
|
+
break;
|
|
2223
|
+
}
|
|
2166
2224
|
}
|
|
2167
|
-
|
|
2168
|
-
}
|
|
2225
|
+
tokenizer.nextToken();
|
|
2226
|
+
} while (true);
|
|
2169
2227
|
}
|
|
2170
|
-
|
|
2171
|
-
this.
|
|
2172
|
-
this.
|
|
2228
|
+
inlineFragment(_node, snapshot, data, key = 'children') {
|
|
2229
|
+
const value = new InlineFragment(snapshot, data, key, this.tokenizer);
|
|
2230
|
+
this.onePropParsed(data, _node, key, value, false, true);
|
|
2173
2231
|
}
|
|
2174
|
-
attributeList(_node) {
|
|
2232
|
+
attributeList(_node, data) {
|
|
2175
2233
|
let key, eq;
|
|
2176
|
-
const data = this.getData();
|
|
2177
2234
|
while ((this.tokenizer.token.type & TokenType.NewLine) === 0) {
|
|
2178
2235
|
if (key == null) {
|
|
2179
2236
|
key = this.tokenizer.token.value;
|
|
@@ -2221,6 +2278,7 @@ class Interpreter {
|
|
|
2221
2278
|
}
|
|
2222
2279
|
this.tokenizer.nextToken();
|
|
2223
2280
|
}
|
|
2281
|
+
return key;
|
|
2224
2282
|
}
|
|
2225
2283
|
config(opt) {
|
|
2226
2284
|
Object.assign(this, opt);
|
|
@@ -2304,6 +2362,15 @@ function createStoreOnePropParsed(child) {
|
|
|
2304
2362
|
};
|
|
2305
2363
|
return onePropParsed;
|
|
2306
2364
|
}
|
|
2365
|
+
class InlineFragment {
|
|
2366
|
+
[aoye.Keys.ProxyFreeObject] = true;
|
|
2367
|
+
constructor(snapshot, data, key, tokenizer) {
|
|
2368
|
+
this.snapshot = snapshot;
|
|
2369
|
+
this.data = data;
|
|
2370
|
+
this.key = key;
|
|
2371
|
+
this.tokenizer = tokenizer;
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2307
2374
|
|
|
2308
2375
|
function bobe(fragments, ...values) {
|
|
2309
2376
|
const ui = function ui(isSub) {
|