@bablr/language-en-spamex 0.10.0 → 0.11.1
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/lib/grammar.js +122 -104
- package/package.json +13 -16
- package/lib/grammar.macro.js +0 -193
package/lib/grammar.js
CHANGED
|
@@ -1,152 +1,170 @@
|
|
|
1
|
-
/* @macrome
|
|
2
|
-
* @generatedby @bablr/macrome-generator-bablr
|
|
3
|
-
* @generatedfrom ./grammar.macro.js#a1e4c7ce2291d9dedc71da4cea2bc1891dbd39ae
|
|
4
|
-
* This file is autogenerated. Please do not edit it directly.
|
|
5
|
-
* When editing run `npx macrome watch` then change the file this is generated from.
|
|
6
|
-
*/
|
|
7
|
-
import _applyDecs from "@babel/runtime/helpers/applyDecs2305";
|
|
8
|
-
let _initProto, _MatcherDecs, _GapNodeMatcherDecs, _ArrayNodeMatcherDecs, _NullNodeMatcherDecs, _PropertyMatcherDecs, _BasicNodeMatcherDecs, _CloseNodeMatcherDecs, _StringMatcherDecs, _StringDecs, _RegexDecs, _ListDecs, _PunctuatorDecs, _AnyDecs;
|
|
9
1
|
import { re, spam as m } from '@bablr/boot';
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import * as JSON from '@bablr/language-en-cstml-json';
|
|
16
|
-
import * as Space from '@bablr/language-en-blank-space';
|
|
2
|
+
import { o, eat, eatMatch, fail, match, defineAttribute } from '@bablr/helpers/grammar';
|
|
3
|
+
import Regex from '@bablr/language-en-regex-vm-pattern';
|
|
4
|
+
import { default as CSTML, eatMatchTrivia } from '@bablr/language-en-cstml';
|
|
5
|
+
import JSON from '@bablr/language-en-cstml-json';
|
|
6
|
+
import Space from '@bablr/language-en-blank-space';
|
|
17
7
|
import { buildString } from '@bablr/helpers/builders';
|
|
8
|
+
import { printSource } from '@bablr/agast-helpers/tree';
|
|
9
|
+
|
|
18
10
|
export const canonicalURL = 'https://bablr.org/languages/core/en/spamex';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
JSON,
|
|
23
|
-
Space
|
|
24
|
-
};
|
|
11
|
+
|
|
12
|
+
export const dependencies = { Regex, CSTML, JSON, Space };
|
|
13
|
+
|
|
25
14
|
export const defaultMatcher = m`<_Matcher />`;
|
|
26
|
-
|
|
27
|
-
eatMatchTrivia
|
|
28
|
-
} = CSTML;
|
|
15
|
+
|
|
29
16
|
export const grammar = class SpamexGrammar {
|
|
30
|
-
static {
|
|
31
|
-
[_initProto] = _applyDecs(this, [[_MatcherDecs, 2, "Matcher"], [_GapNodeMatcherDecs, 2, "GapNodeMatcher"], [_ArrayNodeMatcherDecs, 2, "ArrayNodeMatcher"], [_NullNodeMatcherDecs, 2, "NullNodeMatcher"], [_PropertyMatcherDecs, 2, "PropertyMatcher"], [Node, 2, "ReferenceMatcher"], [Node, 2, "BindingMatcher"], [_BasicNodeMatcherDecs, 2, "BasicNodeMatcher"], [Node, 2, "OpenNodeMatcher"], [_CloseNodeMatcherDecs, 2, "CloseNodeMatcher"], [_StringMatcherDecs, 2, "StringMatcher"], [_StringDecs, 2, "String"], [_RegexDecs, 2, "Regex"], [_ListDecs, 2, "List"], [_PunctuatorDecs, 2, "Punctuator"], [_AnyDecs, 2, "Any"]], []).e;
|
|
32
|
-
}
|
|
33
17
|
constructor() {
|
|
34
|
-
|
|
18
|
+
this.attributes = new Map(
|
|
19
|
+
Object.entries({
|
|
20
|
+
TreeNodeMatcherOpen: { selfClosing: undefined },
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
*Matcher() {
|
|
26
|
+
yield eat(m`<BoundNodeMatcher />`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
*BoundNodeMatcher() {
|
|
30
|
+
while (yield eatMatch(m`bindingMatchers[]: <BindingMatcher ':' />`));
|
|
31
|
+
|
|
32
|
+
yield eat(m`nodeMatcher: <_NodeMatcher />`);
|
|
35
33
|
}
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
|
|
35
|
+
*PropertyMatcher() {
|
|
36
|
+
yield eatMatch(m`refMatcher$: <ReferenceMatcher />`);
|
|
37
|
+
yield* eatMatchTrivia();
|
|
38
|
+
yield eat(m`valueMatcher$: <BoundNodeMatcher />`);
|
|
38
39
|
}
|
|
40
|
+
|
|
39
41
|
*NodeMatcher() {
|
|
40
|
-
|
|
42
|
+
let chrs = yield match(re`/:|\<\/\/?\>|\<|null|['"/]/`);
|
|
43
|
+
switch (printSource(chrs)) {
|
|
44
|
+
case '<//>':
|
|
45
|
+
yield eat(m`<GapNodeMatcher />`);
|
|
46
|
+
break;
|
|
47
|
+
case '</>':
|
|
48
|
+
yield fail();
|
|
49
|
+
break;
|
|
50
|
+
case '<':
|
|
51
|
+
case '"':
|
|
52
|
+
case "'":
|
|
53
|
+
case '/':
|
|
54
|
+
yield eat(m`<TreeNodeMatcher />`);
|
|
55
|
+
break;
|
|
56
|
+
case 'null':
|
|
57
|
+
yield eat(m`<NullNodeMatcher />`);
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
yield eat(m`<TreeNodeMatcher />`);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
41
63
|
}
|
|
64
|
+
|
|
42
65
|
*GapNodeMatcher() {
|
|
43
|
-
yield eat(m`sigilToken
|
|
44
|
-
}
|
|
45
|
-
*ArrayNodeMatcher() {
|
|
46
|
-
yield eat(m`sigilToken: <*Punctuator '[]' />`);
|
|
66
|
+
yield eat(m`sigilToken*: <* '<//>' />`);
|
|
47
67
|
}
|
|
68
|
+
|
|
48
69
|
*NullNodeMatcher() {
|
|
49
|
-
yield eat(m`sigilToken
|
|
70
|
+
yield eat(m`sigilToken*: <* 'null' />`);
|
|
50
71
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
yield* eatMatchTrivia();
|
|
54
|
-
yield eatMatch(m`bindingMatcher: <BindingMatcher />`);
|
|
55
|
-
yield* eatMatchTrivia();
|
|
56
|
-
yield eat(m`nodeMatcher: <_NodeMatcher />`);
|
|
57
|
-
}
|
|
58
|
-
*ReferenceMatcher({
|
|
59
|
-
ctx
|
|
60
|
-
}) {
|
|
72
|
+
|
|
73
|
+
*ReferenceMatcher() {
|
|
61
74
|
let type;
|
|
62
|
-
if (type = yield match(re
|
|
63
|
-
yield eat(m`type
|
|
75
|
+
if ((type = yield match(re`/\.\.|[.#@]/`))) {
|
|
76
|
+
yield eat(m`type*: <* ${buildString(printSource(type))} />`);
|
|
64
77
|
}
|
|
65
|
-
|
|
78
|
+
|
|
79
|
+
if (!type || printSource(type) === '#') {
|
|
66
80
|
if (type) {
|
|
67
|
-
yield eatMatch(m`name$: :CSTML: <Identifier
|
|
68
|
-
bind: true
|
|
69
|
-
}));
|
|
81
|
+
yield eatMatch(m`name$: :CSTML: <Identifier />`);
|
|
70
82
|
} else {
|
|
71
|
-
yield eat(m`type: null`);
|
|
72
83
|
yield eat(m`name$: :CSTML: <Identifier />`);
|
|
73
84
|
}
|
|
74
85
|
} else {
|
|
75
|
-
yield eat(m`name$: null
|
|
76
|
-
bind: true
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
if (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`)) {
|
|
80
|
-
yield* eatMatchTrivia();
|
|
81
|
-
yield eatMatch(m`closeIndexToken: <*Punctuator ']' { balancer: true } />`);
|
|
82
|
-
} else {
|
|
83
|
-
yield eatMatch(m`closeIndexToken: null`);
|
|
86
|
+
yield eat(m`name$: null`);
|
|
84
87
|
}
|
|
88
|
+
|
|
85
89
|
yield* eatMatchTrivia();
|
|
86
|
-
yield eatMatch(m`flags
|
|
90
|
+
yield eatMatch(m`flags*: :CSTML: <ReferenceFlags />`);
|
|
87
91
|
yield* eatMatchTrivia();
|
|
88
|
-
yield eat(m`sigilToken
|
|
92
|
+
yield eat(m`sigilToken*: <* ':' />`);
|
|
89
93
|
}
|
|
94
|
+
|
|
90
95
|
*BindingMatcher() {
|
|
91
|
-
yield eat(m`
|
|
96
|
+
yield eat(m`bindingMatcher*: :CSTML: <BindingTag />`);
|
|
92
97
|
yield* eatMatchTrivia();
|
|
93
|
-
yield eat(m`
|
|
94
|
-
yield* eatMatchTrivia();
|
|
95
|
-
yield eat(m`sigilToken: <*Punctuator ':' />`);
|
|
98
|
+
yield eat(m`valueMatcher+$: <_ />`);
|
|
96
99
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
|
|
101
|
+
*TreeNodeMatcher() {
|
|
102
|
+
if (yield eatMatch(m`children[]*: <PropertyMatcher /[a-zA-Z.#@\g]/ />`)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let open = yield eat(m`open*: <TreeNodeMatcherOpen />`);
|
|
107
|
+
|
|
108
|
+
const { selfClosing } = open.node.value.attributes;
|
|
109
|
+
|
|
100
110
|
if (selfClosing) {
|
|
101
|
-
yield eat(m`
|
|
102
|
-
yield eat(m`close: null`);
|
|
111
|
+
yield eat(m`close*: null`);
|
|
103
112
|
} else {
|
|
104
113
|
// TODO
|
|
105
114
|
yield* eatMatchTrivia();
|
|
106
|
-
|
|
115
|
+
|
|
116
|
+
yield eat(m`close*: <TreeNodeMatcherClose />`);
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
|
|
120
|
+
*TreeNodeMatcherOpen() {
|
|
121
|
+
if (yield match(re`/['"/]/`)) {
|
|
122
|
+
yield eat(m`flags*: :CSTML: <NodeFlags />`, o({ token: true }));
|
|
123
|
+
yield eat(m`literalValue*: <_StringMatcher />`);
|
|
124
|
+
|
|
125
|
+
yield defineAttribute('selfClosing', true);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
yield eat(m`openToken*: <* '<' />`);
|
|
130
|
+
yield eat(m`flags*: :CSTML: <NodeFlags />`);
|
|
131
|
+
let type = yield eatMatch(m`type*: <* /__?/ />`);
|
|
132
|
+
|
|
133
|
+
let isMultiFragment = type && printSource(type.node) === '__';
|
|
134
|
+
|
|
135
|
+
if (yield eatMatch(m`name$: :CSTML: <Identifier /[a-zA-Z\u{80}-\u{10ffff}\u0060\g]/ />`)) {
|
|
113
136
|
// continue
|
|
114
|
-
} else if (!flags.get('fragmentToken')) {
|
|
115
|
-
if (yield eatMatch(m`type$: <*Punctuator '?' />`)) {
|
|
116
|
-
// continue
|
|
117
|
-
} else {
|
|
118
|
-
yield fail();
|
|
119
|
-
}
|
|
120
137
|
}
|
|
138
|
+
|
|
121
139
|
let sp = yield* eatMatchTrivia();
|
|
140
|
+
|
|
122
141
|
if (sp && !(yield match(re`/\/$/`)) && (yield eatMatch(m`literalValue$: <_StringMatcher />`))) {
|
|
123
142
|
sp = yield* eatMatchTrivia();
|
|
124
143
|
}
|
|
144
|
+
|
|
125
145
|
while (sp && (yield match('{'))) {
|
|
126
|
-
yield eat(m`attributes
|
|
146
|
+
yield eat(m`attributes$: :JSON: <Object />`);
|
|
127
147
|
sp = yield* eatMatchTrivia();
|
|
128
148
|
}
|
|
129
|
-
|
|
130
|
-
yield
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
yield eat(m`
|
|
134
|
-
|
|
135
|
-
|
|
149
|
+
|
|
150
|
+
let sc = yield eatMatch(m`selfClosingToken*: <* '/' />`);
|
|
151
|
+
|
|
152
|
+
yield defineAttribute('selfClosing', !!sc);
|
|
153
|
+
yield eat(m`closeToken*: <* '>' />`);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
*TreeNodeMatcherClose() {
|
|
157
|
+
yield eat(m`openToken*: <* '</' />`);
|
|
158
|
+
yield eat(m`closeToken*: <* '>' />`);
|
|
159
|
+
}
|
|
160
|
+
|
|
136
161
|
*StringMatcher() {
|
|
137
162
|
if (yield match(re`/['"]/`)) {
|
|
138
|
-
yield eat(m
|
|
163
|
+
yield eat(m`:JSON: <String />`);
|
|
139
164
|
} else {
|
|
140
|
-
yield eat(m
|
|
165
|
+
yield eat(m`:Regex: <Pattern />`);
|
|
141
166
|
}
|
|
142
167
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
*Regex() {
|
|
147
|
-
yield eat(m`:Regex: <__Pattern />`);
|
|
148
|
-
}
|
|
149
|
-
List() {}
|
|
150
|
-
Punctuator() {}
|
|
151
|
-
Any() {}
|
|
152
|
-
};
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export default { canonicalURL, dependencies, grammar, defaultMatcher };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bablr/language-en-spamex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "A BABLR language for SPAM Expressions",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=12.0.0"
|
|
@@ -15,26 +15,20 @@
|
|
|
15
15
|
],
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "macrome build",
|
|
19
|
-
"watch": "macrome watch",
|
|
20
|
-
"clean": "macrome clean",
|
|
21
18
|
"test": "mocha"
|
|
22
19
|
},
|
|
23
20
|
"dependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@bablr/agast-helpers": "0.
|
|
26
|
-
"@bablr/
|
|
27
|
-
"@bablr/
|
|
28
|
-
"@bablr/
|
|
29
|
-
"@bablr/language-en-
|
|
30
|
-
"@bablr/language-en-cstml": "0.
|
|
31
|
-
"@bablr/language-en-
|
|
32
|
-
"@bablr/language-en-regex-vm-pattern": "0.11.0"
|
|
21
|
+
"@bablr/agast-helpers": "0.10.0",
|
|
22
|
+
"@bablr/agast-vm-helpers": "0.10.0",
|
|
23
|
+
"@bablr/boot": "0.11.0",
|
|
24
|
+
"@bablr/helpers": "0.25.0",
|
|
25
|
+
"@bablr/language-en-blank-space": "0.10.0",
|
|
26
|
+
"@bablr/language-en-cstml": "0.12.0",
|
|
27
|
+
"@bablr/language-en-cstml-json": "0.5.0",
|
|
28
|
+
"@bablr/language-en-regex-vm-pattern": "0.12.1"
|
|
33
29
|
},
|
|
34
30
|
"devDependencies": {
|
|
35
31
|
"@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#c97bfa4b3663f8378e9b3e42bb5a41e685406cf9",
|
|
36
|
-
"@bablr/macrome": "^0.1.3",
|
|
37
|
-
"@bablr/macrome-generator-bablr": "^0.3.2",
|
|
38
32
|
"enhanced-resolve": "^5.12.0",
|
|
39
33
|
"eslint": "^7.32.0",
|
|
40
34
|
"eslint-import-resolver-enhanced-resolve": "^1.0.5",
|
|
@@ -49,7 +43,10 @@
|
|
|
49
43
|
"english",
|
|
50
44
|
"spamex"
|
|
51
45
|
],
|
|
52
|
-
"repository":
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+ssh://git@github.com/bablr-lang/language-en-spamex.git"
|
|
49
|
+
},
|
|
53
50
|
"homepage": "https://github.com/bablr-lang/language-en-spamex",
|
|
54
51
|
"author": "Conrad Buck <conartist6@gmail.com>",
|
|
55
52
|
"license": "MIT"
|
package/lib/grammar.macro.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { re, spam as m } from '@bablr/boot';
|
|
2
|
-
import { Node, CoveredBy, InjectFrom, Literal } from '@bablr/helpers/decorators';
|
|
3
|
-
import * as productions from '@bablr/helpers/productions';
|
|
4
|
-
import { o, eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
|
|
5
|
-
import * as Regex from '@bablr/language-en-regex-vm-pattern';
|
|
6
|
-
import * as CSTML from '@bablr/language-en-cstml';
|
|
7
|
-
import * as JSON from '@bablr/language-en-cstml-json';
|
|
8
|
-
import * as Space from '@bablr/language-en-blank-space';
|
|
9
|
-
import { buildString } from '@bablr/helpers/builders';
|
|
10
|
-
|
|
11
|
-
export const canonicalURL = 'https://bablr.org/languages/core/en/spamex';
|
|
12
|
-
|
|
13
|
-
export const dependencies = { Regex, CSTML, JSON, Space };
|
|
14
|
-
|
|
15
|
-
export const defaultMatcher = m`<_Matcher />`;
|
|
16
|
-
|
|
17
|
-
const { eatMatchTrivia } = CSTML;
|
|
18
|
-
|
|
19
|
-
export const grammar = class SpamexGrammar {
|
|
20
|
-
@CoveredBy('Expression')
|
|
21
|
-
*Matcher() {
|
|
22
|
-
yield eat(m`<__Any />`, [m`<PropertyMatcher /[a-zA-Z.@#<]/ />`, m`<_StringMatcher /[/'"]/ />`]);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
*NodeMatcher() {
|
|
26
|
-
yield eat(m`<__Any />`, [
|
|
27
|
-
m`<GapNodeMatcher '<//>' />`,
|
|
28
|
-
m`<BasicNodeMatcher '<' />`,
|
|
29
|
-
m`<ArrayNodeMatcher '[' />`,
|
|
30
|
-
m`<NullNodeMatcher 'null' />`,
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@Node
|
|
35
|
-
@CoveredBy('NodeMatcher')
|
|
36
|
-
*GapNodeMatcher() {
|
|
37
|
-
yield eat(m`sigilToken: <*Punctuator '<//>' />`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@Node
|
|
41
|
-
@CoveredBy('NodeMatcher')
|
|
42
|
-
*ArrayNodeMatcher() {
|
|
43
|
-
yield eat(m`sigilToken: <*Punctuator '[]' />`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@Node
|
|
47
|
-
@CoveredBy('NodeMatcher')
|
|
48
|
-
*NullNodeMatcher() {
|
|
49
|
-
yield eat(m`sigilToken: <*Punctuator 'null' />`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@Node
|
|
53
|
-
@CoveredBy('Matcher')
|
|
54
|
-
*PropertyMatcher() {
|
|
55
|
-
yield eatMatch(m`refMatcher: <ReferenceMatcher />`);
|
|
56
|
-
yield* eatMatchTrivia();
|
|
57
|
-
yield eatMatch(m`bindingMatcher: <BindingMatcher />`);
|
|
58
|
-
yield* eatMatchTrivia();
|
|
59
|
-
yield eat(m`nodeMatcher: <_NodeMatcher />`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@Node
|
|
63
|
-
*ReferenceMatcher({ ctx }) {
|
|
64
|
-
let type;
|
|
65
|
-
if ((type = yield match(re`/[.#@]/`))) {
|
|
66
|
-
yield eat(m`type: <*Punctuator ${buildString(ctx.sourceTextFor(type))} />`);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!type || ctx.sourceTextFor(type) === '#') {
|
|
70
|
-
if (type) {
|
|
71
|
-
yield eatMatch(m`name$: :CSTML: <Identifier />`, o({}), o({ bind: true }));
|
|
72
|
-
} else {
|
|
73
|
-
yield eat(m`type: null`);
|
|
74
|
-
yield eat(m`name$: :CSTML: <Identifier />`);
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
yield eat(m`name$: null`, o({}), o({ bind: true }));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`)) {
|
|
81
|
-
yield* eatMatchTrivia();
|
|
82
|
-
yield eatMatch(m`closeIndexToken: <*Punctuator ']' { balancer: true } />`);
|
|
83
|
-
} else {
|
|
84
|
-
yield eatMatch(m`closeIndexToken: null`);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
yield* eatMatchTrivia();
|
|
88
|
-
yield eatMatch(m`flags: :CSTML: <ReferenceFlags />`);
|
|
89
|
-
yield* eatMatchTrivia();
|
|
90
|
-
yield eat(m`sigilToken: <*Punctuator ':' />`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
@Node
|
|
94
|
-
*BindingMatcher() {
|
|
95
|
-
yield eat(m`sigilToken: <*Punctuator ':' />`);
|
|
96
|
-
yield* eatMatchTrivia();
|
|
97
|
-
yield eat(m`languagePath: :CSTML: <IdentifierPath />`);
|
|
98
|
-
yield* eatMatchTrivia();
|
|
99
|
-
yield eat(m`sigilToken: <*Punctuator ':' />`);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
@Node
|
|
103
|
-
@CoveredBy('NodeMatcher')
|
|
104
|
-
*BasicNodeMatcher() {
|
|
105
|
-
let open = yield eat(m`open: <OpenNodeMatcher />`);
|
|
106
|
-
|
|
107
|
-
const selfClosing = open.get('selfClosingToken');
|
|
108
|
-
|
|
109
|
-
if (selfClosing) {
|
|
110
|
-
yield eat(m`children[]$: []`);
|
|
111
|
-
yield eat(m`close: null`);
|
|
112
|
-
} else {
|
|
113
|
-
// TODO
|
|
114
|
-
yield* eatMatchTrivia();
|
|
115
|
-
|
|
116
|
-
yield eat(m`close: <CloseNodeMatcher />`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
@Node
|
|
121
|
-
*OpenNodeMatcher() {
|
|
122
|
-
yield eat(m`openToken: <*Punctuator '<' { balancedSpan: 'Tag', balanced: '>' } />`);
|
|
123
|
-
let flags = yield eat(m`flags: :CSTML: <NodeFlags />`);
|
|
124
|
-
|
|
125
|
-
if (yield eatMatch(m`type$: :CSTML: <Identifier /[a-zA-Z\u{80}-\u{10ffff}\u0060\g]/ />`)) {
|
|
126
|
-
// continue
|
|
127
|
-
} else if (!flags.get('fragmentToken')) {
|
|
128
|
-
if (yield eatMatch(m`type$: <*Punctuator '?' />`)) {
|
|
129
|
-
// continue
|
|
130
|
-
} else {
|
|
131
|
-
yield fail();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
let sp = yield* eatMatchTrivia();
|
|
136
|
-
|
|
137
|
-
if (sp && !(yield match(re`/\/$/`)) && (yield eatMatch(m`literalValue$: <_StringMatcher />`))) {
|
|
138
|
-
sp = yield* eatMatchTrivia();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
while (sp && (yield match('{'))) {
|
|
142
|
-
yield eat(m`attributes: :JSON: <Object />`);
|
|
143
|
-
sp = yield* eatMatchTrivia();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
yield eatMatch(m`selfClosingToken: <*Punctuator '/' />`);
|
|
147
|
-
yield eat(m`closeToken: <*Punctuator '>' { balancer: true } />`);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
@Node
|
|
151
|
-
@CoveredBy('Matcher')
|
|
152
|
-
*CloseNodeMatcher() {
|
|
153
|
-
yield eat(m`openToken: <*Punctuator '</' { balanced: '>' } />`);
|
|
154
|
-
yield eat(m`closeToken: <*Punctuator '>' { balancer: true } />`);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
@CoveredBy('Matcher')
|
|
158
|
-
@CoveredBy('Expression')
|
|
159
|
-
*StringMatcher() {
|
|
160
|
-
if (yield match(re`/['"]/`)) {
|
|
161
|
-
yield eat(m`<String />`);
|
|
162
|
-
} else {
|
|
163
|
-
yield eat(m`<Regex />`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
@CoveredBy('StringMatcher')
|
|
168
|
-
@CoveredBy('Matcher')
|
|
169
|
-
@CoveredBy('Expression')
|
|
170
|
-
@Node
|
|
171
|
-
*String() {
|
|
172
|
-
yield eat(m`:JSON: <__String />`);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
@CoveredBy('StringMatcher')
|
|
176
|
-
@CoveredBy('Matcher')
|
|
177
|
-
@CoveredBy('Expression')
|
|
178
|
-
@Node
|
|
179
|
-
*Regex() {
|
|
180
|
-
yield eat(m`:Regex: <__Pattern />`);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
@InjectFrom(productions)
|
|
184
|
-
List() {}
|
|
185
|
-
|
|
186
|
-
@Literal
|
|
187
|
-
@Node
|
|
188
|
-
@InjectFrom(productions)
|
|
189
|
-
Punctuator() {}
|
|
190
|
-
|
|
191
|
-
@InjectFrom(productions)
|
|
192
|
-
Any() {}
|
|
193
|
-
};
|