@bablr/language-en-spamex 0.8.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  /* @macrome
2
2
  * @generatedby @bablr/macrome-generator-bablr
3
- * @generatedfrom ./grammar.macro.js#9ab9bbc4fe3575128046794948beb9a3e1ef7178
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,12 +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 { notNull } from '@bablr/agast-helpers/tree';
17
+ import { buildString } from '@bablr/helpers/builders';
18
18
  export const canonicalURL = 'https://bablr.org/languages/core/en/spamex';
19
19
  export const dependencies = {
20
20
  Regex,
@@ -22,21 +22,22 @@ export const dependencies = {
22
22
  JSON,
23
23
  Space
24
24
  };
25
+ export const defaultMatcher = m`<_Matcher />`;
25
26
  const {
26
27
  eatMatchTrivia
27
28
  } = CSTML;
28
29
  export const grammar = class SpamexGrammar {
29
30
  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;
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;
31
32
  }
32
33
  constructor() {
33
34
  _initProto(this);
34
35
  }
35
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")]() {
36
- yield eat(m`<_Any />`, [m`<PropertyMatcher /[a-zA-Z.@#<]/ />`, m`<__StringMatcher /[/'"]/ />`]);
37
+ yield eat(m`<__Any />`, [m`<PropertyMatcher /[a-zA-Z.@#<]/ />`, m`<_StringMatcher /[/'"]/ />`]);
37
38
  }
38
39
  *NodeMatcher() {
39
- yield eat(m`<_Any />`, [m`<GapNodeMatcher '<//>' />`, m`<BasicNodeMatcher '<' />`, m`<ArrayNodeMatcher '[' />`, m`<NullNodeMatcher 'null' />`]);
40
+ yield eat(m`<__Any />`, [m`<GapNodeMatcher '<//>' />`, m`<BasicNodeMatcher '<' />`, m`<ArrayNodeMatcher '[' />`, m`<NullNodeMatcher 'null' />`]);
40
41
  }
41
42
  *GapNodeMatcher() {
42
43
  yield eat(m`sigilToken: <*Punctuator '<//>' />`);
@@ -50,29 +51,52 @@ export const grammar = class SpamexGrammar {
50
51
  *PropertyMatcher() {
51
52
  yield eatMatch(m`refMatcher: <ReferenceMatcher />`);
52
53
  yield* eatMatchTrivia();
53
- yield eat(m`nodeMatcher: <__NodeMatcher />`);
54
+ yield eatMatch(m`bindingMatcher: <BindingMatcher />`);
55
+ yield* eatMatchTrivia();
56
+ yield eat(m`nodeMatcher: <_NodeMatcher />`);
54
57
  }
55
- *ReferenceMatcher() {
56
- let name;
57
- if (yield match(re`/[.#@]/`)) {
58
- name = yield eatMatch(m`name$: <*Punctuator /[.#@]/ />`);
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
+ }
59
74
  } else {
60
- name = yield eatMatch(m`name$: <CSTML:Identifier />`);
75
+ yield eat(m`name$: null`, o({}), o({
76
+ bind: true
77
+ }));
61
78
  }
62
- if (name && (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`))) {
79
+ if (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`)) {
63
80
  yield* eatMatchTrivia();
64
81
  yield eatMatch(m`closeIndexToken: <*Punctuator ']' { balancer: true } />`);
65
82
  } else {
66
83
  yield eatMatch(m`closeIndexToken: null`);
67
84
  }
68
85
  yield* eatMatchTrivia();
69
- yield eatMatch(m`flags: <CSTML:ReferenceFlags />`);
86
+ yield eatMatch(m`flags: :CSTML: <ReferenceFlags />`);
87
+ yield* eatMatchTrivia();
88
+ yield eat(m`sigilToken: <*Punctuator ':' />`);
89
+ }
90
+ *BindingMatcher() {
91
+ yield eat(m`sigilToken: <*Punctuator ':' />`);
92
+ yield* eatMatchTrivia();
93
+ yield eat(m`languagePath: :CSTML: <IdentifierPath />`);
70
94
  yield* eatMatchTrivia();
71
95
  yield eat(m`sigilToken: <*Punctuator ':' />`);
72
96
  }
73
97
  *BasicNodeMatcher() {
74
98
  let open = yield eat(m`open: <OpenNodeMatcher />`);
75
- const selfClosing = notNull(open.get('selfClosingTagToken'));
99
+ const selfClosing = open.get('selfClosingToken');
76
100
  if (selfClosing) {
77
101
  yield eat(m`children[]$: []`);
78
102
  yield eat(m`close: null`);
@@ -83,25 +107,27 @@ export const grammar = class SpamexGrammar {
83
107
  }
84
108
  }
85
109
  *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]+|?/ />`)) {
110
+ yield eat(m`openToken: <*Punctuator '<' { balancedSpan: 'Tag', balanced: '>' } />`);
111
+ let flags = yield eat(m`flags: :CSTML: <NodeFlags />`);
112
+ if (yield eatMatch(m`type$: :CSTML: <Identifier /[a-zA-Z\u{80}-\u{10ffff}\u0060\g]/ />`)) {
91
113
  // continue
92
- } else {
93
- yield fail();
114
+ } else if (!flags.get('fragmentToken')) {
115
+ if (yield eatMatch(m`type$: <*Punctuator '?' />`)) {
116
+ // continue
117
+ } else {
118
+ yield fail();
119
+ }
94
120
  }
95
121
  let sp = yield* eatMatchTrivia();
96
- if (sp && !(yield match(re`/\/$/`)) && (yield eatMatch(m`intrinsicValue$: <__StringMatcher />`))) {
122
+ if (sp && !(yield match(re`/\/$/`)) && (yield eatMatch(m`literalValue$: <_StringMatcher />`))) {
97
123
  sp = yield* eatMatchTrivia();
98
124
  }
99
125
  while (sp && (yield match('{'))) {
100
- yield eat(m`attributes: <JSON:Object />`);
126
+ yield eat(m`attributes: :JSON: <Object />`);
101
127
  sp = yield* eatMatchTrivia();
102
128
  }
103
- yield eatMatch(m`selfClosingTagToken: <*Punctuator '/' />`);
104
- yield eat(m`close: <*Punctuator '>' { balancer: true } />`);
129
+ yield eatMatch(m`selfClosingToken: <*Punctuator '/' />`);
130
+ yield eat(m`closeToken: <*Punctuator '>' { balancer: true } />`);
105
131
  }
106
132
  *CloseNodeMatcher() {
107
133
  yield eat(m`openToken: <*Punctuator '</' { balanced: '>' } />`);
@@ -115,10 +141,10 @@ export const grammar = class SpamexGrammar {
115
141
  }
116
142
  }
117
143
  *String() {
118
- yield eat(m`<_JSON:String />`);
144
+ yield eat(m`:JSON: <__String />`);
119
145
  }
120
146
  *Regex() {
121
- yield eat(m`<_Regex:Pattern />`);
147
+ yield eat(m`:Regex: <__Pattern />`);
122
148
  }
123
149
  List() {}
124
150
  Punctuator() {}
@@ -1,27 +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 { notNull } from '@bablr/agast-helpers/tree';
9
+ import { buildString } from '@bablr/helpers/builders';
10
10
 
11
11
  export const canonicalURL = 'https://bablr.org/languages/core/en/spamex';
12
12
 
13
13
  export const dependencies = { Regex, CSTML, JSON, Space };
14
14
 
15
+ export const defaultMatcher = m`<_Matcher />`;
16
+
15
17
  const { eatMatchTrivia } = CSTML;
16
18
 
17
19
  export const grammar = class SpamexGrammar {
18
20
  @CoveredBy('Expression')
19
21
  *Matcher() {
20
- yield eat(m`<_Any />`, [m`<PropertyMatcher /[a-zA-Z.@#<]/ />`, m`<__StringMatcher /[/'"]/ />`]);
22
+ yield eat(m`<__Any />`, [m`<PropertyMatcher /[a-zA-Z.@#<]/ />`, m`<_StringMatcher /[/'"]/ />`]);
21
23
  }
22
24
 
23
25
  *NodeMatcher() {
24
- yield eat(m`<_Any />`, [
26
+ yield eat(m`<__Any />`, [
25
27
  m`<GapNodeMatcher '<//>' />`,
26
28
  m`<BasicNodeMatcher '<' />`,
27
29
  m`<ArrayNodeMatcher '[' />`,
@@ -52,19 +54,30 @@ export const grammar = class SpamexGrammar {
52
54
  *PropertyMatcher() {
53
55
  yield eatMatch(m`refMatcher: <ReferenceMatcher />`);
54
56
  yield* eatMatchTrivia();
55
- yield eat(m`nodeMatcher: <__NodeMatcher />`);
57
+ yield eatMatch(m`bindingMatcher: <BindingMatcher />`);
58
+ yield* eatMatchTrivia();
59
+ yield eat(m`nodeMatcher: <_NodeMatcher />`);
56
60
  }
57
61
 
58
62
  @Node
59
- *ReferenceMatcher() {
60
- let name;
61
- if (yield match(re`/[.#@]/`)) {
62
- name = yield eatMatch(m`name$: <*Punctuator /[.#@]/ />`);
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
+ }
63
76
  } else {
64
- name = yield eatMatch(m`name$: <CSTML:Identifier />`);
77
+ yield eat(m`name$: null`, o({}), o({ bind: true }));
65
78
  }
66
79
 
67
- if (name && (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`))) {
80
+ if (yield eatMatch(m`openIndexToken: <*Punctuator '[' { balanced: ']' } />`)) {
68
81
  yield* eatMatchTrivia();
69
82
  yield eatMatch(m`closeIndexToken: <*Punctuator ']' { balancer: true } />`);
70
83
  } else {
@@ -72,7 +85,16 @@ export const grammar = class SpamexGrammar {
72
85
  }
73
86
 
74
87
  yield* eatMatchTrivia();
75
- yield eatMatch(m`flags: <CSTML:ReferenceFlags />`);
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 />`);
76
98
  yield* eatMatchTrivia();
77
99
  yield eat(m`sigilToken: <*Punctuator ':' />`);
78
100
  }
@@ -82,7 +104,7 @@ export const grammar = class SpamexGrammar {
82
104
  *BasicNodeMatcher() {
83
105
  let open = yield eat(m`open: <OpenNodeMatcher />`);
84
106
 
85
- const selfClosing = notNull(open.get('selfClosingTagToken'));
107
+ const selfClosing = open.get('selfClosingToken');
86
108
 
87
109
  if (selfClosing) {
88
110
  yield eat(m`children[]$: []`);
@@ -97,34 +119,32 @@ export const grammar = class SpamexGrammar {
97
119
 
98
120
  @Node
99
121
  *OpenNodeMatcher() {
100
- yield eat(m`open: <*Punctuator '<' { balancedSpan: 'Tag', balanced: '>' } />`);
101
- yield eat(m`flags: <CSTML:NodeFlags />`);
122
+ yield eat(m`openToken: <*Punctuator '<' { balancedSpan: 'Tag', balanced: '>' } />`);
123
+ let flags = yield eat(m`flags: :CSTML: <NodeFlags />`);
102
124
 
103
- if (yield eatMatch(m`<_CSTML:TagType /[a-zA-Z'"\g]/ />`)) {
125
+ if (yield eatMatch(m`type$: :CSTML: <Identifier /[a-zA-Z\u{80}-\u{10ffff}\u0060\g]/ />`)) {
104
126
  // continue
105
- } else if (yield eatMatch(m`type$: <*Punctuator /[ \t]+|?/ />`)) {
106
- // continue
107
- } else {
108
- yield fail();
127
+ } else if (!flags.get('fragmentToken')) {
128
+ if (yield eatMatch(m`type$: <*Punctuator '?' />`)) {
129
+ // continue
130
+ } else {
131
+ yield fail();
132
+ }
109
133
  }
110
134
 
111
135
  let sp = yield* eatMatchTrivia();
112
136
 
113
- if (
114
- sp &&
115
- !(yield match(re`/\/$/`)) &&
116
- (yield eatMatch(m`intrinsicValue$: <__StringMatcher />`))
117
- ) {
137
+ if (sp && !(yield match(re`/\/$/`)) && (yield eatMatch(m`literalValue$: <_StringMatcher />`))) {
118
138
  sp = yield* eatMatchTrivia();
119
139
  }
120
140
 
121
141
  while (sp && (yield match('{'))) {
122
- yield eat(m`attributes: <JSON:Object />`);
142
+ yield eat(m`attributes: :JSON: <Object />`);
123
143
  sp = yield* eatMatchTrivia();
124
144
  }
125
145
 
126
- yield eatMatch(m`selfClosingTagToken: <*Punctuator '/' />`);
127
- yield eat(m`close: <*Punctuator '>' { balancer: true } />`);
146
+ yield eatMatch(m`selfClosingToken: <*Punctuator '/' />`);
147
+ yield eat(m`closeToken: <*Punctuator '>' { balancer: true } />`);
128
148
  }
129
149
 
130
150
  @Node
@@ -149,7 +169,7 @@ export const grammar = class SpamexGrammar {
149
169
  @CoveredBy('Expression')
150
170
  @Node
151
171
  *String() {
152
- yield eat(m`<_JSON:String />`);
172
+ yield eat(m`:JSON: <__String />`);
153
173
  }
154
174
 
155
175
  @CoveredBy('StringMatcher')
@@ -157,7 +177,7 @@ export const grammar = class SpamexGrammar {
157
177
  @CoveredBy('Expression')
158
178
  @Node
159
179
  *Regex() {
160
- yield eat(m`<_Regex:Pattern />`);
180
+ yield eat(m`:Regex: <__Pattern />`);
161
181
  }
162
182
 
163
183
  @InjectFrom(productions)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bablr/language-en-spamex",
3
- "version": "0.8.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,18 +21,18 @@
21
21
  "test": "mocha"
22
22
  },
23
23
  "dependencies": {
24
- "@babel/runtime": "^7.23.2",
25
- "@bablr/agast-helpers": "0.7.1",
26
- "@bablr/agast-vm-helpers": "0.7.1",
27
- "@bablr/boot": "0.8.1",
28
- "@bablr/helpers": "0.22.1",
29
- "@bablr/language-en-blank-space": "0.7.0",
30
- "@bablr/language-en-cstml": "0.9.0",
31
- "@bablr/language-en-cstml-json": "0.2.0",
32
- "@bablr/language-en-regex-vm-pattern": "0.9.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
- "@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",