@bablr/language-en-bablr-vm-instruction 0.3.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/LICENSE +21 -0
- package/README.md +3 -0
- package/lib/cstml.grammar.js +72 -0
- package/lib/cstml.grammar.macro.js +17 -0
- package/lib/grammar.js +3082 -0
- package/lib/grammar.macro.js +151 -0
- package/lib/spamex.grammar.js +121 -0
- package/lib/spamex.grammar.macro.js +17 -0
- package/package.json +54 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { i } from '@bablr/boot/shorthand.macro';
|
|
2
|
+
import { CoveredBy, Node, InjectFrom } from '@bablr/helpers/decorators';
|
|
3
|
+
import * as Space from '@bablr/language-en-blank-space';
|
|
4
|
+
import * as productions from '@bablr/helpers/productions';
|
|
5
|
+
|
|
6
|
+
export const canonicalURL = 'https://bablr.org/languages/core/en/bablr-vm-instruction';
|
|
7
|
+
|
|
8
|
+
export const dependencies = { Space };
|
|
9
|
+
|
|
10
|
+
export function* eatMatchTrivia() {
|
|
11
|
+
if (yield i`match(/[ \t\n]/)`) {
|
|
12
|
+
return yield i`eat(<#*Space:Space>)`;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const grammar = class BABLRVMInstructionGrammar {
|
|
18
|
+
@Node
|
|
19
|
+
*Call() {
|
|
20
|
+
yield i`eat(<*Identifier> 'callee')`;
|
|
21
|
+
yield* eatMatchTrivia();
|
|
22
|
+
yield i`eat(<Tuple> 'arguments')`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
*Expression() {
|
|
26
|
+
yield i`eat(<Any> null [
|
|
27
|
+
<Array '['>
|
|
28
|
+
<Object '{'>
|
|
29
|
+
<Tuple '('>
|
|
30
|
+
<*Boolean /true|false/>
|
|
31
|
+
<*Null 'null'>
|
|
32
|
+
<*Identifier /[a-zA-Z]+/>
|
|
33
|
+
<Number /[\d]|[+-]?Infinity/>
|
|
34
|
+
])`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@CoveredBy('Expression')
|
|
38
|
+
@Node
|
|
39
|
+
*Array() {
|
|
40
|
+
yield i`eat(<~*Punctuator '[' balanced=']'> 'openToken')`;
|
|
41
|
+
let sp = yield* eatMatchTrivia();
|
|
42
|
+
let first = true;
|
|
43
|
+
while ((first || sp) && (yield i`match(/./y)`)) {
|
|
44
|
+
yield i`eat(<Expression> 'elements[]')`;
|
|
45
|
+
sp = yield* eatMatchTrivia();
|
|
46
|
+
first = false;
|
|
47
|
+
}
|
|
48
|
+
yield i`eat(<~*Punctuator ']' balancer> 'closeToken')`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@CoveredBy('Expression')
|
|
52
|
+
@Node
|
|
53
|
+
*Object() {
|
|
54
|
+
yield i`eat(<~*Punctuator '{' balanced='}'> 'openToken')`;
|
|
55
|
+
let sp = yield* eatMatchTrivia();
|
|
56
|
+
let first = true;
|
|
57
|
+
while ((first || sp) && (yield i`match(/./y)`)) {
|
|
58
|
+
yield i`eat(<Property> 'properties[]')`;
|
|
59
|
+
sp = yield* eatMatchTrivia();
|
|
60
|
+
first = false;
|
|
61
|
+
}
|
|
62
|
+
yield i`eat(<~*Punctuator '}' balancer> 'closeToken')`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Node
|
|
66
|
+
*Property() {
|
|
67
|
+
yield i`eat(<*Identifier> 'key')`;
|
|
68
|
+
yield* eatMatchTrivia();
|
|
69
|
+
yield i`eat(<~*Punctuator ':'> 'mapToken')`;
|
|
70
|
+
yield* eatMatchTrivia();
|
|
71
|
+
yield i`eat(<Expression> 'value')`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@CoveredBy('Expression')
|
|
75
|
+
@Node
|
|
76
|
+
*Tuple() {
|
|
77
|
+
yield i`eat(<~*Punctuator '(' balanced=')'> 'openToken')`;
|
|
78
|
+
let sp = yield* eatMatchTrivia();
|
|
79
|
+
let first = true;
|
|
80
|
+
while ((first || sp) && (yield i`match(/./y)`)) {
|
|
81
|
+
yield i`eat(<Expression> 'values[]')`;
|
|
82
|
+
sp = yield* eatMatchTrivia();
|
|
83
|
+
first = false;
|
|
84
|
+
}
|
|
85
|
+
yield i`eat(<~*Punctuator ')' balancer> 'closeToken')`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@CoveredBy('Expression')
|
|
89
|
+
@Node
|
|
90
|
+
*Boolean() {
|
|
91
|
+
yield i`eat(<~*Keyword /true|false/> 'sigilToken')`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@CoveredBy('Expression')
|
|
95
|
+
@Node
|
|
96
|
+
*Null() {
|
|
97
|
+
yield i`eat(<~*Keyword 'null'> 'sigilToken')`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@CoveredBy('Expression')
|
|
101
|
+
@Node
|
|
102
|
+
*Identifier() {
|
|
103
|
+
yield i`eat(/[a-zA-Z]+/)`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
*Number() {
|
|
107
|
+
yield i`eat(<Any> null [
|
|
108
|
+
<Integer /-?\d/>
|
|
109
|
+
<Infinity /[+-]I/>
|
|
110
|
+
])`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@Node
|
|
114
|
+
*UnsignedInteger() {
|
|
115
|
+
yield i`eat(<Digits> 'digits[]')`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@CoveredBy('Number')
|
|
119
|
+
@Node
|
|
120
|
+
*Integer() {
|
|
121
|
+
yield i`eatMatch(<~*Punctuator '-'> 'negativeToken')`;
|
|
122
|
+
yield i`eat(<Digits> 'digits[]')`;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
*Digits() {
|
|
126
|
+
while (yield i`eatMatch(<*Digit /\d/>)`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@Node
|
|
130
|
+
*Digit() {
|
|
131
|
+
yield i`eat(/\d/)`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@CoveredBy('Number')
|
|
135
|
+
@Node
|
|
136
|
+
*Infinity() {
|
|
137
|
+
yield i`eatMatch(<~*Punctuator /[+-]/> 'signToken')`;
|
|
138
|
+
yield i`eat(<~*Keyword 'Infinity'> 'sigilToken')`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
@Node
|
|
142
|
+
@InjectFrom(productions)
|
|
143
|
+
*Punctuator() {}
|
|
144
|
+
|
|
145
|
+
@Node
|
|
146
|
+
@InjectFrom(productions)
|
|
147
|
+
*Keyword() {}
|
|
148
|
+
|
|
149
|
+
@InjectFrom(productions)
|
|
150
|
+
*Any() {}
|
|
151
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/* @macrome
|
|
2
|
+
* @generatedby @bablr/macrome-generator-bablr
|
|
3
|
+
* @generatedfrom ./spamex.grammar.macro.js#ce862490709aa1bd7b3c70d2e6aa90eeca50971e
|
|
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 {
|
|
8
|
+
interpolateArray as _interpolateArray,
|
|
9
|
+
interpolateArrayChildren as _interpolateArrayChildren,
|
|
10
|
+
interpolateString as _interpolateString,
|
|
11
|
+
} from '@bablr/agast-helpers/template';
|
|
12
|
+
import * as _l from '@bablr/agast-vm-helpers/languages';
|
|
13
|
+
import * as _t from '@bablr/agast-helpers/shorthand';
|
|
14
|
+
import * as Spamex from '@bablr/language-en-spamex';
|
|
15
|
+
import * as Instruction from './grammar.js';
|
|
16
|
+
export const canonicalURL = 'https://bablr.org/languages/core/en/bablr-vm-spamex-instruction';
|
|
17
|
+
export const dependencies = {
|
|
18
|
+
...Instruction.dependencies,
|
|
19
|
+
Spamex,
|
|
20
|
+
};
|
|
21
|
+
export const grammar = class BABLRVMSpamexInstructionGrammar extends Instruction.grammar {
|
|
22
|
+
*Expression() {
|
|
23
|
+
if (
|
|
24
|
+
yield _t.node(
|
|
25
|
+
_l.Instruction,
|
|
26
|
+
'Call',
|
|
27
|
+
[_t.ref`verb`, _t.ref`arguments`],
|
|
28
|
+
{
|
|
29
|
+
verb: _t.s_node(_l.Instruction, 'Identifier', 'eatMatch'),
|
|
30
|
+
arguments: _t.node(
|
|
31
|
+
_l.Instruction,
|
|
32
|
+
'Tuple',
|
|
33
|
+
[_t.ref`openToken`, _t.ref`values[]`, _t.ref`closeToken`],
|
|
34
|
+
{
|
|
35
|
+
openToken: _t.s_i_node(_l.Instruction, 'Punctuator', '('),
|
|
36
|
+
values: [
|
|
37
|
+
_t.node(
|
|
38
|
+
_l.Spamex,
|
|
39
|
+
'NodeMatcher',
|
|
40
|
+
[
|
|
41
|
+
_t.ref`openToken`,
|
|
42
|
+
_t.ref`flags`,
|
|
43
|
+
_t.ref`language`,
|
|
44
|
+
_t.ref`namespaceSeparatorToken`,
|
|
45
|
+
_t.ref`type`,
|
|
46
|
+
_t.embedded(_t.s_t_node(_l.Space, 'Space', [_t.lit(' ')], {}, {})),
|
|
47
|
+
_t.ref`intrinsicValue`,
|
|
48
|
+
_t.ref`closeToken`,
|
|
49
|
+
],
|
|
50
|
+
{
|
|
51
|
+
openToken: _t.s_i_node(_l.Spamex, 'Punctuator', '<'),
|
|
52
|
+
flags: _t.node(_l.CSTML, 'Flags', [], {}, {}),
|
|
53
|
+
language: _t.s_node(_l.Spamex, 'Identifier', 'Spamex'),
|
|
54
|
+
namespaceSeparatorToken: _t.s_i_node(_l.Spamex, 'Punctuator', ':'),
|
|
55
|
+
type: _t.s_node(_l.Spamex, 'Identifier', 'Matcher'),
|
|
56
|
+
intrinsicValue: _t.node(
|
|
57
|
+
_l.Regex,
|
|
58
|
+
'Pattern',
|
|
59
|
+
[_t.ref`openToken`, _t.ref`alternatives[]`, _t.ref`closeToken`],
|
|
60
|
+
{
|
|
61
|
+
openToken: _t.s_i_node(_l.Regex, 'Punctuator', '/'),
|
|
62
|
+
alternatives: [
|
|
63
|
+
_t.node(
|
|
64
|
+
_l.Regex,
|
|
65
|
+
'Alternative',
|
|
66
|
+
[_t.ref`elements[]`],
|
|
67
|
+
{
|
|
68
|
+
elements: [
|
|
69
|
+
_t.node(
|
|
70
|
+
_l.Regex,
|
|
71
|
+
'CharacterClass',
|
|
72
|
+
[
|
|
73
|
+
_t.ref`openToken`,
|
|
74
|
+
_t.ref`elements[]`,
|
|
75
|
+
_t.ref`elements[]`,
|
|
76
|
+
_t.ref`elements[]`,
|
|
77
|
+
_t.ref`elements[]`,
|
|
78
|
+
_t.ref`closeToken`,
|
|
79
|
+
],
|
|
80
|
+
{
|
|
81
|
+
openToken: _t.s_i_node(_l.Regex, 'Punctuator', '['),
|
|
82
|
+
elements: [
|
|
83
|
+
_t.node(_l.Regex, 'Character', [_t.lit('<')], {}, {}),
|
|
84
|
+
_t.node(_l.Regex, 'Character', [_t.lit("'")], {}, {}),
|
|
85
|
+
_t.node(_l.Regex, 'Character', [_t.lit('"')], {}, {}),
|
|
86
|
+
_t.node(_l.Regex, 'Character', [_t.lit('/')], {}, {}),
|
|
87
|
+
],
|
|
88
|
+
closeToken: _t.s_i_node(_l.Regex, 'Punctuator', ']'),
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
negate: false,
|
|
92
|
+
},
|
|
93
|
+
),
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{},
|
|
97
|
+
),
|
|
98
|
+
],
|
|
99
|
+
closeToken: _t.s_i_node(_l.Regex, 'Punctuator', '/'),
|
|
100
|
+
},
|
|
101
|
+
{},
|
|
102
|
+
),
|
|
103
|
+
closeToken: _t.s_i_node(_l.Spamex, 'Punctuator', '>'),
|
|
104
|
+
},
|
|
105
|
+
{},
|
|
106
|
+
),
|
|
107
|
+
],
|
|
108
|
+
closeToken: _t.s_i_node(_l.Instruction, 'Punctuator', ')'),
|
|
109
|
+
},
|
|
110
|
+
{},
|
|
111
|
+
),
|
|
112
|
+
},
|
|
113
|
+
{},
|
|
114
|
+
)
|
|
115
|
+
) {
|
|
116
|
+
// done
|
|
117
|
+
} else {
|
|
118
|
+
yield* super.Expression();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { i } from '@bablr/boot/shorthand.macro';
|
|
2
|
+
import * as Spamex from '@bablr/language-en-spamex';
|
|
3
|
+
import * as Instruction from './grammar.js';
|
|
4
|
+
|
|
5
|
+
export const canonicalURL = 'https://bablr.org/languages/core/en/bablr-vm-spamex-instruction';
|
|
6
|
+
|
|
7
|
+
export const dependencies = { ...Instruction.dependencies, Spamex };
|
|
8
|
+
|
|
9
|
+
export const grammar = class BABLRVMSpamexInstructionGrammar extends Instruction.grammar {
|
|
10
|
+
*Expression() {
|
|
11
|
+
if (yield i`eatMatch(<Spamex:Matcher /[<'"/]/>)`) {
|
|
12
|
+
// done
|
|
13
|
+
} else {
|
|
14
|
+
yield* super.Expression();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bablr/language-en-bablr-vm-instruction",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "A BABLR language for BABLR VM instructions",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=12.0.0"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./lib/grammar.js",
|
|
11
|
+
"./cstml": "./lib/cstml.grammar.js",
|
|
12
|
+
"./spamex": "./lib/spamex.grammar.js",
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"lib/**/*.js"
|
|
17
|
+
],
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "macrome build",
|
|
21
|
+
"watch": "macrome watch",
|
|
22
|
+
"clean": "macrome clean"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@babel/runtime": "^7.23.2",
|
|
26
|
+
"@bablr/agast-helpers": "0.2.0",
|
|
27
|
+
"@bablr/agast-vm-helpers": "0.2.0",
|
|
28
|
+
"@bablr/helpers": "0.17.0",
|
|
29
|
+
"@bablr/language-en-blank-space": "0.2.0",
|
|
30
|
+
"@bablr/language-en-cstml": "0.4.0",
|
|
31
|
+
"@bablr/language-en-spamex": "0.3.1"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@bablr/boot": "0.3.0",
|
|
35
|
+
"@bablr/eslint-config-base": "github:bablr-lang/eslint-config-base#49f5952efed27f94ee9b94340eb1563c440bf64e",
|
|
36
|
+
"@bablr/macrome": "0.1.3",
|
|
37
|
+
"@bablr/macrome-generator-bablr": "0.3.1",
|
|
38
|
+
"enhanced-resolve": "^5.12.0",
|
|
39
|
+
"eslint": "^8.47.0",
|
|
40
|
+
"eslint-import-resolver-enhanced-resolve": "^1.0.5",
|
|
41
|
+
"eslint-plugin-import": "^2.27.5",
|
|
42
|
+
"expect": "^29.6.2",
|
|
43
|
+
"prettier": "^2.0.5"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"bablr-language",
|
|
47
|
+
"grammar",
|
|
48
|
+
"english"
|
|
49
|
+
],
|
|
50
|
+
"repository": "git@github.com:bablr-lang/language-en-bablr-vm-instruction.git",
|
|
51
|
+
"homepage": "https://github.com/bablr-lang/language-en-bablr-vm-instruction",
|
|
52
|
+
"author": "Conrad Buck <conartist6@gmail.com>",
|
|
53
|
+
"license": "MIT"
|
|
54
|
+
}
|