@bablr/language-en-bablr-vm-instruction 0.10.0 → 0.11.1

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,120 +1,129 @@
1
- /* @macrome
2
- * @generatedby @bablr/macrome-generator-bablr
3
- * @generatedfrom ./grammar.macro.js#47f25aae061ffc415e01f1c6898e6397cd0a8e0b
4
- * This file is autogenerated. Please do not edit it directly.
5
- * When editing run `npx macrome watch` then change the file this is generated from.
6
- */
7
- import _applyDecs from "@babel/runtime/helpers/applyDecs2305";
8
- let _initProto, _StringDecs, _PunctuatorDecs, _KeywordDecs, _AnyDecs;
9
1
  import { re, spam as m } from '@bablr/boot';
10
- import { extendLanguage, eat, match, eatMatch } from '@bablr/helpers/grammar';
11
- import { CoveredBy, Node, InjectFrom } from '@bablr/helpers/decorators';
12
- import * as Space from '@bablr/language-en-blank-space';
13
- import * as CSTML from '@bablr/language-en-cstml';
14
- import * as Spamex from '@bablr/language-en-spamex';
15
- import * as Regex from '@bablr/language-en-regex-vm-pattern';
16
- import * as JSON from '@bablr/language-en-cstml-json';
17
- import * as productions from '@bablr/helpers/productions';
2
+ import { extendLanguage, eat, match, eatMatch, startSpan, endSpan } from '@bablr/helpers/grammar';
3
+ import Space from '@bablr/language-en-blank-space';
4
+ import CSTML from '@bablr/language-en-cstml';
5
+ import Spamex from '@bablr/language-en-spamex';
6
+ import Regex from '@bablr/language-en-regex-vm-pattern';
7
+ import JSON from '@bablr/language-en-cstml-json';
18
8
  import { buildString } from '@bablr/helpers/builders';
9
+ import { printSource } from '@bablr/agast-helpers/tree';
10
+
19
11
  export const canonicalURL = 'https://bablr.org/languages/core/en/bablr-vm-instruction';
12
+
20
13
  export const defaultMatcher = m`<Call />`;
14
+
21
15
  export function* eatMatchTrivia() {
22
- if (yield match(re`/[ \t\n]/`)) {
23
- return yield eat(m`#: :Space: <__Blank />`);
16
+ let trivia = null;
17
+ while (yield match(re`/[ \t\n]/`)) {
18
+ trivia = yield eat(m`#: :Space: <_Blank />`);
24
19
  }
25
- return null;
20
+ return trivia;
26
21
  }
22
+
27
23
  const IJSON = extendLanguage(JSON, {
28
24
  canonicalURL: 'https://bablr.org/languages/core/en/bablr-vm-instruction-json',
29
- dependencies: {
30
- Instruction: canonicalURL
31
- },
32
25
  grammar: class IJSON extends JSON.grammar {
33
26
  *Expression(props) {
34
- if (yield match(re`/(m|re|t|i)['"\u0060]/`)) {
35
- yield eat(m`:Instruction: <__Expression />`);
27
+ if (yield match(re`/(?:m|re|t|i)['"\u0060]/`)) {
28
+ yield eat(m`:..: <_Expression />`);
36
29
  } else {
37
30
  yield* super.Expression(props);
38
31
  }
39
32
  }
40
- }
33
+ },
41
34
  });
42
- export const dependencies = {
43
- Space,
44
- CSTML,
45
- Spamex,
46
- Regex,
47
- JSON,
48
- IJSON
49
- };
35
+
36
+ export const dependencies = { Space, CSTML, Spamex, Regex, JSON, IJSON };
37
+
50
38
  export const grammar = class BABLRVMInstructionGrammar {
51
- static {
52
- [_initProto] = _applyDecs(this, [[Node, 2, "Call"], [Node, 2, "SpamexString"], [Node, 2, "CSTMLString"], [Node, 2, "RegexString"], [Node, 2, "InstructionString"], [_StringDecs, 2, "String"], [Node, 2, "Identifier"], [_PunctuatorDecs, 2, "Punctuator"], [_KeywordDecs, 2, "Keyword"], [_AnyDecs, 2, "Any"]], []).e;
53
- }
54
39
  constructor() {
55
- _initProto(this);
40
+ this.literals = new Set(['Keyword']);
56
41
  }
57
- *[(_StringDecs = [CoveredBy('IJSONExpression'), CoveredBy('Expression'), Node], _PunctuatorDecs = [Node, InjectFrom(productions)], _KeywordDecs = [Node, InjectFrom(productions)], _AnyDecs = InjectFrom(productions), "Call")]() {
42
+
43
+ *Call() {
58
44
  yield eat(m`callee$: <*Identifier />`);
59
45
  yield* eatMatchTrivia();
60
- yield eat(m`openToken: <*Punctuator '(' { balanced: ')' } />`);
46
+
47
+ yield eat(m`openToken*: <* '(' />`);
48
+ yield startSpan('Bare', ')');
61
49
  let sp = yield* eatMatchTrivia();
62
50
  let first = true;
63
51
  while ((first || sp) && (yield match(re`/./s`))) {
64
52
  yield eat(m`values[]$: <_Expression />`);
65
53
  yield* eatMatchTrivia();
66
- sp = yield eatMatch(m`#separatorTokens[]: <*Punctuator ',' />`);
54
+ sp = yield eatMatch(m`#separatorTokens: <* ',' />`);
67
55
  yield* eatMatchTrivia();
68
56
  first = false;
69
57
  }
70
- yield eat(m`closeToken: <*Punctuator ')' { balancer: true } />`);
58
+ yield endSpan();
59
+ yield eat(m`closeToken*: <* ')' />`);
71
60
  }
61
+
72
62
  *Expression() {
73
- yield eat(m`<__Any />`, [m`:IJSON: <Array '[' />`, m`:IJSON: <Object '{' />`, m`:JSON: <Boolean /true|false/ />`, m`:JSON: <Null 'null' />`, m`:JSON: <Number /[\d]/ />`, m`:JSON: <Infinity /[+-]?Infinity/ />`, m`<SpamexString /m["'\u0060]/ />`, m`<CSTMLString /t["'\u0060]/ />`, m`<RegexString /re["'\u0060]/ />`, m`<InstructionString /i["'\u0060]/ />`, m`:JSON: <String /["']/ />`]);
63
+ if (yield eatMatch(m`:IJSON: <Array '[' />`)) {
64
+ } else if (yield eatMatch(m`:IJSON: <Object '{' />`)) {
65
+ } else if (yield eatMatch(m`:JSON: <Boolean /true|false/ />`)) {
66
+ } else if (yield eatMatch(m`:JSON: <Null 'null' />`)) {
67
+ } else if (yield eatMatch(m`:JSON: <Undefined 'undefined' />`)) {
68
+ } else if (yield eatMatch(m`:JSON: <Number /[\d]/ />`)) {
69
+ } else if (yield eatMatch(m`:JSON: <Infinity /[+-]?Infinity/ />`)) {
70
+ } else if (yield eatMatch(m`<SpamexString /m["'\u0060]/ />`)) {
71
+ } else if (yield eatMatch(m`<TagString /t["'\u0060]/ />`)) {
72
+ } else if (yield eatMatch(m`<NodeString /n["'\u0060]/ />`)) {
73
+ } else if (yield eatMatch(m`<RegexString /re["'\u0060]/ />`)) {
74
+ } else if (yield eatMatch(m`<InstructionString /i["'\u0060]/ />`)) {
75
+ } else {
76
+ yield eat(m`:JSON: <String /["']/ />`);
77
+ }
74
78
  }
75
- *SpamexString({
76
- ctx
77
- }) {
78
- yield eat(m`sigilToken: <*Keyword 'm' />`);
79
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
80
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
81
- yield eat(m`content: :Spamex: <_Matcher />`);
82
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
79
+
80
+ *SpamexString() {
81
+ yield eat(m`sigilToken*: <*Keyword 'm' />`);
82
+ let quot = buildString(printSource(yield match(re`/['"\u0060]/`)));
83
+ yield eat(m`openToken*: <* ${quot} />`);
84
+ yield eat(m`content$: :Spamex: <_Matcher />`);
85
+ yield eat(m`closeToken*: <* ${quot} />`);
83
86
  }
84
- *CSTMLString({
85
- ctx
86
- }) {
87
- yield eat(m`sigilToken: <*Keyword 't' />`);
88
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
89
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
90
- yield eat(m`content: :CSTML: <_Tag />`);
91
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
87
+
88
+ *TagString() {
89
+ yield eat(m`sigilToken*: <*Keyword 't' />`);
90
+ let quot = buildString(printSource(yield match(re`/['"\u0060]/`)));
91
+ yield eat(m`openToken*: <* ${quot} />`);
92
+ yield eat(m`content$: :CSTML: <_Tag />`);
93
+ yield eat(m`closeToken*: <* ${quot} />`);
92
94
  }
93
- *RegexString({
94
- ctx
95
- }) {
96
- yield eat(m`sigilToken: <*Keyword 're' />`);
97
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
98
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
99
- yield eat(m`content: :Regex: <Pattern />`);
100
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
95
+
96
+ *NodeString() {
97
+ yield eat(m`sigilToken*: <*Keyword 'n' />`);
98
+ let quot = buildString(printSource(yield match(re`/['"\u0060]/`)));
99
+ yield eat(m`openToken*: <* ${quot} />`);
100
+ yield eat(m`content$: :CSTML: <_Node />`);
101
+ yield eat(m`closeToken*: <* ${quot} />`);
101
102
  }
102
- *InstructionString({
103
- ctx
104
- }) {
105
- yield eat(m`sigilToken: <*Keyword 'i' />`);
106
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
107
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
108
- yield eat(m`content: <Call />`);
109
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
103
+
104
+ *RegexString() {
105
+ yield eat(m`sigilToken*: <*Keyword 're' />`);
106
+ let quot = buildString(printSource(yield match(re`/['"\u0060]/`)));
107
+ yield eat(m`openToken*: <* ${quot} />`);
108
+ yield eat(m`content$: :Regex: <Pattern />`);
109
+ yield eat(m`closeToken*: <* ${quot} />`);
110
110
  }
111
+
112
+ *InstructionString() {
113
+ yield eat(m`sigilToken*: <*Keyword 'i' />`);
114
+ let quot = buildString(printSource(yield match(re`/['"\u0060]/`)));
115
+ yield eat(m`openToken*: <* ${quot} />`);
116
+ yield eat(m`content$: <Call />`);
117
+ yield eat(m`closeToken*: <* ${quot} />`);
118
+ }
119
+
111
120
  *String() {
112
121
  yield eat(m`:IJSON: <__String />`);
113
122
  }
123
+
114
124
  *Identifier() {
115
125
  yield eat(re`/[a-zA-Z]+/`);
116
126
  }
117
- *Punctuator() {}
118
- *Keyword() {}
119
- *Any() {}
120
- };
127
+ };
128
+
129
+ export default { canonicalURL, dependencies, grammar, defaultMatcher };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bablr/language-en-bablr-vm-instruction",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "description": "A BABLR language for BABLR VM instructions",
5
5
  "engines": {
6
6
  "node": ">=12.0.0"
@@ -8,35 +8,25 @@
8
8
  "type": "module",
9
9
  "exports": {
10
10
  ".": "./lib/grammar.js",
11
- "./cstml": "./lib/cstml.grammar.js",
12
- "./spamex": "./lib/spamex.grammar.js",
13
11
  "./package.json": "./package.json"
14
12
  },
15
13
  "files": [
16
14
  "lib/**/*.js"
17
15
  ],
18
16
  "sideEffects": false,
19
- "scripts": {
20
- "build": "macrome build",
21
- "watch": "macrome watch",
22
- "clean": "macrome clean"
23
- },
24
17
  "dependencies": {
25
- "@babel/runtime": "7.28.2",
26
- "@bablr/agast-helpers": "0.9.0",
27
- "@bablr/agast-vm-helpers": "0.9.0",
28
- "@bablr/boot": "0.10.0",
29
- "@bablr/helpers": "0.24.0",
30
- "@bablr/language-en-blank-space": "0.9.0",
31
- "@bablr/language-en-cstml": "0.11.0",
32
- "@bablr/language-en-regex-vm-pattern": "0.11.0",
33
- "@bablr/language-en-spamex": "0.10.0",
34
- "@bablr/language-en-cstml-json": "0.4.0"
18
+ "@bablr/agast-helpers": "0.10.0",
19
+ "@bablr/agast-vm-helpers": "0.10.0",
20
+ "@bablr/boot": "0.11.0",
21
+ "@bablr/helpers": "0.25.0",
22
+ "@bablr/language-en-blank-space": "0.10.0",
23
+ "@bablr/language-en-cstml": "0.12.0",
24
+ "@bablr/language-en-regex-vm-pattern": "0.12.1",
25
+ "@bablr/language-en-spamex": "0.11.1",
26
+ "@bablr/language-en-cstml-json": "0.5.0"
35
27
  },
36
28
  "devDependencies": {
37
29
  "@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#c97bfa4b3663f8378e9b3e42bb5a41e685406cf9",
38
- "@bablr/macrome": "^0.1.3",
39
- "@bablr/macrome-generator-bablr": "^0.3.2",
40
30
  "enhanced-resolve": "^5.12.0",
41
31
  "eslint": "^8.47.0",
42
32
  "eslint-import-resolver-enhanced-resolve": "^1.0.5",
@@ -49,7 +39,10 @@
49
39
  "grammar",
50
40
  "english"
51
41
  ],
52
- "repository": "git@github.com:bablr-lang/language-en-bablr-vm-instruction.git",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+ssh://git@github.com/bablr-lang/language-en-bablr-vm-instruction.git"
45
+ },
53
46
  "homepage": "https://github.com/bablr-lang/language-en-bablr-vm-instruction",
54
47
  "author": "Conrad Buck <conartist6@gmail.com>",
55
48
  "license": "MIT"
@@ -1,134 +0,0 @@
1
- import { re, spam as m } from '@bablr/boot';
2
- import { extendLanguage, eat, match, eatMatch } from '@bablr/helpers/grammar';
3
- import { CoveredBy, Node, InjectFrom } from '@bablr/helpers/decorators';
4
- import * as Space from '@bablr/language-en-blank-space';
5
- import * as CSTML from '@bablr/language-en-cstml';
6
- import * as Spamex from '@bablr/language-en-spamex';
7
- import * as Regex from '@bablr/language-en-regex-vm-pattern';
8
- import * as JSON from '@bablr/language-en-cstml-json';
9
- import * as productions from '@bablr/helpers/productions';
10
- import { buildString } from '@bablr/helpers/builders';
11
-
12
- export const canonicalURL = 'https://bablr.org/languages/core/en/bablr-vm-instruction';
13
-
14
- export const defaultMatcher = m`<Call />`;
15
-
16
- export function* eatMatchTrivia() {
17
- if (yield match(re`/[ \t\n]/`)) {
18
- return yield eat(m`#: :Space: <__Blank />`);
19
- }
20
- return null;
21
- }
22
-
23
- const IJSON = extendLanguage(JSON, {
24
- canonicalURL: 'https://bablr.org/languages/core/en/bablr-vm-instruction-json',
25
- dependencies: {
26
- Instruction: canonicalURL,
27
- },
28
- grammar: class IJSON extends JSON.grammar {
29
- *Expression(props) {
30
- if (yield match(re`/(m|re|t|i)['"\u0060]/`)) {
31
- yield eat(m`:Instruction: <__Expression />`);
32
- } else {
33
- yield* super.Expression(props);
34
- }
35
- }
36
- },
37
- });
38
-
39
- export const dependencies = { Space, CSTML, Spamex, Regex, JSON, IJSON };
40
-
41
- export const grammar = class BABLRVMInstructionGrammar {
42
- @Node
43
- *Call() {
44
- yield eat(m`callee$: <*Identifier />`);
45
- yield* eatMatchTrivia();
46
-
47
- yield eat(m`openToken: <*Punctuator '(' { balanced: ')' } />`);
48
- let sp = yield* eatMatchTrivia();
49
- let first = true;
50
- while ((first || sp) && (yield match(re`/./s`))) {
51
- yield eat(m`values[]$: <_Expression />`);
52
- yield* eatMatchTrivia();
53
- sp = yield eatMatch(m`#separatorTokens[]: <*Punctuator ',' />`);
54
- yield* eatMatchTrivia();
55
- first = false;
56
- }
57
- yield eat(m`closeToken: <*Punctuator ')' { balancer: true } />`);
58
- }
59
-
60
- *Expression() {
61
- yield eat(m`<__Any />`, [
62
- m`:IJSON: <Array '[' />`,
63
- m`:IJSON: <Object '{' />`,
64
- m`:JSON: <Boolean /true|false/ />`,
65
- m`:JSON: <Null 'null' />`,
66
- m`:JSON: <Number /[\d]/ />`,
67
- m`:JSON: <Infinity /[+-]?Infinity/ />`,
68
- m`<SpamexString /m["'\u0060]/ />`,
69
- m`<CSTMLString /t["'\u0060]/ />`,
70
- m`<RegexString /re["'\u0060]/ />`,
71
- m`<InstructionString /i["'\u0060]/ />`,
72
- m`:JSON: <String /["']/ />`,
73
- ]);
74
- }
75
-
76
- @Node
77
- *SpamexString({ ctx }) {
78
- yield eat(m`sigilToken: <*Keyword 'm' />`);
79
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
80
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
81
- yield eat(m`content: :Spamex: <_Matcher />`);
82
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
83
- }
84
-
85
- @Node
86
- *CSTMLString({ ctx }) {
87
- yield eat(m`sigilToken: <*Keyword 't' />`);
88
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
89
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
90
- yield eat(m`content: :CSTML: <_Tag />`);
91
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
92
- }
93
-
94
- @Node
95
- *RegexString({ ctx }) {
96
- yield eat(m`sigilToken: <*Keyword 're' />`);
97
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
98
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
99
- yield eat(m`content: :Regex: <Pattern />`);
100
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
101
- }
102
-
103
- @Node
104
- *InstructionString({ ctx }) {
105
- yield eat(m`sigilToken: <*Keyword 'i' />`);
106
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
107
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
108
- yield eat(m`content: <Call />`);
109
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
110
- }
111
-
112
- @CoveredBy('IJSONExpression')
113
- @CoveredBy('Expression')
114
- @Node
115
- *String() {
116
- yield eat(m`:IJSON: <__String />`);
117
- }
118
-
119
- @Node
120
- *Identifier() {
121
- yield eat(re`/[a-zA-Z]+/`);
122
- }
123
-
124
- @Node
125
- @InjectFrom(productions)
126
- *Punctuator() {}
127
-
128
- @Node
129
- @InjectFrom(productions)
130
- *Keyword() {}
131
-
132
- @InjectFrom(productions)
133
- *Any() {}
134
- };