@bablr/boot 0.1.4 → 0.1.5

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.
@@ -14,18 +14,31 @@ const name = 'CSTML';
14
14
  const dependencies = { Regex, String: StringLanguage, Number };
15
15
 
16
16
  const covers = buildCovers({
17
- [sym.node]: ['Attribute', 'Property', 'TagType', 'Node', 'OpenNodeTag', 'CloseNodeTag'],
17
+ [sym.node]: [
18
+ 'Attribute',
19
+ 'Property',
20
+ 'TagType',
21
+ 'Node',
22
+ 'OpenNodeTag',
23
+ 'CloseNodeTag',
24
+ 'Terminal',
25
+ ],
18
26
  [sym.fragment]: ['Attributes'],
19
27
  Attribute: ['MappingAttribute', 'BooleanAttribute'],
20
28
  AttributeValue: ['String:String', 'Number:Number'],
21
29
  TagType: ['Identifier', 'GlobalIdentifier'],
30
+ Terminal: ['Literal', 'Trivia', 'Escape'],
22
31
  });
23
32
 
24
33
  const grammar = class CSTMLMiniparserGrammar {
25
34
  Fragment(p) {
26
35
  p.eatMatchTrivia(_);
27
- while (p.match(/<[^/]/y) || p.atExpression) {
28
- p.eatProduction('Property', { path: 'properties[]' });
36
+ while (p.match(/['"]|<[^/]/y) || p.atExpression) {
37
+ if (p.match(/['"]/y)) {
38
+ p.eatProduction('Terminal', { path: 'properties[]' });
39
+ } else {
40
+ p.eatProduction('Property', { path: 'properties[]' });
41
+ }
29
42
  p.eatMatchTrivia(_);
30
43
  }
31
44
  }
@@ -65,7 +78,7 @@ const grammar = class CSTMLMiniparserGrammar {
65
78
  // @Node
66
79
  CloseNodeTag(p) {
67
80
  p.eat('</', PN, { path: 'open', startSpan: 'Tag', balanced: '>' });
68
-
81
+ // TODO permit .type
69
82
  p.eat('>', PN, { path: 'close', endSpan: 'Tag', balancer: true });
70
83
  }
71
84
 
@@ -138,6 +151,37 @@ const grammar = class CSTMLMiniparserGrammar {
138
151
  Identifier(p) {
139
152
  p.eatLiteral(/\w+/y);
140
153
  }
154
+
155
+ // @Cover
156
+ Terminal(p) {
157
+ if (p.match(/!['"]/y)) {
158
+ p.eatProduction('Escape');
159
+ } else if (p.match(/#['"]/y)) {
160
+ p.eatProduction('Trivia');
161
+ } else {
162
+ p.eatProduction('Literal');
163
+ }
164
+ }
165
+
166
+ // @Node
167
+ Escape(p) {
168
+ p.eat('!', PN, { path: 'escapeOperator' });
169
+ p.eatProduction('String:String', { path: 'rawValue' });
170
+ p.eatMatchTrivia(_);
171
+ p.eat(':', PN, { path: 'rawOperator' });
172
+ p.eatProduction('String:String', { path: 'value' });
173
+ }
174
+
175
+ // @Node
176
+ Trivia(p) {
177
+ p.eat('#', PN, { path: 'trivializeOperator' });
178
+ p.eatProduction('String:String', { path: 'value' });
179
+ }
180
+
181
+ // @Node
182
+ Literal(p) {
183
+ p.eatProduction('String:String', { path: 'value' });
184
+ }
141
185
  };
142
186
 
143
187
  module.exports = { name, dependencies, covers, grammar };
@@ -34,6 +34,7 @@ const grammar = class InstructionMiniparserGrammar {
34
34
  Call(p) {
35
35
  p.eat(/\w+/y, ID, { path: 'verb' });
36
36
  p.eatMatchTrivia(_);
37
+ p.eatMatch(/[!#]/y, PN, { path: 'verbSuffix' });
37
38
  p.eatProduction('Tuple', { path: 'arguments' });
38
39
  }
39
40
 
@@ -79,8 +79,8 @@ const grammar = class StringMiniparserGrammar {
79
79
  : p.eatMatchEscape(/\\(u(\{\d{1,6}\}|\d{4})|x[0-9a-fA-F]{2}|[\\nrt0"])/y);
80
80
  lit =
81
81
  p.span.type === 'Single'
82
- ? p.eatMatchLiteral(/[^\r\n\\']+/y)
83
- : p.eatMatchLiteral(/[^\r\n\\"]+/y);
82
+ ? p.eatMatchLiteral(/[^\r\n\0\\']+/y)
83
+ : p.eatMatchLiteral(/[^\r\n\0\\"]+/y);
84
84
  i++;
85
85
  } while (esc || lit);
86
86
  if (i === 1 && !esc && !lit) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bablr/boot",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Compile-time tools for bootstrapping BABLR VM",
5
5
  "engines": {
6
6
  "node": ">=12.0.0"