@live-codes/browser-compilers 0.4.5 → 0.4.10
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 +41 -7
- package/vendor-licenses.md +7 -1
- 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 +85 -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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013, Lawrence Kesteloot
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
- Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
- Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
and/or other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
14
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
15
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
16
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
17
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
18
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
19
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
20
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
21
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// based on https://github.com/MikeRalphson/turbopascal/blob/master/tpc.js
|
|
3
|
+
const turbopascal = {
|
|
4
|
+
createCompiler: (options = {}) =>
|
|
5
|
+
new Promise((resolve) => {
|
|
6
|
+
const inputCallback =
|
|
7
|
+
options.inputCallback ||
|
|
8
|
+
((callback) => {
|
|
9
|
+
const input = window.prompt('please supply the input');
|
|
10
|
+
callback(input);
|
|
11
|
+
});
|
|
12
|
+
const outputCallback = options.outputCallback || console.log;
|
|
13
|
+
const errorCallback = options.errorCallback || console.warn;
|
|
14
|
+
|
|
15
|
+
requirejs.config({
|
|
16
|
+
baseUrl: 'https://cdn.jsdelivr.net/npm/turbopascal@1.0.3',
|
|
17
|
+
paths: {
|
|
18
|
+
underscore: 'https://cdn.jsdelivr.net/npm/underscore@1.13.2/underscore-umd.min',
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
require([
|
|
23
|
+
'Stream',
|
|
24
|
+
'Lexer',
|
|
25
|
+
'CommentStripper',
|
|
26
|
+
'Parser',
|
|
27
|
+
'Compiler',
|
|
28
|
+
'Machine',
|
|
29
|
+
'SymbolTable',
|
|
30
|
+
], function (Stream, Lexer, CommentStripper, Parser, Compiler, Machine, SymbolTable) {
|
|
31
|
+
function compile(source, run, DEBUG_TRACE) {
|
|
32
|
+
let result = { parsed: false, compiled: false };
|
|
33
|
+
if (!source) return result;
|
|
34
|
+
|
|
35
|
+
let stream = new Stream(source);
|
|
36
|
+
let lexer = new CommentStripper(new Lexer(stream));
|
|
37
|
+
let parser = new Parser(lexer);
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
// Create the symbol table of built-in constants, functions, and procedures.
|
|
41
|
+
let builtinSymbolTable = SymbolTable.makeBuiltinSymbolTable();
|
|
42
|
+
|
|
43
|
+
// Parse the program into a parse tree. Create the symbol table as we go.
|
|
44
|
+
let root = parser.parse(builtinSymbolTable);
|
|
45
|
+
result.tree = root.print('');
|
|
46
|
+
result.parsed = true;
|
|
47
|
+
|
|
48
|
+
// Compile to bytecode.
|
|
49
|
+
let compiler = new Compiler();
|
|
50
|
+
let bytecode = compiler.compile(root);
|
|
51
|
+
result.compiled = true;
|
|
52
|
+
result.bytecode = bytecode;
|
|
53
|
+
result.pSrc = bytecode.print();
|
|
54
|
+
|
|
55
|
+
if (run) {
|
|
56
|
+
// Execute the bytecode.
|
|
57
|
+
let machine = new Machine(bytecode, this.keyboard);
|
|
58
|
+
if (DEBUG_TRACE) {
|
|
59
|
+
machine.setDebugCallback(function (state) {
|
|
60
|
+
$state.append(state + '\\n');
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
machine.setFinishCallback(function (runningTime) {});
|
|
64
|
+
machine.setOutputCallback(function (line) {
|
|
65
|
+
outputCallback(line);
|
|
66
|
+
});
|
|
67
|
+
machine.setOutChCallback(function (line) {
|
|
68
|
+
outputCallback(line);
|
|
69
|
+
});
|
|
70
|
+
machine.setInputCallback(function (callback) {
|
|
71
|
+
inputCallback(callback);
|
|
72
|
+
});
|
|
73
|
+
machine.run();
|
|
74
|
+
}
|
|
75
|
+
} catch (e) {
|
|
76
|
+
// Print errors.
|
|
77
|
+
const msg = e.getMessage() || e.message || e;
|
|
78
|
+
errorCallback(msg);
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
resolve(compile);
|
|
83
|
+
});
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017, ecky-l
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -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).
|