@bablr/language-en-spamex 0.5.0 → 0.6.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 +501 -647
- package/lib/grammar.macro.js +34 -39
- package/package.json +10 -10
package/lib/grammar.macro.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i } from '@bablr/boot/shorthand.macro';
|
|
2
|
-
import { Node, CoveredBy, InjectFrom } from '@bablr/helpers/decorators';
|
|
2
|
+
import { Node, CoveredBy, InjectFrom, UnboundAttributes } from '@bablr/helpers/decorators';
|
|
3
3
|
import * as productions from '@bablr/helpers/productions';
|
|
4
4
|
import * as Regex from '@bablr/language-en-regex-vm-pattern';
|
|
5
5
|
import * as CSTML from '@bablr/language-en-cstml';
|
|
@@ -13,11 +13,6 @@ export const dependencies = { Regex, CSTML, Space };
|
|
|
13
13
|
const { eatMatchTrivia } = CSTML;
|
|
14
14
|
|
|
15
15
|
export const grammar = class SpamexGrammar {
|
|
16
|
-
@Node
|
|
17
|
-
*Pattern() {
|
|
18
|
-
yield i`eat(<Matcher /> 'matcher')`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
16
|
@CoveredBy('Expression')
|
|
22
17
|
*Matcher() {
|
|
23
18
|
yield i`eat(<Any /> null [
|
|
@@ -32,14 +27,10 @@ export const grammar = class SpamexGrammar {
|
|
|
32
27
|
*NodeMatcher() {
|
|
33
28
|
let open = yield i`eat(<OpenNodeMatcher /> 'open')`;
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
// gaps have a non-nullish representation
|
|
37
|
-
//
|
|
38
|
-
const { selfClosingTagToken } = open.properties;
|
|
39
|
-
const selfClosing = notNull(selfClosingTagToken);
|
|
30
|
+
const selfClosing = notNull(open.get('selfClosingTagToken'));
|
|
40
31
|
|
|
41
32
|
if (selfClosing) {
|
|
42
|
-
yield i`eat([] 'children[]')`;
|
|
33
|
+
yield i`eat([] 'children[]$')`;
|
|
43
34
|
yield i`eat(null 'close')`;
|
|
44
35
|
} else {
|
|
45
36
|
// TODO
|
|
@@ -51,24 +42,22 @@ export const grammar = class SpamexGrammar {
|
|
|
51
42
|
|
|
52
43
|
@Node
|
|
53
44
|
*OpenNodeMatcher() {
|
|
54
|
-
yield i`eat(
|
|
45
|
+
yield i`eat(<*Punctuator '<' balancedSpan='Tag' balanced='>' /> 'open')`;
|
|
55
46
|
yield i`eat(<CSTML:Flags /> 'flags')`;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
yield i`eat(null 'language')`;
|
|
62
|
-
yield i`eat(null 'namespaceOperator')`;
|
|
63
|
-
yield i`eatMatch(<*CSTML:Identifier /> 'type')`;
|
|
64
|
-
} else if (yield i`match('?')`) {
|
|
65
|
-
yield i`eat(<~*Punctuator '?' /> 'type')`;
|
|
66
|
-
} else if (yield i`match(/[ \t]/)`) {
|
|
67
|
-
yield i`eatMatch(<~*Punctuator /[ \t]+/ /> 'type')`;
|
|
47
|
+
|
|
48
|
+
if (yield i`eatMatch(<CSTML:TagType /[a-zA-Z'"\g]/ />)`) {
|
|
49
|
+
// continue
|
|
50
|
+
} else if (yield i`eatMatch(<*Punctuator /[ \t]+|?/ /> 'type$')`) {
|
|
51
|
+
// continue
|
|
68
52
|
}
|
|
53
|
+
|
|
69
54
|
let sp = yield* eatMatchTrivia();
|
|
70
55
|
|
|
71
|
-
if (
|
|
56
|
+
if (
|
|
57
|
+
sp &&
|
|
58
|
+
!(yield i`match(/\/$/)`) &&
|
|
59
|
+
(yield i`eatMatch(<StringMatcher /> 'intrinsicValue$')`)
|
|
60
|
+
) {
|
|
72
61
|
sp = yield* eatMatchTrivia();
|
|
73
62
|
}
|
|
74
63
|
|
|
@@ -77,16 +66,16 @@ export const grammar = class SpamexGrammar {
|
|
|
77
66
|
sp = yield* eatMatchTrivia();
|
|
78
67
|
}
|
|
79
68
|
|
|
80
|
-
yield i`eatMatch(
|
|
81
|
-
yield i`eat(
|
|
69
|
+
yield i`eatMatch(<*Punctuator '/' /> 'selfClosingTagToken')`;
|
|
70
|
+
yield i`eat(<*Punctuator '>' balancer /> 'close')`;
|
|
82
71
|
}
|
|
83
72
|
|
|
84
73
|
@Node
|
|
85
74
|
@CoveredBy('Matcher')
|
|
86
75
|
*CloseNodeMatcher() {
|
|
87
|
-
yield i`eat(
|
|
76
|
+
yield i`eat(<*Punctuator '</' balanced='>' /> 'openToken')`;
|
|
88
77
|
yield i`eatMatch(<TagType />)`;
|
|
89
|
-
yield i`eat(
|
|
78
|
+
yield i`eat(<*Punctuator '>' balancer /> 'closeToken')`;
|
|
90
79
|
}
|
|
91
80
|
|
|
92
81
|
*Attributes() {
|
|
@@ -104,18 +93,24 @@ export const grammar = class SpamexGrammar {
|
|
|
104
93
|
}
|
|
105
94
|
}
|
|
106
95
|
|
|
107
|
-
@
|
|
96
|
+
@UnboundAttributes(['true'])
|
|
108
97
|
@Node
|
|
98
|
+
@CoveredBy('Attribute')
|
|
109
99
|
*BooleanAttribute() {
|
|
110
|
-
yield i`
|
|
100
|
+
if (yield i`eatMatch(<*Punctuator '!' /> 'negateToken')`) {
|
|
101
|
+
yield i`bindAttribute('true' false)`;
|
|
102
|
+
} else {
|
|
103
|
+
yield i`bindAttribute('true' true)`;
|
|
104
|
+
}
|
|
105
|
+
yield i`eat(<*CSTML:Identifier /> 'key$')`;
|
|
111
106
|
}
|
|
112
107
|
|
|
113
108
|
@CoveredBy('Attribute')
|
|
114
109
|
@Node
|
|
115
110
|
*MappingAttribute() {
|
|
116
|
-
yield i`eat(<*CSTML:Identifier /> 'key')`;
|
|
117
|
-
yield i`eat(
|
|
118
|
-
yield i`eat(<CSTML:AttributeValue /> 'value')`;
|
|
111
|
+
yield i`eat(<*CSTML:Identifier /> 'key$')`;
|
|
112
|
+
yield i`eat(<*Punctuator '=' /> 'mapOperator')`;
|
|
113
|
+
yield i`eat(<CSTML:AttributeValue /> 'value$')`;
|
|
119
114
|
}
|
|
120
115
|
|
|
121
116
|
@CoveredBy('Matcher')
|
|
@@ -141,10 +136,10 @@ export const grammar = class SpamexGrammar {
|
|
|
141
136
|
@CoveredBy('Expression')
|
|
142
137
|
@Node
|
|
143
138
|
*Regex() {
|
|
144
|
-
yield i`eat(
|
|
145
|
-
yield i`eat(<Regex:Alternatives /> 'alternatives[]')`;
|
|
146
|
-
yield i`eat(
|
|
147
|
-
yield i`eat(<Regex:Flags /> 'flags')`;
|
|
139
|
+
yield i`eat(<*Punctuator '/' balanced='/' /> 'open')`;
|
|
140
|
+
yield i`eat(<Regex:Alternatives /> 'alternatives[]$')`;
|
|
141
|
+
yield i`eat(<*Punctuator '/' balancer /> 'close')`;
|
|
142
|
+
yield i`eat(<Regex:Flags /> 'flags$')`;
|
|
148
143
|
}
|
|
149
144
|
|
|
150
145
|
@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.6.0",
|
|
4
4
|
"description": "A BABLR language for SPAM Expressions",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=12.0.0"
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@babel/runtime": "^7.23.2",
|
|
25
|
-
"@bablr/agast-helpers": "0.
|
|
26
|
-
"@bablr/agast-vm-helpers": "0.
|
|
27
|
-
"@bablr/helpers": "0.
|
|
28
|
-
"@bablr/language-en-blank-space": "0.
|
|
29
|
-
"@bablr/language-en-cstml": "0.
|
|
30
|
-
"@bablr/language-en-regex-vm-pattern": "0.
|
|
25
|
+
"@bablr/agast-helpers": "^0.5.0",
|
|
26
|
+
"@bablr/agast-vm-helpers": "^0.5.0",
|
|
27
|
+
"@bablr/helpers": "^0.20.0",
|
|
28
|
+
"@bablr/language-en-blank-space": "^0.5.0",
|
|
29
|
+
"@bablr/language-en-cstml": "^0.6.0",
|
|
30
|
+
"@bablr/language-en-regex-vm-pattern": "^0.7.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@bablr/boot": "0.
|
|
33
|
+
"@bablr/boot": "^0.6.0",
|
|
34
34
|
"@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#49f5952efed27f94ee9b94340eb1563c440bf64e",
|
|
35
|
-
"@bablr/macrome": "0.1.3",
|
|
36
|
-
"@bablr/macrome-generator-bablr": "0.3.2",
|
|
35
|
+
"@bablr/macrome": "^0.1.3",
|
|
36
|
+
"@bablr/macrome-generator-bablr": "^0.3.2",
|
|
37
37
|
"enhanced-resolve": "^5.12.0",
|
|
38
38
|
"eslint": "^7.32.0",
|
|
39
39
|
"eslint-import-resolver-enhanced-resolve": "^1.0.5",
|