@bablr/language-en-bablr-vm-instruction 0.9.0 → 0.11.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,119 +1,128 @@
1
- /* @macrome
2
- * @generatedby @bablr/macrome-generator-bablr
3
- * @generatedfrom ./grammar.macro.js#d59a1c2024ebd27e109c529425646b0eb4863552
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, o, 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
+
13
+ export const defaultMatcher = m`<Call />`;
14
+
20
15
  export function* eatMatchTrivia() {
21
- if (yield match(re`/[ \t\n]/`)) {
22
- return yield eat(m`#: :Space: <*Space />`);
16
+ let trivia = null;
17
+ while (yield match(re`/[ \t\n]/`)) {
18
+ trivia = yield eat(m`#: :Space: <_Blank />`);
23
19
  }
24
- return null;
20
+ return trivia;
25
21
  }
22
+
26
23
  const IJSON = extendLanguage(JSON, {
27
24
  canonicalURL: 'https://bablr.org/languages/core/en/bablr-vm-instruction-json',
28
- dependencies: {
29
- Instruction: canonicalURL
30
- },
31
25
  grammar: class IJSON extends JSON.grammar {
32
26
  *Expression(props) {
33
- if (yield match(re`/(m|re|t|i)['"\u0060]/`)) {
27
+ if (yield match(re`/(?:m|re|t|i)['"\u0060]/`)) {
34
28
  yield eat(m`:Instruction: <_Expression />`);
35
29
  } else {
36
30
  yield* super.Expression(props);
37
31
  }
38
32
  }
39
- }
33
+ },
40
34
  });
41
- export const dependencies = {
42
- Space,
43
- CSTML,
44
- Spamex,
45
- Regex,
46
- JSON,
47
- IJSON
48
- };
35
+
36
+ export const dependencies = { Space, CSTML, Spamex, Regex, JSON, IJSON };
37
+
49
38
  export const grammar = class BABLRVMInstructionGrammar {
50
- static {
51
- [_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;
52
- }
53
39
  constructor() {
54
- _initProto(this);
40
+ this.literals = new Set(['Keyword']);
55
41
  }
56
- *[(_StringDecs = [CoveredBy('IJSONExpression'), CoveredBy('Expression'), Node], _PunctuatorDecs = [Node, InjectFrom(productions)], _KeywordDecs = [Node, InjectFrom(productions)], _AnyDecs = InjectFrom(productions), "Call")]() {
42
+
43
+ *Call() {
57
44
  yield eat(m`callee$: <*Identifier />`);
58
45
  yield* eatMatchTrivia();
59
- yield eat(m`openToken: <*Punctuator '(' { balanced: ')' } />`);
46
+
47
+ yield eat(m`openToken*: <* '(' />`);
48
+ yield startSpan('Bare', ')');
60
49
  let sp = yield* eatMatchTrivia();
61
50
  let first = true;
62
51
  while ((first || sp) && (yield match(re`/./s`))) {
63
- yield eat(m`values[]$: <__Expression />`);
52
+ yield eat(m`values[]$: <_Expression />`);
64
53
  yield* eatMatchTrivia();
65
- sp = yield eatMatch(m`separatorTokens[]: <*Punctuator ',' />`);
54
+ sp = yield eatMatch(m`#separatorTokens: <* ',' />`);
66
55
  yield* eatMatchTrivia();
67
56
  first = false;
68
57
  }
69
- yield eat(m`closeToken: <*Punctuator ')' { balancer: true } />`);
58
+ yield endSpan();
59
+ yield eat(m`closeToken*: <* ')' />`);
70
60
  }
61
+
71
62
  *Expression() {
72
- 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: <Number /[\d]/ />`)) {
68
+ } else if (yield eatMatch(m`:JSON: <Infinity /[+-]?Infinity/ />`)) {
69
+ } else if (yield eatMatch(m`<SpamexString /m["'\u0060]/ />`)) {
70
+ } else if (yield eatMatch(m`<TagString /t["'\u0060]/ />`)) {
71
+ } else if (yield eatMatch(m`<NodeString /n["'\u0060]/ />`)) {
72
+ } else if (yield eatMatch(m`<RegexString /re["'\u0060]/ />`)) {
73
+ } else if (yield eatMatch(m`<InstructionString /i["'\u0060]/ />`)) {
74
+ } else {
75
+ yield eat(m`:JSON: <String /["']/ />`);
76
+ }
73
77
  }
74
- *SpamexString({
75
- ctx
76
- }) {
77
- yield eat(m`sigilToken: <*Keyword 'm' />`);
78
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
79
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
80
- yield eat(m`content: :Spamex: <__Matcher />`);
81
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
78
+
79
+ *SpamexString() {
80
+ yield eat(m`sigilToken*: <*Keyword 'm' />`);
81
+ let quot = buildString(printSource(yield match(re`/['"\u0060]/`)));
82
+ yield eat(m`openToken*: <* ${quot} />`);
83
+ yield eat(m`content$: :Spamex: <_Matcher />`);
84
+ yield eat(m`closeToken*: <* ${quot} />`);
82
85
  }
83
- *CSTMLString({
84
- ctx
85
- }) {
86
- yield eat(m`sigilToken: <*Keyword 't' />`);
87
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
88
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
89
- yield eat(m`content: :CSTML: <__Tag />`);
90
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
86
+
87
+ *TagString() {
88
+ yield eat(m`sigilToken*: <*Keyword 't' />`);
89
+ let quot = buildString(printSource(yield match(re`/['"\u0060]/`)));
90
+ yield eat(m`openToken*: <* ${quot} />`);
91
+ yield eat(m`content$: :CSTML: <_Tag />`);
92
+ yield eat(m`closeToken*: <* ${quot} />`);
91
93
  }
92
- *RegexString({
93
- ctx
94
- }) {
95
- yield eat(m`sigilToken: <*Keyword 're' />`);
96
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
97
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
98
- yield eat(m`content: :Regex: <Pattern />`);
99
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
94
+
95
+ *NodeString() {
96
+ yield eat(m`sigilToken*: <*Keyword 'n' />`);
97
+ let quot = buildString(printSource(yield match(re`/['"\u0060]/`)));
98
+ yield eat(m`openToken*: <* ${quot} />`);
99
+ yield eat(m`content$: :CSTML: <_Node />`);
100
+ yield eat(m`closeToken*: <* ${quot} />`);
100
101
  }
101
- *InstructionString({
102
- ctx
103
- }) {
104
- yield eat(m`sigilToken: <*Keyword 'i' />`);
105
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
106
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
107
- yield eat(m`content: <Call />`);
108
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
102
+
103
+ *RegexString() {
104
+ yield eat(m`sigilToken*: <*Keyword 're' />`);
105
+ let quot = buildString(printSource(yield match(re`/['"\u0060]/`)));
106
+ yield eat(m`openToken*: <* ${quot} />`);
107
+ yield eat(m`content$: :Regex: <Pattern />`);
108
+ yield eat(m`closeToken*: <* ${quot} />`);
109
109
  }
110
+
111
+ *InstructionString() {
112
+ yield eat(m`sigilToken*: <*Keyword 'i' />`);
113
+ let quot = buildString(printSource(yield match(re`/['"\u0060]/`)));
114
+ yield eat(m`openToken*: <* ${quot} />`);
115
+ yield eat(m`content$: <Call />`);
116
+ yield eat(m`closeToken*: <* ${quot} />`);
117
+ }
118
+
110
119
  *String() {
111
- yield eat(m`:IJSON: <_String />`);
120
+ yield eat(m`:IJSON: <__String />`);
112
121
  }
122
+
113
123
  *Identifier() {
114
124
  yield eat(re`/[a-zA-Z]+/`);
115
125
  }
116
- *Punctuator() {}
117
- *Keyword() {}
118
- *Any() {}
119
- };
126
+ };
127
+
128
+ 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.9.0",
3
+ "version": "0.11.0",
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.23.2",
26
- "@bablr/agast-helpers": "0.8.0",
27
- "@bablr/agast-vm-helpers": "0.8.0",
28
- "@bablr/boot": "0.9.0",
29
- "@bablr/helpers": "0.23.0",
30
- "@bablr/language-en-blank-space": "0.8.0",
31
- "@bablr/language-en-cstml": "0.10.0",
32
- "@bablr/language-en-regex-vm-pattern": "0.10.0",
33
- "@bablr/language-en-spamex": "0.9.0",
34
- "@bablr/language-en-cstml-json": "0.3.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.0",
25
+ "@bablr/language-en-spamex": "0.11.0",
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,132 +0,0 @@
1
- import { re, spam as m } from '@bablr/boot';
2
- import { extendLanguage, o, 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 function* eatMatchTrivia() {
15
- if (yield match(re`/[ \t\n]/`)) {
16
- return yield eat(m`#: :Space: <*Space />`);
17
- }
18
- return null;
19
- }
20
-
21
- const IJSON = extendLanguage(JSON, {
22
- canonicalURL: 'https://bablr.org/languages/core/en/bablr-vm-instruction-json',
23
- dependencies: {
24
- Instruction: canonicalURL,
25
- },
26
- grammar: class IJSON extends JSON.grammar {
27
- *Expression(props) {
28
- if (yield match(re`/(m|re|t|i)['"\u0060]/`)) {
29
- yield eat(m`:Instruction: <_Expression />`);
30
- } else {
31
- yield* super.Expression(props);
32
- }
33
- }
34
- },
35
- });
36
-
37
- export const dependencies = { Space, CSTML, Spamex, Regex, JSON, IJSON };
38
-
39
- export const grammar = class BABLRVMInstructionGrammar {
40
- @Node
41
- *Call() {
42
- yield eat(m`callee$: <*Identifier />`);
43
- yield* eatMatchTrivia();
44
-
45
- yield eat(m`openToken: <*Punctuator '(' { balanced: ')' } />`);
46
- let sp = yield* eatMatchTrivia();
47
- let first = true;
48
- while ((first || sp) && (yield match(re`/./s`))) {
49
- yield eat(m`values[]$: <__Expression />`);
50
- yield* eatMatchTrivia();
51
- sp = yield eatMatch(m`separatorTokens[]: <*Punctuator ',' />`);
52
- yield* eatMatchTrivia();
53
- first = false;
54
- }
55
- yield eat(m`closeToken: <*Punctuator ')' { balancer: true } />`);
56
- }
57
-
58
- *Expression() {
59
- yield eat(m`<_Any />`, [
60
- m`:IJSON: <Array '[' />`,
61
- m`:IJSON: <Object '{' />`,
62
- m`:JSON: <Boolean /true|false/ />`,
63
- m`:JSON: <Null 'null' />`,
64
- m`:JSON: <Number /[\d]/ />`,
65
- m`:JSON: <Infinity /[+-]?Infinity/ />`,
66
- m`<SpamexString /m["'\u0060]/ />`,
67
- m`<CSTMLString /t["'\u0060]/ />`,
68
- m`<RegexString /re["'\u0060]/ />`,
69
- m`<InstructionString /i["'\u0060]/ />`,
70
- m`:JSON: <String /["']/ />`,
71
- ]);
72
- }
73
-
74
- @Node
75
- *SpamexString({ ctx }) {
76
- yield eat(m`sigilToken: <*Keyword 'm' />`);
77
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
78
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
79
- yield eat(m`content: :Spamex: <__Matcher />`);
80
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
81
- }
82
-
83
- @Node
84
- *CSTMLString({ ctx }) {
85
- yield eat(m`sigilToken: <*Keyword 't' />`);
86
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
87
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
88
- yield eat(m`content: :CSTML: <__Tag />`);
89
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
90
- }
91
-
92
- @Node
93
- *RegexString({ ctx }) {
94
- yield eat(m`sigilToken: <*Keyword 're' />`);
95
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
96
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
97
- yield eat(m`content: :Regex: <Pattern />`);
98
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
99
- }
100
-
101
- @Node
102
- *InstructionString({ ctx }) {
103
- yield eat(m`sigilToken: <*Keyword 'i' />`);
104
- let quot = buildString(ctx.sourceTextFor(yield match(re`/['"\u0060]/`)));
105
- yield eat(m`openToken: <*Punctuator ${quot} { balanced: ${quot} } />`);
106
- yield eat(m`content: <Call />`);
107
- yield eat(m`closeToken: <*Punctuator ${quot} { balancer: true } />`);
108
- }
109
-
110
- @CoveredBy('IJSONExpression')
111
- @CoveredBy('Expression')
112
- @Node
113
- *String() {
114
- yield eat(m`:IJSON: <_String />`);
115
- }
116
-
117
- @Node
118
- *Identifier() {
119
- yield eat(re`/[a-zA-Z]+/`);
120
- }
121
-
122
- @Node
123
- @InjectFrom(productions)
124
- *Punctuator() {}
125
-
126
- @Node
127
- @InjectFrom(productions)
128
- *Keyword() {}
129
-
130
- @InjectFrom(productions)
131
- *Any() {}
132
- };