@live-codes/browser-compilers 0.4.4 → 0.4.9
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/dist/jscpp/JSCPP.es5.min.js +1 -0
- package/dist/turbopascal/turbopascal.js +96 -0
- package/dist/wacl/tcl/wacl-custom.data +22 -0
- package/dist/wacl/tcl/wacl-library.data +54175 -0
- package/dist/wacl/tcl/wacl.js +4 -0
- package/dist/wacl/tcl/wacl.wasm +0 -0
- package/package.json +1 -1
- package/scripts/vendors.js +30 -19
- package/vendor-licenses.md +7 -3
- package/vendor_modules/src/jscpp/JSCPP.es5.min.js +1 -0
- package/vendor_modules/src/jscpp/readme.md +5 -0
- package/vendor_modules/src/turbopascal/LICENSE +22 -0
- package/vendor_modules/src/turbopascal/turbopascal.js +96 -0
- package/vendor_modules/src/wacl/LICENSE.txt +29 -0
- package/vendor_modules/src/wacl/readme.md +2 -0
- package/vendor_modules/src/wacl/tcl/wacl-custom.data +22 -0
- package/vendor_modules/src/wacl/tcl/wacl-library.data +54175 -0
- package/vendor_modules/src/wacl/tcl/wacl.js +4 -0
- package/vendor_modules/src/wacl/tcl/wacl.wasm +0 -0
- package/dist/malinajs/acorn.js +0 -5525
- package/dist/malinajs/astring.js +0 -3
- package/dist/malinajs/cjs2es.js +0 -1
- package/dist/malinajs/csstree.js +0 -1
- package/dist/malinajs/malina.js +0 -6144
- package/vendor_modules/src/malinajs/acorn.js +0 -5525
- package/vendor_modules/src/malinajs/astring.js +0 -3
- package/vendor_modules/src/malinajs/cjs2es.js +0 -1
- package/vendor_modules/src/malinajs/csstree.js +0 -1
- package/vendor_modules/src/malinajs/malina.js +0 -6144
- package/vendor_modules/src/malinajs/readme.md +0 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// based on https://github.com/MikeRalphson/turbopascal/blob/master/tpc.js
|
|
2
|
+
const turbopascal = {
|
|
3
|
+
compiler: new Promise((resolve) => {
|
|
4
|
+
requirejs.config({
|
|
5
|
+
baseUrl: 'https://cdn.jsdelivr.net/npm/turbopascal@1.0.3',
|
|
6
|
+
paths: {
|
|
7
|
+
underscore: 'https://cdn.jsdelivr.net/npm/underscore@1.13.2/underscore-umd.min',
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
require([
|
|
12
|
+
'Stream',
|
|
13
|
+
'Lexer',
|
|
14
|
+
'CommentStripper',
|
|
15
|
+
'Parser',
|
|
16
|
+
'PascalError',
|
|
17
|
+
'Compiler',
|
|
18
|
+
'Machine',
|
|
19
|
+
'SymbolTable',
|
|
20
|
+
], function (
|
|
21
|
+
Stream,
|
|
22
|
+
Lexer,
|
|
23
|
+
CommentStripper,
|
|
24
|
+
Parser,
|
|
25
|
+
PascalError,
|
|
26
|
+
Compiler,
|
|
27
|
+
Machine,
|
|
28
|
+
SymbolTable,
|
|
29
|
+
) {
|
|
30
|
+
function compile(source, run, DEBUG_TRACE) {
|
|
31
|
+
let self = this;
|
|
32
|
+
|
|
33
|
+
if (!source) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let stream = new Stream(source);
|
|
38
|
+
let lexer = new CommentStripper(new Lexer(stream));
|
|
39
|
+
let parser = new Parser(lexer);
|
|
40
|
+
|
|
41
|
+
let result = { parsed: false, compiled: false };
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
// Create the symbol table of built-in constants, functions, and procedures.
|
|
45
|
+
let builtinSymbolTable = SymbolTable.makeBuiltinSymbolTable();
|
|
46
|
+
|
|
47
|
+
// Parse the program into a parse tree. Create the symbol table as we go.
|
|
48
|
+
let root = parser.parse(builtinSymbolTable);
|
|
49
|
+
result.tree = root.print('');
|
|
50
|
+
result.parsed = true;
|
|
51
|
+
|
|
52
|
+
// Compile to bytecode.
|
|
53
|
+
let compiler = new Compiler();
|
|
54
|
+
let bytecode = compiler.compile(root);
|
|
55
|
+
result.compiled = true;
|
|
56
|
+
result.bytecode = bytecode;
|
|
57
|
+
result.pSrc = bytecode.print();
|
|
58
|
+
|
|
59
|
+
if (run) {
|
|
60
|
+
// Execute the bytecode.
|
|
61
|
+
let machine = new Machine(bytecode, this.keyboard);
|
|
62
|
+
if (DEBUG_TRACE) {
|
|
63
|
+
machine.setDebugCallback(function (state) {
|
|
64
|
+
$state.append(state + '\\n');
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
machine.setFinishCallback(function (runningTime) {});
|
|
68
|
+
machine.setOutputCallback(function (line) {
|
|
69
|
+
console.log(line);
|
|
70
|
+
});
|
|
71
|
+
machine.setOutChCallback(function (line) {
|
|
72
|
+
console.log(line);
|
|
73
|
+
});
|
|
74
|
+
machine.setInputCallback(function (callback) {
|
|
75
|
+
self.screen.addCursor();
|
|
76
|
+
self._setInputMode(INPUT_STRING, function (line) {
|
|
77
|
+
self._setInputMode(INPUT_RUNNING);
|
|
78
|
+
callback(line);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
machine.run();
|
|
82
|
+
}
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.warn(e.message);
|
|
85
|
+
// Print parsing errors.
|
|
86
|
+
if (e instanceof PascalError) {
|
|
87
|
+
console.warn(e.getMessage());
|
|
88
|
+
}
|
|
89
|
+
console.warn(e.stack);
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
resolve(compile);
|
|
94
|
+
});
|
|
95
|
+
}),
|
|
96
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
Directory for custom Tcl code
|
|
3
|
+
=============================
|
|
4
|
+
|
|
5
|
+
This directory is turned into a .data file during the build process and loaded
|
|
6
|
+
at startup together with (in parallel to) the wacl-library.data file. Both
|
|
7
|
+
of these data files are mounted to /usr/lib on startup and are put on the
|
|
8
|
+
$auto_path of Wacl.
|
|
9
|
+
|
|
10
|
+
You can put your own packages and tcl code here in this directory. It will be
|
|
11
|
+
available in Wacl on the auto_path, i.e. if the directories here contain
|
|
12
|
+
a pkgIndex.tcl file with the usual signature (see the Tcl documentation for
|
|
13
|
+
the pkg_mkIndex command), you can load them with [package require ...] inside
|
|
14
|
+
Wacl.
|
|
15
|
+
|
|
16
|
+
It is not necessary to completely build Wacl when your Tcl packages change.
|
|
17
|
+
In order to update the contents of wacl-custom.data, you just need to put
|
|
18
|
+
your updated Tcl packages here and then run
|
|
19
|
+
|
|
20
|
+
python $(EMSCRIPTEN)/tools/file_packager.py wacl-custom.data --preload custom@/usr/lib/ >
|
|
21
|
+
|
|
22
|
+
(you need python and the emscripten SDK on your PATH, though).
|