mlogjs 0.2.1 → 0.2.2
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/build/bin.cjs +69 -0
- package/dist/bin.cjs +69 -0
- package/dist/index.cjs +1817 -0
- package/dist/index.mjs +1813 -0
- package/dist/types/Compiler.d.ts +18 -0
- package/{build → dist/types}/Scope.d.ts +23 -26
- package/dist/types/bin.d.ts +1 -0
- package/dist/types/handlers/BlockStatement.d.ts +2 -0
- package/dist/types/handlers/CallExpression.d.ts +3 -0
- package/dist/types/handlers/ForStatement.d.ts +2 -0
- package/{build → dist/types}/handlers/Function.d.ts +4 -4
- package/{build → dist/types}/handlers/Identifier.d.ts +2 -2
- package/dist/types/handlers/IfStatement.d.ts +2 -0
- package/{build → dist/types}/handlers/Literal.d.ts +2 -2
- package/{build → dist/types}/handlers/Object.d.ts +4 -4
- package/{build → dist/types}/handlers/OperationExpressions.d.ts +7 -7
- package/dist/types/handlers/Program.d.ts +2 -0
- package/dist/types/handlers/Statements.d.ts +5 -0
- package/dist/types/handlers/TemplateExpression.d.ts +2 -0
- package/dist/types/handlers/VariableDeclaration.d.ts +3 -0
- package/dist/types/handlers/WhileStatement.d.ts +2 -0
- package/{build → dist/types}/handlers/index.d.ts +14 -14
- package/dist/types/index.d.ts +1 -0
- package/{build → dist/types}/initScope.d.ts +2 -2
- package/{build → dist/types}/instructions/AddressResolver.d.ts +12 -12
- package/{build → dist/types}/instructions/ControlInstructions.d.ts +11 -11
- package/{build → dist/types}/instructions/EndInstruction.d.ts +4 -4
- package/{build → dist/types}/instructions/InstructionBase.d.ts +10 -10
- package/{build → dist/types}/instructions/JumpInstruction.d.ts +15 -15
- package/{build → dist/types}/instructions/OperationInstruction.d.ts +5 -5
- package/{build → dist/types}/instructions/SetCounterInstruction.d.ts +5 -5
- package/{build → dist/types}/instructions/SetInstruction.d.ts +5 -5
- package/{build → dist/types}/instructions/ZeroSpaceInstruction.d.ts +4 -4
- package/{build → dist/types}/instructions/index.d.ts +9 -9
- package/{build → dist/types}/macros/Building.d.ts +11 -11
- package/dist/types/macros/Function.d.ts +12 -0
- package/{build → dist/types}/macros/Math.d.ts +5 -5
- package/{build → dist/types}/macros/Memory.d.ts +5 -5
- package/{build → dist/types}/macros/Namespace.d.ts +21 -21
- package/{build → dist/types}/macros/Other.d.ts +5 -5
- package/{build → dist/types}/macros/RawValue.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Control.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Draw.d.ts +5 -5
- package/{build → dist/types}/macros/commands/DrawFlush.d.ts +5 -5
- package/{build → dist/types}/macros/commands/GetLink.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Lookup.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Print.d.ts +5 -5
- package/{build → dist/types}/macros/commands/PrintFlush.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Radar.d.ts +7 -7
- package/{build → dist/types}/macros/commands/Sensor.d.ts +5 -5
- package/{build → dist/types}/macros/commands/UnitBind.d.ts +5 -5
- package/dist/types/macros/commands/UnitControl.d.ts +5 -0
- package/{build → dist/types}/macros/commands/UnitLocate.d.ts +5 -5
- package/{build → dist/types}/macros/commands/UnitRadar.d.ts +5 -5
- package/{build → dist/types}/macros/commands/Wait.d.ts +5 -5
- package/{build → dist/types}/macros/commands/index.d.ts +14 -14
- package/{build → dist/types}/macros/index.d.ts +7 -7
- package/{build → dist/types}/operators.d.ts +25 -25
- package/dist/types/types.d.ts +100 -0
- package/{build → dist/types}/utils.d.ts +3 -3
- package/{build → dist/types}/values/BaseValue.d.ts +5 -5
- package/{build → dist/types}/values/FunctionValue.d.ts +34 -34
- package/{build → dist/types}/values/LiteralValue.d.ts +12 -12
- package/dist/types/values/ObjectValue.d.ts +19 -0
- package/{build → dist/types}/values/StoreValue.d.ts +11 -11
- package/{build → dist/types}/values/TempValue.d.ts +12 -12
- package/{build → dist/types}/values/VoidValue.d.ts +13 -11
- package/{build → dist/types}/values/index.d.ts +6 -6
- package/doc/README.md +9 -0
- package/lib/eslib/lib.es5.d.ts +1 -1
- package/lib/traits.d.ts +0 -1
- package/package.json +17 -27
- package/build/Compiler.d.ts +0 -18
- package/build/Compiler.js +0 -100
- package/build/Compiler.js.map +0 -1
- package/build/Scope.js +0 -61
- package/build/Scope.js.map +0 -1
- package/build/bin.d.ts +0 -2
- package/build/bin.js +0 -61
- package/build/bin.js.map +0 -1
- package/build/handlers/BlockStatement.d.ts +0 -2
- package/build/handlers/BlockStatement.js +0 -14
- package/build/handlers/BlockStatement.js.map +0 -1
- package/build/handlers/CallExpression.d.ts +0 -3
- package/build/handlers/CallExpression.js +0 -20
- package/build/handlers/CallExpression.js.map +0 -1
- package/build/handlers/ForStatement.d.ts +0 -2
- package/build/handlers/ForStatement.js +0 -32
- package/build/handlers/ForStatement.js.map +0 -1
- package/build/handlers/Function.js +0 -36
- package/build/handlers/Function.js.map +0 -1
- package/build/handlers/Identifier.js +0 -8
- package/build/handlers/Identifier.js.map +0 -1
- package/build/handlers/IfStatement.d.ts +0 -2
- package/build/handlers/IfStatement.js +0 -25
- package/build/handlers/IfStatement.js.map +0 -1
- package/build/handlers/Literal.js +0 -18
- package/build/handlers/Literal.js.map +0 -1
- package/build/handlers/Object.js +0 -44
- package/build/handlers/Object.js.map +0 -1
- package/build/handlers/OperationExpressions.js +0 -33
- package/build/handlers/OperationExpressions.js.map +0 -1
- package/build/handlers/Program.d.ts +0 -2
- package/build/handlers/Program.js +0 -9
- package/build/handlers/Program.js.map +0 -1
- package/build/handlers/Statements.d.ts +0 -5
- package/build/handlers/Statements.js +0 -30
- package/build/handlers/Statements.js.map +0 -1
- package/build/handlers/TemplateExpression.d.ts +0 -2
- package/build/handlers/TemplateExpression.js +0 -18
- package/build/handlers/TemplateExpression.js.map +0 -1
- package/build/handlers/VariableDeclaration.d.ts +0 -3
- package/build/handlers/VariableDeclaration.js +0 -56
- package/build/handlers/VariableDeclaration.js.map +0 -1
- package/build/handlers/WhileStatement.d.ts +0 -2
- package/build/handlers/WhileStatement.js +0 -23
- package/build/handlers/WhileStatement.js.map +0 -1
- package/build/handlers/index.js +0 -31
- package/build/handlers/index.js.map +0 -1
- package/build/index.d.ts +0 -1
- package/build/index.js +0 -8
- package/build/index.js.map +0 -1
- package/build/initScope.js +0 -40
- package/build/initScope.js.map +0 -1
- package/build/instructions/AddressResolver.js +0 -31
- package/build/instructions/AddressResolver.js.map +0 -1
- package/build/instructions/ControlInstructions.js +0 -23
- package/build/instructions/ControlInstructions.js.map +0 -1
- package/build/instructions/EndInstruction.js +0 -11
- package/build/instructions/EndInstruction.js.map +0 -1
- package/build/instructions/InstructionBase.js +0 -21
- package/build/instructions/InstructionBase.js.map +0 -1
- package/build/instructions/JumpInstruction.js +0 -22
- package/build/instructions/JumpInstruction.js.map +0 -1
- package/build/instructions/OperationInstruction.js +0 -11
- package/build/instructions/OperationInstruction.js.map +0 -1
- package/build/instructions/SetCounterInstruction.js +0 -11
- package/build/instructions/SetCounterInstruction.js.map +0 -1
- package/build/instructions/SetInstruction.js +0 -11
- package/build/instructions/SetInstruction.js.map +0 -1
- package/build/instructions/ZeroSpaceInstruction.js +0 -11
- package/build/instructions/ZeroSpaceInstruction.js.map +0 -1
- package/build/instructions/index.js +0 -26
- package/build/instructions/index.js.map +0 -1
- package/build/macros/Building.js +0 -81
- package/build/macros/Building.js.map +0 -1
- package/build/macros/Function.d.ts +0 -12
- package/build/macros/Function.js +0 -20
- package/build/macros/Function.js.map +0 -1
- package/build/macros/Math.js +0 -57
- package/build/macros/Math.js.map +0 -1
- package/build/macros/Memory.js +0 -61
- package/build/macros/Memory.js.map +0 -1
- package/build/macros/Namespace.js +0 -98
- package/build/macros/Namespace.js.map +0 -1
- package/build/macros/Other.js +0 -20
- package/build/macros/Other.js.map +0 -1
- package/build/macros/RawValue.js +0 -16
- package/build/macros/RawValue.js.map +0 -1
- package/build/macros/commands/Control.js +0 -25
- package/build/macros/commands/Control.js.map +0 -1
- package/build/macros/commands/Draw.js +0 -39
- package/build/macros/commands/Draw.js.map +0 -1
- package/build/macros/commands/DrawFlush.js +0 -17
- package/build/macros/commands/DrawFlush.js.map +0 -1
- package/build/macros/commands/GetLink.js +0 -21
- package/build/macros/commands/GetLink.js.map +0 -1
- package/build/macros/commands/Lookup.js +0 -24
- package/build/macros/commands/Lookup.js.map +0 -1
- package/build/macros/commands/Print.js +0 -14
- package/build/macros/commands/Print.js.map +0 -1
- package/build/macros/commands/PrintFlush.js +0 -17
- package/build/macros/commands/PrintFlush.js.map +0 -1
- package/build/macros/commands/Radar.js +0 -61
- package/build/macros/commands/Radar.js.map +0 -1
- package/build/macros/commands/Sensor.js +0 -20
- package/build/macros/commands/Sensor.js.map +0 -1
- package/build/macros/commands/UnitBind.js +0 -17
- package/build/macros/commands/UnitBind.js.map +0 -1
- package/build/macros/commands/UnitControl.d.ts +0 -5
- package/build/macros/commands/UnitControl.js +0 -68
- package/build/macros/commands/UnitControl.js.map +0 -1
- package/build/macros/commands/UnitLocate.js +0 -55
- package/build/macros/commands/UnitLocate.js.map +0 -1
- package/build/macros/commands/UnitRadar.js +0 -41
- package/build/macros/commands/UnitRadar.js.map +0 -1
- package/build/macros/commands/Wait.js +0 -18
- package/build/macros/commands/Wait.js.map +0 -1
- package/build/macros/commands/index.js +0 -33
- package/build/macros/commands/index.js.map +0 -1
- package/build/macros/index.js +0 -40
- package/build/macros/index.js.map +0 -1
- package/build/operators.js +0 -102
- package/build/operators.js.map +0 -1
- package/build/types.d.ts +0 -49
- package/build/types.js +0 -28
- package/build/types.js.map +0 -1
- package/build/utils.js +0 -13
- package/build/utils.js.map +0 -1
- package/build/values/BaseValue.js +0 -112
- package/build/values/BaseValue.js.map +0 -1
- package/build/values/FunctionValue.js +0 -104
- package/build/values/FunctionValue.js.map +0 -1
- package/build/values/LiteralValue.js +0 -88
- package/build/values/LiteralValue.js.map +0 -1
- package/build/values/ObjectValue.d.ts +0 -17
- package/build/values/ObjectValue.js +0 -50
- package/build/values/ObjectValue.js.map +0 -1
- package/build/values/StoreValue.js +0 -31
- package/build/values/StoreValue.js.map +0 -1
- package/build/values/TempValue.js +0 -67
- package/build/values/TempValue.js.map +0 -1
- package/build/values/VoidValue.js +0 -31
- package/build/values/VoidValue.js.map +0 -1
- package/build/values/index.js +0 -23
- package/build/values/index.js.map +0 -1
- package/dist/mlogjs.es.js +0 -6366
- package/dist/mlogjs.umd.js +0 -8
package/build/bin.cjs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var helpers = require('yargs/helpers');
|
|
6
|
+
var index_cjs = require('./index.cjs');
|
|
7
|
+
var cliHighlight = require('cli-highlight');
|
|
8
|
+
var yargs = require('yargs');
|
|
9
|
+
var chalk = require('chalk');
|
|
10
|
+
var path = require('path');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
var yargs__default = /*#__PURE__*/_interopDefaultLegacy(yargs);
|
|
15
|
+
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
|
16
|
+
|
|
17
|
+
yargs__default["default"](helpers.hideBin(process.argv))
|
|
18
|
+
.command("$0 [path] [out]", "compiles your Javascript file to MLog", yargs => {
|
|
19
|
+
return yargs
|
|
20
|
+
.positional("path", {
|
|
21
|
+
describe: "path of the file to compile",
|
|
22
|
+
type: "string",
|
|
23
|
+
})
|
|
24
|
+
.positional("out", {
|
|
25
|
+
describe: "path of the output file",
|
|
26
|
+
type: "string",
|
|
27
|
+
});
|
|
28
|
+
}, argv => {
|
|
29
|
+
const path$1 = argv.path;
|
|
30
|
+
if (!path$1)
|
|
31
|
+
return console.log("missing required path argument");
|
|
32
|
+
if (!fs.existsSync(path$1))
|
|
33
|
+
return console.log(`file at ${path$1} does not exist`);
|
|
34
|
+
const out = argv.out ?? defaultOutPath(path$1);
|
|
35
|
+
if (path$1 == out)
|
|
36
|
+
return console.log("The out path cannot be the same as the input path");
|
|
37
|
+
const code = fs.readFileSync(path$1, "utf8");
|
|
38
|
+
const [output, error, [node]] = index_cjs.compile(code);
|
|
39
|
+
if (error) {
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
let start = error?.loc;
|
|
42
|
+
let end = start;
|
|
43
|
+
if (node) {
|
|
44
|
+
start = node.loc.start;
|
|
45
|
+
end = node.loc.end;
|
|
46
|
+
}
|
|
47
|
+
const lines = code.split("\n");
|
|
48
|
+
console.log(chalk__default["default"].cyanBright([path.resolve(path$1), start.line, start.column].join(":")));
|
|
49
|
+
for (let i = Math.max(start.line - 3, 0); i < Math.min(end.line + 2, lines.length); i++) {
|
|
50
|
+
const n = i + 1;
|
|
51
|
+
const head = chalk__default["default"].gray((n + " | ").padStart(6, " "));
|
|
52
|
+
console.log(head + cliHighlight.highlight(lines[i], { language: "js" }));
|
|
53
|
+
if (n === start.line) {
|
|
54
|
+
console.log(chalk__default["default"].red(" ".repeat(6 + start.column) + "^ " + error.message));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
fs.writeFileSync(out, output);
|
|
60
|
+
console.log(`Success: Compiled ${path$1}. Your compiled code is at ${out}.`);
|
|
61
|
+
})
|
|
62
|
+
.help()
|
|
63
|
+
.scriptName("mlogjs")
|
|
64
|
+
.demandCommand()
|
|
65
|
+
.parse();
|
|
66
|
+
function defaultOutPath(path$1) {
|
|
67
|
+
const parsed = path.parse(path$1);
|
|
68
|
+
return path.join(parsed.dir, `${parsed.name}.mlog`);
|
|
69
|
+
}
|
package/dist/bin.cjs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var helpers = require('yargs/helpers');
|
|
6
|
+
var index_cjs = require('./index.cjs');
|
|
7
|
+
var cliHighlight = require('cli-highlight');
|
|
8
|
+
var yargs = require('yargs');
|
|
9
|
+
var chalk = require('chalk');
|
|
10
|
+
var path = require('path');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
var yargs__default = /*#__PURE__*/_interopDefaultLegacy(yargs);
|
|
15
|
+
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
|
16
|
+
|
|
17
|
+
yargs__default["default"](helpers.hideBin(process.argv))
|
|
18
|
+
.command("$0 [path] [out]", "compiles your Javascript file to MLog", yargs => {
|
|
19
|
+
return yargs
|
|
20
|
+
.positional("path", {
|
|
21
|
+
describe: "path of the file to compile",
|
|
22
|
+
type: "string",
|
|
23
|
+
})
|
|
24
|
+
.positional("out", {
|
|
25
|
+
describe: "path of the output file",
|
|
26
|
+
type: "string",
|
|
27
|
+
});
|
|
28
|
+
}, argv => {
|
|
29
|
+
const path$1 = argv.path;
|
|
30
|
+
if (!path$1)
|
|
31
|
+
return console.log("missing required path argument");
|
|
32
|
+
if (!fs.existsSync(path$1))
|
|
33
|
+
return console.log(`file at ${path$1} does not exist`);
|
|
34
|
+
const out = argv.out ?? defaultOutPath(path$1);
|
|
35
|
+
if (path$1 == out)
|
|
36
|
+
return console.log("The out path cannot be the same as the input path");
|
|
37
|
+
const code = fs.readFileSync(path$1, "utf8");
|
|
38
|
+
const [output, error, [node]] = index_cjs.compile(code);
|
|
39
|
+
if (error) {
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
let start = error?.loc;
|
|
42
|
+
let end = start;
|
|
43
|
+
if (node) {
|
|
44
|
+
start = node.loc.start;
|
|
45
|
+
end = node.loc.end;
|
|
46
|
+
}
|
|
47
|
+
const lines = code.split("\n");
|
|
48
|
+
console.log(chalk__default["default"].cyanBright([path.resolve(path$1), start.line, start.column].join(":")));
|
|
49
|
+
for (let i = Math.max(start.line - 3, 0); i < Math.min(end.line + 2, lines.length); i++) {
|
|
50
|
+
const n = i + 1;
|
|
51
|
+
const head = chalk__default["default"].gray((n + " | ").padStart(6, " "));
|
|
52
|
+
console.log(head + cliHighlight.highlight(lines[i], { language: "js" }));
|
|
53
|
+
if (n === start.line) {
|
|
54
|
+
console.log(chalk__default["default"].red(" ".repeat(6 + start.column) + "^ " + error.message));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
fs.writeFileSync(out, output);
|
|
60
|
+
console.log(`Success: Compiled ${path$1}. Your compiled code is at ${out}.`);
|
|
61
|
+
})
|
|
62
|
+
.help()
|
|
63
|
+
.scriptName("mlogjs")
|
|
64
|
+
.demandCommand()
|
|
65
|
+
.parse();
|
|
66
|
+
function defaultOutPath(path$1) {
|
|
67
|
+
const parsed = path.parse(path$1);
|
|
68
|
+
return path.join(parsed.dir, `${parsed.name}.mlog`);
|
|
69
|
+
}
|