-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathinteractive.html
39 lines (38 loc) · 1.19 KB
/
interactive.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
<!doctype html>
<html>
<head>
<title>Parser Test Suite Page</title>
</head>
<body>
(c) qfox.nl<br/>
Parser interactive input (just start typing js :)<br/>
<div>
<textarea id="left" style="width: 47%; height: 500px; margin-right: 4%">var foo = <div class="foo" meh='bar' hidden></div>;</textarea>
<textarea id="right" style="width: 47%; height: 500px;"></textarea>
</div>
<script src="unicodecategories.js"></script>
<script src="Tokenizer.js"></script>
<script src="ZeParser.js"></script>
<script>
var left = document.getElementById('left');
left.value = localStorage.getItem('input');
left.focus();
var parser = null;
document.getElementById('left').onkeyup = function(){
var tree = [];
var input = document.getElementById('left').value;
localStorage.setItem('input', input);
var tokenizer = new Tokenizer(input);
parser = new ZeParser(input, tokenizer, tree);
parser.parse();
parser.tokenizer.fixValues();
document.getElementById('right').value = '{'+tokenizer.wtree.map(function(t){
return Object.keys(t).map(function(key){
return key+':'+t[key];
}).join(' ');
}).join('}\n{')+'}';
};
//document.getElementById('left').onkeyup();
</script>
</body>
</html>