-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
42 lines (42 loc) · 1.34 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Scala Parser goes JavaScript</title>
</head>
<body>
<textarea id="inputArea">print "Hello"</textarea>
<br/>
<button onclick="checkSyntax();">Check Syntax</button>
<button onclick="showAST();">Parse</button>
<div id="output">Output</div>
<script type="module" src="tigerpython-parser.mjs"></script>
<script type="module">
import { TPyParser } from './tigerpython-parser.mjs';
window.TPyParser = TPyParser;
</script>
<script type="text/javascript">
function checkSyntax() {
var inp = document.getElementById('inputArea');
var outp = document.getElementById('output');
TPyParser.rejectDeadCode = true;
var err = TPyParser.checkSyntax(inp.value);
if (err !== null) {
outp.innerHTML = err;
} else {
outp.innerHTML = "-- no errors found --";
}
console.log("Done");
}
function showAST() {
var inp = document.getElementById('inputArea');
var outp = document.getElementById('output');
TPyParser.rejectDeadCode = true;
var ast = TPyParser.parse(inp.value);
console.log(ast);
outp.innerHTML = "Beta-Testing AST:<br/>" + JSON.stringify(ast);
console.log("Done");
}
</script>
</body>
</html>