-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
111 lines (100 loc) · 4.08 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!doctype html>
<html>
<head>
<title>Xextan Parser</title>
<meta name="viewport" content="initial-scale=1.0,width=device-width,user-scalable=0,viewport-fit=cover" />
<style>form, select { margin: 4px 0 }</style>
</head>
<body>
<meta charset='utf-8' />
<span style="font: 15px arial, sans-serif;">Type any Xextan text in the following textarea. The result will be parsed as you type:</span>
<br /><br />
<form id="form1" name="form1" method="post" action="" style="width:100%">
<textarea id="input_textarea" style="width:100%" rows="8" autofocus></textarea>
<br />
<span style="font: 15px arial, sans-serif;">Output mode: </span>
<select id="optlist" onChange="run_parser()">
<option>Raw output</option>
<option>Condensed</option>
<option id="default">Prettified</option>
<option>Prettified + word class</option>
<option>Prettified + wc + extra</option>
<option>Prettified, no terminators</option>
<option>Prettified, no term. + wc</option>
<option>Prettified, no term. + extra</option>
</select>
<select id="morpho-mode" onChange="run_parser();">
<option>Remove morphology</option>
<option>Keep morphology</option>
</select>
<select id="spaces-display-mode" onChange="run_parser();">
<option>Hide spaces</option>
<option>Display spaces as '_'</option>
</select>
<span style="padding-left: 24px; text-align: right; font: 15px arial, sans-serif;">Parser: </span>
<select id="parser" onChange="load_parser();">
<option>Parser: Standard</option>
</select>
<script>
var parser_list = [
{p: undefined, g: "parser.peg"},
];
</script>
<span style="padding-left: 24px; text-align: right; font-size: 12px;">
<a href="parser.pegjs" target="_blank" id="peg-link">[ Grammar file ]</a>
</span>
</form>
<div style="display:block; overflow: scroll; max-height:24em; border: solid 1px; padding: 10px; background-color: #DDDDFF;"
height="24em">
<pre style="white-space: pre-wrap;"><code id="parse_result" width="100%" height="100%"> </code></pre>
</div>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="parser.js"></script>
<script>parser_list[0].p = parser;</script>
<script type="text/javascript" src="parser_preproc.js"></script>
<script type="text/javascript" src="parser_postproc.js"></script>
<script>
document.getElementById("default").defaultSelected = true;
window.onload = load_parser;
function load_parser() {
var i = document.getElementById("parser").selectedIndex;
document.getElementById("peg-link").href = parser_list[i].g;
parser = parser_list[i].p;
run_parser();
}
/*
* Binding the function run_parser() to keyup event on input_textarea by using jQuery
*/
$('#input_textarea').bind( "keyup",
function(e) {
run_parser();
} );
function run_parser() {
try {
var input = $('#input_textarea').val();
input = parser_preprocessing(input);
var result = parser.parse(input);
} catch (err) {
if (err.location !== undefined) {
var location_info = '\nLocation: [' + err.location.start.offset + ', ' + err.location.end.offset + ']';
location_info += '\n…' + input.substring(err.location.start.offset, err.location.start.offset + 12) + '…';
} else var location_info = "";
$('#parse_result').text(err.toString() + location_info);
return;
}
/* We get the output mode selected in the combobox */
var mode = document.getElementById("optlist").selectedIndex;
/* Get the parse tree processing selected in the second combobox */
if (1 == document.getElementById("morpho-mode").selectedIndex)
mode |= 16;
var b_display_spaces = (1 == document.getElementById("spaces-display-mode").selectedIndex);
if (b_display_spaces) mode |= 8;
/* Postprocessing: if mode == 0, the below function won't modify parser' output */
result = parser_postprocessing(result, mode);
// @ parser_postproc.js
/* Retrieve the result */
$('#parse_result').text(result);
}
</script>
</body>
</html>