-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
executable file
·38 lines (38 loc) · 1.2 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
<!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 src="../release/tigerpython-parser.js"></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>