@bablr/language-en-spamex 0.9.0 → 0.10.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/lib/grammar.js +32 -17
- package/lib/grammar.macro.js +26 -19
- package/package.json +10 -10
package/lib/grammar.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @macrome
|
|
2
2
|
* @generatedby @bablr/macrome-generator-bablr
|
|
3
|
-
* @generatedfrom ./grammar.macro.js#
|
|
3
|
+
* @generatedfrom ./grammar.macro.js#a1e4c7ce2291d9dedc71da4cea2bc1891dbd39ae
|
|
4
4
|
* This file is autogenerated. Please do not edit it directly.
|
|
5
5
|
* When editing run `npx macrome watch` then change the file this is generated from.
|
|
6
6
|
*/
|
|
@@ -9,11 +9,12 @@ let _initProto, _MatcherDecs, _GapNodeMatcherDecs, _ArrayNodeMatcherDecs, _NullN
|
|
|
9
9
|
import { re, spam as m } from '@bablr/boot';
|
|
10
10
|
import { Node, CoveredBy, InjectFrom, Literal } from '@bablr/helpers/decorators';
|
|
11
11
|
import * as productions from '@bablr/helpers/productions';
|
|
12
|
-
import { eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
|
|
12
|
+
import { o, eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
|
|
13
13
|
import * as Regex from '@bablr/language-en-regex-vm-pattern';
|
|
14
14
|
import * as CSTML from '@bablr/language-en-cstml';
|
|
15
15
|
import * as JSON from '@bablr/language-en-cstml-json';
|
|
16
16
|
import * as Space from '@bablr/language-en-blank-space';
|
|
17
|
+
import { buildString } from '@bablr/helpers/builders';
|
|
17
18
|
export const canonicalURL = 'https://bablr.org/languages/core/en/spamex';
|
|
18
19
|
export const dependencies = {
|
|
19
20
|
Regex,
|
|
@@ -21,6 +22,7 @@ export const dependencies = {
|
|
|
21
22
|
JSON,
|
|
22
23
|
Space
|
|
23
24
|
};
|
|
25
|
+
export const defaultMatcher = m`<_Matcher />`;
|
|
24
26
|
const {
|
|
25
27
|
eatMatchTrivia
|
|
26
28
|
} = CSTML;
|
|
@@ -32,10 +34,10 @@ export const grammar = class SpamexGrammar {
|
|
|
32
34
|
_initProto(this);
|
|
33
35
|
}
|
|
34
36
|
*[(_MatcherDecs = CoveredBy('Expression'), _GapNodeMatcherDecs = [Node, CoveredBy('NodeMatcher')], _ArrayNodeMatcherDecs = [Node, CoveredBy('NodeMatcher')], _NullNodeMatcherDecs = [Node, CoveredBy('NodeMatcher')], _PropertyMatcherDecs = [Node, CoveredBy('Matcher')], _BasicNodeMatcherDecs = [Node, CoveredBy('NodeMatcher')], _CloseNodeMatcherDecs = [Node, CoveredBy('Matcher')], _StringMatcherDecs = [CoveredBy('Matcher'), CoveredBy('Expression')], _StringDecs = [CoveredBy('StringMatcher'), CoveredBy('Matcher'), CoveredBy('Expression'), Node], _RegexDecs = [CoveredBy('StringMatcher'), CoveredBy('Matcher'), CoveredBy('Expression'), Node], _ListDecs = InjectFrom(productions), _PunctuatorDecs = [Literal, Node, InjectFrom(productions)], _AnyDecs = InjectFrom(productions), "Matcher")]() {
|
|
35
|
-
yield eat(m`<
|
|
37
|
+
yield eat(m`<__Any />`, [m`<PropertyMatcher /[a-zA-Z.@#<]/ />`, m`<_StringMatcher /[/'"]/ />`]);
|
|
36
38
|
}
|
|
37
39
|
*NodeMatcher() {
|
|
38
|
-
yield eat(m`<
|
|
40
|
+
yield eat(m`<__Any />`, [m`<GapNodeMatcher '<//>' />`, m`<BasicNodeMatcher '<' />`, m`<ArrayNodeMatcher '[' />`, m`<NullNodeMatcher 'null' />`]);
|
|
39
41
|
}
|
|
40
42
|
*GapNodeMatcher() {
|
|
41
43
|
yield eat(m`sigilToken: <*Punctuator '<//>' />`);
|
|
@@ -51,15 +53,28 @@ export const grammar = class SpamexGrammar {
|
|
|
51
53
|
yield* eatMatchTrivia();
|
|
52
54
|
yield eatMatch(m`bindingMatcher: <BindingMatcher />`);
|
|
53
55
|
yield* eatMatchTrivia();
|
|
54
|
-
yield eat(m`nodeMatcher: <
|
|
55
|
-
}
|
|
56
|
-
*ReferenceMatcher(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
yield eat(m`nodeMatcher: <_NodeMatcher />`);
|
|
57
|
+
}
|
|
58
|
+
*ReferenceMatcher({
|
|
59
|
+
ctx
|
|
60
|
+
}) {
|
|
61
|
+
let type;
|
|
62
|
+
if (type = yield match(re`/[.#@]/`)) {
|
|
63
|
+
yield eat(m`type: <*Punctuator ${buildString(ctx.sourceTextFor(type))} />`);
|
|
64
|
+
}
|
|
65
|
+
if (!type || ctx.sourceTextFor(type) === '#') {
|
|
66
|
+
if (type) {
|
|
67
|
+
yield eatMatch(m`name$: :CSTML: <Identifier />`, o({}), o({
|
|
68
|
+
bind: true
|
|
69
|
+
}));
|
|
70
|
+
} else {
|
|
71
|
+
yield eat(m`type: null`);
|
|
72
|
+
yield eat(m`name$: :CSTML: <Identifier />`);
|
|
73
|
+
}
|
|
60
74
|
} else {
|
|
61
|
-
yield eat(m`
|
|
62
|
-
|
|
75
|
+
yield eat(m`name$: null`, o({}), o({
|
|
76
|
+
bind: true
|
|
77
|
+
}));
|
|
63
78
|
}
|
|
64
79
|
if (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`)) {
|
|
65
80
|
yield* eatMatchTrivia();
|
|
@@ -81,7 +96,7 @@ export const grammar = class SpamexGrammar {
|
|
|
81
96
|
}
|
|
82
97
|
*BasicNodeMatcher() {
|
|
83
98
|
let open = yield eat(m`open: <OpenNodeMatcher />`);
|
|
84
|
-
const selfClosing = open.get('
|
|
99
|
+
const selfClosing = open.get('selfClosingToken');
|
|
85
100
|
if (selfClosing) {
|
|
86
101
|
yield eat(m`children[]$: []`);
|
|
87
102
|
yield eat(m`close: null`);
|
|
@@ -104,14 +119,14 @@ export const grammar = class SpamexGrammar {
|
|
|
104
119
|
}
|
|
105
120
|
}
|
|
106
121
|
let sp = yield* eatMatchTrivia();
|
|
107
|
-
if (sp && !(yield match(re`/\/$/`)) && (yield eatMatch(m`
|
|
122
|
+
if (sp && !(yield match(re`/\/$/`)) && (yield eatMatch(m`literalValue$: <_StringMatcher />`))) {
|
|
108
123
|
sp = yield* eatMatchTrivia();
|
|
109
124
|
}
|
|
110
125
|
while (sp && (yield match('{'))) {
|
|
111
126
|
yield eat(m`attributes: :JSON: <Object />`);
|
|
112
127
|
sp = yield* eatMatchTrivia();
|
|
113
128
|
}
|
|
114
|
-
yield eatMatch(m`
|
|
129
|
+
yield eatMatch(m`selfClosingToken: <*Punctuator '/' />`);
|
|
115
130
|
yield eat(m`closeToken: <*Punctuator '>' { balancer: true } />`);
|
|
116
131
|
}
|
|
117
132
|
*CloseNodeMatcher() {
|
|
@@ -126,10 +141,10 @@ export const grammar = class SpamexGrammar {
|
|
|
126
141
|
}
|
|
127
142
|
}
|
|
128
143
|
*String() {
|
|
129
|
-
yield eat(m`:JSON: <
|
|
144
|
+
yield eat(m`:JSON: <__String />`);
|
|
130
145
|
}
|
|
131
146
|
*Regex() {
|
|
132
|
-
yield eat(m`:Regex: <
|
|
147
|
+
yield eat(m`:Regex: <__Pattern />`);
|
|
133
148
|
}
|
|
134
149
|
List() {}
|
|
135
150
|
Punctuator() {}
|
package/lib/grammar.macro.js
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import { re, spam as m } from '@bablr/boot';
|
|
2
2
|
import { Node, CoveredBy, InjectFrom, Literal } from '@bablr/helpers/decorators';
|
|
3
3
|
import * as productions from '@bablr/helpers/productions';
|
|
4
|
-
import { eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
|
|
4
|
+
import { o, eat, eatMatch, match, fail } from '@bablr/helpers/grammar';
|
|
5
5
|
import * as Regex from '@bablr/language-en-regex-vm-pattern';
|
|
6
6
|
import * as CSTML from '@bablr/language-en-cstml';
|
|
7
7
|
import * as JSON from '@bablr/language-en-cstml-json';
|
|
8
8
|
import * as Space from '@bablr/language-en-blank-space';
|
|
9
|
+
import { buildString } from '@bablr/helpers/builders';
|
|
9
10
|
|
|
10
11
|
export const canonicalURL = 'https://bablr.org/languages/core/en/spamex';
|
|
11
12
|
|
|
12
13
|
export const dependencies = { Regex, CSTML, JSON, Space };
|
|
13
14
|
|
|
15
|
+
export const defaultMatcher = m`<_Matcher />`;
|
|
16
|
+
|
|
14
17
|
const { eatMatchTrivia } = CSTML;
|
|
15
18
|
|
|
16
19
|
export const grammar = class SpamexGrammar {
|
|
17
20
|
@CoveredBy('Expression')
|
|
18
21
|
*Matcher() {
|
|
19
|
-
yield eat(m`<
|
|
22
|
+
yield eat(m`<__Any />`, [m`<PropertyMatcher /[a-zA-Z.@#<]/ />`, m`<_StringMatcher /[/'"]/ />`]);
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
*NodeMatcher() {
|
|
23
|
-
yield eat(m`<
|
|
26
|
+
yield eat(m`<__Any />`, [
|
|
24
27
|
m`<GapNodeMatcher '<//>' />`,
|
|
25
28
|
m`<BasicNodeMatcher '<' />`,
|
|
26
29
|
m`<ArrayNodeMatcher '[' />`,
|
|
@@ -53,17 +56,25 @@ export const grammar = class SpamexGrammar {
|
|
|
53
56
|
yield* eatMatchTrivia();
|
|
54
57
|
yield eatMatch(m`bindingMatcher: <BindingMatcher />`);
|
|
55
58
|
yield* eatMatchTrivia();
|
|
56
|
-
yield eat(m`nodeMatcher: <
|
|
59
|
+
yield eat(m`nodeMatcher: <_NodeMatcher />`);
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
@Node
|
|
60
|
-
*ReferenceMatcher() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
yield eat(m`
|
|
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
|
+
}
|
|
64
76
|
} else {
|
|
65
|
-
yield eat(m`
|
|
66
|
-
yield eat(m`name$: :CSTML: <Identifier />`);
|
|
77
|
+
yield eat(m`name$: null`, o({}), o({ bind: true }));
|
|
67
78
|
}
|
|
68
79
|
|
|
69
80
|
if (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`)) {
|
|
@@ -93,7 +104,7 @@ export const grammar = class SpamexGrammar {
|
|
|
93
104
|
*BasicNodeMatcher() {
|
|
94
105
|
let open = yield eat(m`open: <OpenNodeMatcher />`);
|
|
95
106
|
|
|
96
|
-
const selfClosing = open.get('
|
|
107
|
+
const selfClosing = open.get('selfClosingToken');
|
|
97
108
|
|
|
98
109
|
if (selfClosing) {
|
|
99
110
|
yield eat(m`children[]$: []`);
|
|
@@ -123,11 +134,7 @@ export const grammar = class SpamexGrammar {
|
|
|
123
134
|
|
|
124
135
|
let sp = yield* eatMatchTrivia();
|
|
125
136
|
|
|
126
|
-
if (
|
|
127
|
-
sp &&
|
|
128
|
-
!(yield match(re`/\/$/`)) &&
|
|
129
|
-
(yield eatMatch(m`intrinsicValue$: <__StringMatcher />`))
|
|
130
|
-
) {
|
|
137
|
+
if (sp && !(yield match(re`/\/$/`)) && (yield eatMatch(m`literalValue$: <_StringMatcher />`))) {
|
|
131
138
|
sp = yield* eatMatchTrivia();
|
|
132
139
|
}
|
|
133
140
|
|
|
@@ -136,7 +143,7 @@ export const grammar = class SpamexGrammar {
|
|
|
136
143
|
sp = yield* eatMatchTrivia();
|
|
137
144
|
}
|
|
138
145
|
|
|
139
|
-
yield eatMatch(m`
|
|
146
|
+
yield eatMatch(m`selfClosingToken: <*Punctuator '/' />`);
|
|
140
147
|
yield eat(m`closeToken: <*Punctuator '>' { balancer: true } />`);
|
|
141
148
|
}
|
|
142
149
|
|
|
@@ -162,7 +169,7 @@ export const grammar = class SpamexGrammar {
|
|
|
162
169
|
@CoveredBy('Expression')
|
|
163
170
|
@Node
|
|
164
171
|
*String() {
|
|
165
|
-
yield eat(m`:JSON: <
|
|
172
|
+
yield eat(m`:JSON: <__String />`);
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
@CoveredBy('StringMatcher')
|
|
@@ -170,7 +177,7 @@ export const grammar = class SpamexGrammar {
|
|
|
170
177
|
@CoveredBy('Expression')
|
|
171
178
|
@Node
|
|
172
179
|
*Regex() {
|
|
173
|
-
yield eat(m`:Regex: <
|
|
180
|
+
yield eat(m`:Regex: <__Pattern />`);
|
|
174
181
|
}
|
|
175
182
|
|
|
176
183
|
@InjectFrom(productions)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bablr/language-en-spamex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "A BABLR language for SPAM Expressions",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=12.0.0"
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"test": "mocha"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@babel/runtime": "
|
|
25
|
-
"@bablr/agast-helpers": "0.
|
|
26
|
-
"@bablr/agast-vm-helpers": "0.
|
|
27
|
-
"@bablr/boot": "0.
|
|
28
|
-
"@bablr/helpers": "0.
|
|
29
|
-
"@bablr/language-en-blank-space": "0.
|
|
30
|
-
"@bablr/language-en-cstml": "0.
|
|
31
|
-
"@bablr/language-en-cstml-json": "0.
|
|
32
|
-
"@bablr/language-en-regex-vm-pattern": "0.
|
|
24
|
+
"@babel/runtime": "7.28.2",
|
|
25
|
+
"@bablr/agast-helpers": "0.9.0",
|
|
26
|
+
"@bablr/agast-vm-helpers": "0.9.0",
|
|
27
|
+
"@bablr/boot": "0.10.0",
|
|
28
|
+
"@bablr/helpers": "0.24.0",
|
|
29
|
+
"@bablr/language-en-blank-space": "0.9.0",
|
|
30
|
+
"@bablr/language-en-cstml": "0.11.0",
|
|
31
|
+
"@bablr/language-en-cstml-json": "0.4.0",
|
|
32
|
+
"@bablr/language-en-regex-vm-pattern": "0.11.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#c97bfa4b3663f8378e9b3e42bb5a41e685406cf9",
|