forked from ajaxorg/treehugger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
55 lines (54 loc) · 1.32 KB
/
test.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
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<title>treehugger.js demo</title>
<script data-main="lib/demo" src="lib/require.js"></script>
<style>
textarea {
font-family: "Courier new";
font-size: 11pt;
width: 100%;
height: 100%;
}
table {
width: 100%;
border: 0;
}
</style>
</head>
<body>
<h1>Treehugger.js playground</h1>
<table>
<tr>
<th>Javascript</th>
<th>AST</th>
</tr>
<tr>
<td><textarea id="code" rows="15" cols="42">var a = 10, b;
console.log(a, b, c);</textarea></td>
<td><textarea id="ast" rows="15" cols="42" readonly style="background-color: #eee;"></textarea></td>
</tr>
<tr>
<th>Analysis code <button id="runbutton">Run</button></th>
<th>Output</th>
</tr>
<tr>
<td><textarea id="analysis" rows="15" cols="42">var declared = {console: true};
ast.traverseTopDown(
'VarDecl(x)', function(b) {
declared[b.x.value] = true;
},
'VarDeclInit(x, _)', function(b) {
declared[b.x.value] = true;
},
'Var(x)', function(b) {
if(!declared[b.x.value])
log("Variable " + b.x.value + " is not declared.");
}
);
</textarea></td>
<td><textarea id="output" rows="15" cols="42" readonly style="background-color: #eee;"></textarea></td>
</tr>
</table>
</body>
</html>