Skip to content

Commit 59f6e3c

Browse files
committed
fix issues
1 parent 73c75ee commit 59f6e3c

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

scripts/thendral.js renamed to Transpiler.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,6 @@ define("translator/TranslatorMapper", ["require", "exports", "parser/ParserTypes
953953
}
954954
TranslatorMapper.prototype.getTranslation = function () {
955955
this.startTranslation();
956-
console.log(this.lines);
957956
return this.lines;
958957
};
959958
TranslatorMapper.prototype.startTranslation = function () {
@@ -1076,7 +1075,7 @@ define("translator/TranslatorMapper", ["require", "exports", "parser/ParserTypes
10761075
return "elseif ( ".concat(this.visitExpression(e.expr), " ) ").concat(this.visitStatement(e.statement));
10771076
};
10781077
TranslatorMapper.prototype.visitPrintStmt = function (e) {
1079-
return "document.write( ".concat(this.visitExpression(e.expr), " )");
1078+
return "console.log( ".concat(this.visitExpression(e.expr), " )");
10801079
};
10811080
TranslatorMapper.prototype.visitBlockStmt = function (e) {
10821081
var _this = this;

index.html

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<meta charset="utf-8">
22
<title>தென்றல் - Thendral transpiler</title>
3-
3+
<head>
4+
<script src="scripts/require.js"></script>
5+
</head>
46
<style>
7+
8+
body {
9+
background-color: rgba(0,0,0,0.8);
10+
color: white;
11+
}
512
.container {
613
display: flex;
714
flex-direction: row;
@@ -24,25 +31,50 @@
2431
</style>
2532

2633
<div class="container">
27-
<textarea class="textarea"></textarea>
28-
<textarea class="textarea"></textarea>
29-
<textarea class="textarea"></textarea>
34+
<textarea class="textarea" id="thendral-code"></textarea>
35+
<textarea class="textarea" id="translated-code"></textarea>
36+
<textarea class="textarea" id="output"></textarea>
3037
</div>
3138
<div class="container">
3239
<p class="description">Thendral</p>
3340
<p class="description">Translated JS Code</p>
3441
<p class="description">Output</p>
3542
</div>
3643

37-
<script data-main="scripts/thendral" src="scripts/require.js"></script>
44+
3845
<script>
3946

40-
window.addEventListener("load", () => {
47+
function translate() {
48+
const thendralCode = document.getElementById("thendral-code").value
4149

42-
window.thendral = require("Transpiler").thendral
50+
const jsCode = window.thendral(thendralCode).code;
4351

52+
document.getElementById("translated-code")
53+
.value = jsCode
54+
const output = eval(jsCode);
55+
56+
document.getElementById("output")
57+
.value = output
58+
}
59+
60+
window.addEventListener("load", () => {
61+
require(["Transpiler"], (Transpiler) => {
62+
window.thendral = Transpiler.thendral
63+
})
4464

65+
document.getElementById("thendral-code")
66+
.addEventListener("keydown", (event) => {
67+
translate();
68+
})
4569

70+
document.getElementById("thendral-code")
71+
.addEventListener("keypress", (event) => {
72+
translate();
73+
})
74+
document.getElementById("thendral-code")
75+
.addEventListener("keyup", (event) => {
76+
translate();
77+
})
4678

4779
})
4880

0 commit comments

Comments
 (0)