forked from mistic100/sql-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
37 lines (27 loc) · 931 Bytes
/
Copy pathexample.html
File metadata and controls
37 lines (27 loc) · 931 Bytes
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
<html>
<body>
<h1>SQLParser</h1>
<h2>Input</h2>
<textarea id="input" cols="100" rows="10">select * from test where a = 1 and foo = "bar"</textarea>
<button onclick="parse()">Parse</button>
<h2>Tokens</h2>
<pre id="tokens"></pre>
<h2>Parsed</h2>
<pre id="parsed"></pre>
<h2>Output</h2>
<pre id="output"></pre>
<script src="./sql-parser.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
function parse() {
var input = document.getElementById('input').value;
var tokens = SQLParser.lexer.tokenize(input);
var parsed = SQLParser.parser.parse(tokens);
var output = parsed.toString();
document.getElementById('tokens').innerText = tokens;
document.getElementById('parsed').innerText = JSON.stringify(parsed, null, 2);
document.getElementById('output').innerText = output;
}
parse();
</script>
</body>
</html>