@bablr/language-en-spamex 0.7.0 → 0.9.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 CHANGED
@@ -1,20 +1,19 @@
1
1
  /* @macrome
2
2
  * @generatedby @bablr/macrome-generator-bablr
3
- * @generatedfrom ./grammar.macro.js#fba5948385285e93eab4ec54f33e3401a5ef7a12
3
+ * @generatedfrom ./grammar.macro.js#d3a89c912a3321b6fe824122fc60ff07c79b0f7f
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
  */
7
7
  import _applyDecs from "@babel/runtime/helpers/applyDecs2305";
8
8
  let _initProto, _MatcherDecs, _GapNodeMatcherDecs, _ArrayNodeMatcherDecs, _NullNodeMatcherDecs, _PropertyMatcherDecs, _BasicNodeMatcherDecs, _CloseNodeMatcherDecs, _StringMatcherDecs, _StringDecs, _RegexDecs, _ListDecs, _PunctuatorDecs, _AnyDecs;
9
9
  import { re, spam as m } from '@bablr/boot';
10
- import { Node, CoveredBy, InjectFrom, UnboundAttributes } from '@bablr/helpers/decorators';
10
+ import { Node, CoveredBy, InjectFrom, Literal } from '@bablr/helpers/decorators';
11
11
  import * as productions from '@bablr/helpers/productions';
12
- import { o, eat, eatMatch, match, bindAttribute, fail } from '@bablr/helpers/grammar';
12
+ import { 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 { notNull } from '@bablr/agast-helpers/tree';
18
17
  export const canonicalURL = 'https://bablr.org/languages/core/en/spamex';
19
18
  export const dependencies = {
20
19
  Regex,
@@ -27,16 +26,16 @@ const {
27
26
  } = CSTML;
28
27
  export const grammar = class SpamexGrammar {
29
28
  static {
30
- [_initProto] = _applyDecs(this, [[_MatcherDecs, 2, "Matcher"], [_GapNodeMatcherDecs, 2, "GapNodeMatcher"], [_ArrayNodeMatcherDecs, 2, "ArrayNodeMatcher"], [_NullNodeMatcherDecs, 2, "NullNodeMatcher"], [_PropertyMatcherDecs, 2, "PropertyMatcher"], [Node, 2, "ReferenceMatcher"], [_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;
29
+ [_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;
31
30
  }
32
31
  constructor() {
33
32
  _initProto(this);
34
33
  }
35
- *[(_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 = [Node, InjectFrom(productions)], _AnyDecs = InjectFrom(productions), "Matcher")]() {
36
- yield eat(m`<Any />`, [m`<PropertyMatcher /[a-zA-Z.@#<]/ />`, m`<StringMatcher /[/'"]/ />`]);
34
+ *[(_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`<_Any />`, [m`<PropertyMatcher /[a-zA-Z.@#<]/ />`, m`<__StringMatcher /[/'"]/ />`]);
37
36
  }
38
37
  *NodeMatcher() {
39
- yield eat(m`<Any />`, [m`<GapNodeMatcher '<//>' />`, m`<BasicNodeMatcher '<' />`, m`<ArrayNodeMatcher '[' />`, m`<NullNodeMatcher 'null' />`]);
38
+ yield eat(m`<_Any />`, [m`<GapNodeMatcher '<//>' />`, m`<BasicNodeMatcher '<' />`, m`<ArrayNodeMatcher '[' />`, m`<NullNodeMatcher 'null' />`]);
40
39
  }
41
40
  *GapNodeMatcher() {
42
41
  yield eat(m`sigilToken: <*Punctuator '<//>' />`);
@@ -50,29 +49,39 @@ export const grammar = class SpamexGrammar {
50
49
  *PropertyMatcher() {
51
50
  yield eatMatch(m`refMatcher: <ReferenceMatcher />`);
52
51
  yield* eatMatchTrivia();
53
- yield eat(m`nodeMatcher: <NodeMatcher />`);
52
+ yield eatMatch(m`bindingMatcher: <BindingMatcher />`);
53
+ yield* eatMatchTrivia();
54
+ yield eat(m`nodeMatcher: <__NodeMatcher />`);
54
55
  }
55
56
  *ReferenceMatcher() {
56
- let name;
57
57
  if (yield match(re`/[.#@]/`)) {
58
- name = yield eatMatch(m`name$: <*Punctuator /[.#@]/ />`);
58
+ yield eat(m`type: <*Punctuator /[.#@]/ />`);
59
+ yield eat(m`name$: null`);
59
60
  } else {
60
- name = yield eatMatch(m`name$: <*CSTML:Identifier />`);
61
+ yield eat(m`type: null`);
62
+ yield eat(m`name$: :CSTML: <Identifier />`);
61
63
  }
62
- if (name && (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`))) {
64
+ if (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`)) {
63
65
  yield* eatMatchTrivia();
64
66
  yield eatMatch(m`closeIndexToken: <*Punctuator ']' { balancer: true } />`);
65
67
  } else {
66
68
  yield eatMatch(m`closeIndexToken: null`);
67
69
  }
68
70
  yield* eatMatchTrivia();
69
- yield eatMatch(m`flags: <CSTML:ReferenceFlags />`);
71
+ yield eatMatch(m`flags: :CSTML: <ReferenceFlags />`);
72
+ yield* eatMatchTrivia();
73
+ yield eat(m`sigilToken: <*Punctuator ':' />`);
74
+ }
75
+ *BindingMatcher() {
76
+ yield eat(m`sigilToken: <*Punctuator ':' />`);
77
+ yield* eatMatchTrivia();
78
+ yield eat(m`languagePath: :CSTML: <IdentifierPath />`);
70
79
  yield* eatMatchTrivia();
71
80
  yield eat(m`sigilToken: <*Punctuator ':' />`);
72
81
  }
73
82
  *BasicNodeMatcher() {
74
83
  let open = yield eat(m`open: <OpenNodeMatcher />`);
75
- const selfClosing = notNull(open.get('selfClosingTagToken'));
84
+ const selfClosing = open.get('selfClosingTagToken');
76
85
  if (selfClosing) {
77
86
  yield eat(m`children[]$: []`);
78
87
  yield eat(m`close: null`);
@@ -83,25 +92,27 @@ export const grammar = class SpamexGrammar {
83
92
  }
84
93
  }
85
94
  *OpenNodeMatcher() {
86
- yield eat(m`open: <*Punctuator '<' { balancedSpan: 'Tag', balanced: '>' } />`);
87
- yield eat(m`flags: <CSTML:NodeFlags />`);
88
- if (yield eatMatch(m`<CSTML:TagType /[a-zA-Z'"\g]/ />`)) {
89
- // continue
90
- } else if (yield eatMatch(m`type$: <*Punctuator /[ \t]+|?/ />`)) {
95
+ yield eat(m`openToken: <*Punctuator '<' { balancedSpan: 'Tag', balanced: '>' } />`);
96
+ let flags = yield eat(m`flags: :CSTML: <NodeFlags />`);
97
+ if (yield eatMatch(m`type$: :CSTML: <Identifier /[a-zA-Z\u{80}-\u{10ffff}\u0060\g]/ />`)) {
91
98
  // continue
92
- } else {
93
- yield fail();
99
+ } else if (!flags.get('fragmentToken')) {
100
+ if (yield eatMatch(m`type$: <*Punctuator '?' />`)) {
101
+ // continue
102
+ } else {
103
+ yield fail();
104
+ }
94
105
  }
95
106
  let sp = yield* eatMatchTrivia();
96
- if (sp && !(yield match(re`/\/$/`)) && (yield eatMatch(m`intrinsicValue$: <StringMatcher />`))) {
107
+ if (sp && !(yield match(re`/\/$/`)) && (yield eatMatch(m`intrinsicValue$: <__StringMatcher />`))) {
97
108
  sp = yield* eatMatchTrivia();
98
109
  }
99
110
  while (sp && (yield match('{'))) {
100
- yield eat(m`attributes: <JSON:Object />`);
111
+ yield eat(m`attributes: :JSON: <Object />`);
101
112
  sp = yield* eatMatchTrivia();
102
113
  }
103
114
  yield eatMatch(m`selfClosingTagToken: <*Punctuator '/' />`);
104
- yield eat(m`close: <*Punctuator '>' { balancer: true } />`);
115
+ yield eat(m`closeToken: <*Punctuator '>' { balancer: true } />`);
105
116
  }
106
117
  *CloseNodeMatcher() {
107
118
  yield eat(m`openToken: <*Punctuator '</' { balanced: '>' } />`);
@@ -115,14 +126,10 @@ export const grammar = class SpamexGrammar {
115
126
  }
116
127
  }
117
128
  *String() {
118
- yield eat(m`<JSON:String />`, null, o({
119
- suppressNode: true
120
- }));
129
+ yield eat(m`:JSON: <_String />`);
121
130
  }
122
131
  *Regex() {
123
- yield eat(m`<Regex:Pattern />`, null, o({
124
- suppressNode: true
125
- }));
132
+ yield eat(m`:Regex: <_Pattern />`);
126
133
  }
127
134
  List() {}
128
135
  Punctuator() {}
@@ -1,12 +1,11 @@
1
1
  import { re, spam as m } from '@bablr/boot';
2
- import { Node, CoveredBy, InjectFrom, UnboundAttributes } from '@bablr/helpers/decorators';
2
+ import { Node, CoveredBy, InjectFrom, Literal } from '@bablr/helpers/decorators';
3
3
  import * as productions from '@bablr/helpers/productions';
4
- import { o, eat, eatMatch, match, bindAttribute, fail } from '@bablr/helpers/grammar';
4
+ import { 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 { notNull } from '@bablr/agast-helpers/tree';
10
9
 
11
10
  export const canonicalURL = 'https://bablr.org/languages/core/en/spamex';
12
11
 
@@ -17,11 +16,11 @@ const { eatMatchTrivia } = CSTML;
17
16
  export const grammar = class SpamexGrammar {
18
17
  @CoveredBy('Expression')
19
18
  *Matcher() {
20
- yield eat(m`<Any />`, [m`<PropertyMatcher /[a-zA-Z.@#<]/ />`, m`<StringMatcher /[/'"]/ />`]);
19
+ yield eat(m`<_Any />`, [m`<PropertyMatcher /[a-zA-Z.@#<]/ />`, m`<__StringMatcher /[/'"]/ />`]);
21
20
  }
22
21
 
23
22
  *NodeMatcher() {
24
- yield eat(m`<Any />`, [
23
+ yield eat(m`<_Any />`, [
25
24
  m`<GapNodeMatcher '<//>' />`,
26
25
  m`<BasicNodeMatcher '<' />`,
27
26
  m`<ArrayNodeMatcher '[' />`,
@@ -52,19 +51,22 @@ export const grammar = class SpamexGrammar {
52
51
  *PropertyMatcher() {
53
52
  yield eatMatch(m`refMatcher: <ReferenceMatcher />`);
54
53
  yield* eatMatchTrivia();
55
- yield eat(m`nodeMatcher: <NodeMatcher />`);
54
+ yield eatMatch(m`bindingMatcher: <BindingMatcher />`);
55
+ yield* eatMatchTrivia();
56
+ yield eat(m`nodeMatcher: <__NodeMatcher />`);
56
57
  }
57
58
 
58
59
  @Node
59
60
  *ReferenceMatcher() {
60
- let name;
61
61
  if (yield match(re`/[.#@]/`)) {
62
- name = yield eatMatch(m`name$: <*Punctuator /[.#@]/ />`);
62
+ yield eat(m`type: <*Punctuator /[.#@]/ />`);
63
+ yield eat(m`name$: null`);
63
64
  } else {
64
- name = yield eatMatch(m`name$: <*CSTML:Identifier />`);
65
+ yield eat(m`type: null`);
66
+ yield eat(m`name$: :CSTML: <Identifier />`);
65
67
  }
66
68
 
67
- if (name && (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`))) {
69
+ if (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`)) {
68
70
  yield* eatMatchTrivia();
69
71
  yield eatMatch(m`closeIndexToken: <*Punctuator ']' { balancer: true } />`);
70
72
  } else {
@@ -72,7 +74,16 @@ export const grammar = class SpamexGrammar {
72
74
  }
73
75
 
74
76
  yield* eatMatchTrivia();
75
- yield eatMatch(m`flags: <CSTML:ReferenceFlags />`);
77
+ yield eatMatch(m`flags: :CSTML: <ReferenceFlags />`);
78
+ yield* eatMatchTrivia();
79
+ yield eat(m`sigilToken: <*Punctuator ':' />`);
80
+ }
81
+
82
+ @Node
83
+ *BindingMatcher() {
84
+ yield eat(m`sigilToken: <*Punctuator ':' />`);
85
+ yield* eatMatchTrivia();
86
+ yield eat(m`languagePath: :CSTML: <IdentifierPath />`);
76
87
  yield* eatMatchTrivia();
77
88
  yield eat(m`sigilToken: <*Punctuator ':' />`);
78
89
  }
@@ -82,7 +93,7 @@ export const grammar = class SpamexGrammar {
82
93
  *BasicNodeMatcher() {
83
94
  let open = yield eat(m`open: <OpenNodeMatcher />`);
84
95
 
85
- const selfClosing = notNull(open.get('selfClosingTagToken'));
96
+ const selfClosing = open.get('selfClosingTagToken');
86
97
 
87
98
  if (selfClosing) {
88
99
  yield eat(m`children[]$: []`);
@@ -97,15 +108,17 @@ export const grammar = class SpamexGrammar {
97
108
 
98
109
  @Node
99
110
  *OpenNodeMatcher() {
100
- yield eat(m`open: <*Punctuator '<' { balancedSpan: 'Tag', balanced: '>' } />`);
101
- yield eat(m`flags: <CSTML:NodeFlags />`);
111
+ yield eat(m`openToken: <*Punctuator '<' { balancedSpan: 'Tag', balanced: '>' } />`);
112
+ let flags = yield eat(m`flags: :CSTML: <NodeFlags />`);
102
113
 
103
- if (yield eatMatch(m`<CSTML:TagType /[a-zA-Z'"\g]/ />`)) {
104
- // continue
105
- } else if (yield eatMatch(m`type$: <*Punctuator /[ \t]+|?/ />`)) {
114
+ if (yield eatMatch(m`type$: :CSTML: <Identifier /[a-zA-Z\u{80}-\u{10ffff}\u0060\g]/ />`)) {
106
115
  // continue
107
- } else {
108
- yield fail();
116
+ } else if (!flags.get('fragmentToken')) {
117
+ if (yield eatMatch(m`type$: <*Punctuator '?' />`)) {
118
+ // continue
119
+ } else {
120
+ yield fail();
121
+ }
109
122
  }
110
123
 
111
124
  let sp = yield* eatMatchTrivia();
@@ -113,18 +126,18 @@ export const grammar = class SpamexGrammar {
113
126
  if (
114
127
  sp &&
115
128
  !(yield match(re`/\/$/`)) &&
116
- (yield eatMatch(m`intrinsicValue$: <StringMatcher />`))
129
+ (yield eatMatch(m`intrinsicValue$: <__StringMatcher />`))
117
130
  ) {
118
131
  sp = yield* eatMatchTrivia();
119
132
  }
120
133
 
121
134
  while (sp && (yield match('{'))) {
122
- yield eat(m`attributes: <JSON:Object />`);
135
+ yield eat(m`attributes: :JSON: <Object />`);
123
136
  sp = yield* eatMatchTrivia();
124
137
  }
125
138
 
126
139
  yield eatMatch(m`selfClosingTagToken: <*Punctuator '/' />`);
127
- yield eat(m`close: <*Punctuator '>' { balancer: true } />`);
140
+ yield eat(m`closeToken: <*Punctuator '>' { balancer: true } />`);
128
141
  }
129
142
 
130
143
  @Node
@@ -149,7 +162,7 @@ export const grammar = class SpamexGrammar {
149
162
  @CoveredBy('Expression')
150
163
  @Node
151
164
  *String() {
152
- yield eat(m`<JSON:String />`, null, o({ suppressNode: true }));
165
+ yield eat(m`:JSON: <_String />`);
153
166
  }
154
167
 
155
168
  @CoveredBy('StringMatcher')
@@ -157,12 +170,13 @@ export const grammar = class SpamexGrammar {
157
170
  @CoveredBy('Expression')
158
171
  @Node
159
172
  *Regex() {
160
- yield eat(m`<Regex:Pattern />`, null, o({ suppressNode: true }));
173
+ yield eat(m`:Regex: <_Pattern />`);
161
174
  }
162
175
 
163
176
  @InjectFrom(productions)
164
177
  List() {}
165
178
 
179
+ @Literal
166
180
  @Node
167
181
  @InjectFrom(productions)
168
182
  Punctuator() {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bablr/language-en-spamex",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "A BABLR language for SPAM Expressions",
5
5
  "engines": {
6
6
  "node": ">=12.0.0"
@@ -22,17 +22,17 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@babel/runtime": "^7.23.2",
25
- "@bablr/agast-helpers": "0.6.0",
26
- "@bablr/agast-vm-helpers": "0.6.0",
27
- "@bablr/helpers": "0.21.1",
28
- "@bablr/language-en-blank-space": "0.6.0",
29
- "@bablr/language-en-cstml": "0.8.0",
30
- "@bablr/language-en-cstml-json": "0.1.0",
31
- "@bablr/language-en-regex-vm-pattern": "0.8.0"
25
+ "@bablr/agast-helpers": "0.8.0",
26
+ "@bablr/agast-vm-helpers": "0.8.0",
27
+ "@bablr/boot": "0.9.0",
28
+ "@bablr/helpers": "0.23.0",
29
+ "@bablr/language-en-blank-space": "0.8.0",
30
+ "@bablr/language-en-cstml": "0.10.0",
31
+ "@bablr/language-en-cstml-json": "0.3.0",
32
+ "@bablr/language-en-regex-vm-pattern": "0.10.0"
32
33
  },
33
34
  "devDependencies": {
34
- "@bablr/boot": "^0.7.0",
35
- "@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#49f5952efed27f94ee9b94340eb1563c440bf64e",
35
+ "@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#c97bfa4b3663f8378e9b3e42bb5a41e685406cf9",
36
36
  "@bablr/macrome": "^0.1.3",
37
37
  "@bablr/macrome-generator-bablr": "^0.3.2",
38
38
  "enhanced-resolve": "^5.12.0",