-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
385 lines (342 loc) · 17 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Context-Free Grammar Explorer</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<!-- ?25 is used to enforce flushing cache on new versions -->
<link rel="stylesheet" href="css/main.css?25" />
<link rel="stylesheet" href="css/symbols.css?25" />
<link rel="stylesheet" href="css/structures.css?25" />
<link rel="stylesheet" href="css/tabs.css?25" />
<script src="js/common.js?25"></script>
<script src="js/MyError.js?25"></script>
<script src="js/Loader.js?25"></script>
<script src="js/Highlight.js?25"></script>
<script src="js/external/plugins.js?25"></script>
<script src="js/external/lz-string-1.3.3.js"></script>
<script src="js/external/d3.v3.min.js"></script>
<script src="js/external/dagre-d3.min.js"></script>
<script src="js/external/viz.js"></script>
<script src="js/structures/Symbol.js?25"></script>
<script src="js/structures/Word.js?25"></script>
<script src="js/structures/Rule.js?25"></script>
<script src="js/structures/Grammar.js?25"></script>
<script src="js/structures/ConversionGrammar.js?25"></script>
<script src="js/structures/Structures.js?25"></script>
<script src="js/structures/LRItem.js?25"></script>
<script src="js/structures/LRState.js?25"></script>
<script src="js/structures/LRAutomaton.js?25"></script>
<script src="js/structures/ParserActions.js?25"></script>
<script src="js/structures/ParserStructures.js?25"></script>
<script src="js/algorithm_framework/AlgorithmController.js?25"></script>
<script src="js/algorithm_framework/AlgorithmExplorer.js?25"></script>
<script src="js/grammar_forms/ReducedForm.js?25"></script>
<script src="js/grammar_forms/EpsilonFreeForm.js?25"></script>
<script src="js/grammar_forms/ChainRuleFreeForm.js?25"></script>
<script src="js/grammar_forms/ChomskyForm.js?25"></script>
<script src="js/grammar_forms/StrictChomskyForm.js?25"></script>
<script src="js/grammar_forms/NoLeftRecursionForm.js?25"></script>
<script src="js/grammar_forms/GreibachForm.js?25"></script>
<script src="js/grammar_forms/LeftFactoredForm.js?25"></script>
<script src="js/grammar_forms/FrameworkDemoForm.js?25"></script>
<script src="js/parsing/CYK.js?25"></script>
<script src="js/parsing/CYKParseTree.js?25"></script>
<script src="js/parsing/FirstFollowCompute.js?25"></script>
<script src="js/parsing/SLRParseTableCompute.js?25"></script>
<script src="js/parsing/CLRParseTableCompute.js?25"></script>
<script src="js/parsing/LALRParseTableCompute.js?25"></script>
<script src="js/parsing/LRParserAlgorithm.js?25"></script>
<script src="js/parsing/LLParseTableCompute.js?25"></script>
<script src="js/parsing/LLParserAlgorithm.js?25"></script>
<script src="js/gui/visualComponents.js?25"></script>
<script src="js/gui/Menu.js?25"></script>
<script src="js/gui/MainTab.js?25"></script>
<script src="js/gui/RichInput.js?25"></script>
<script src="js/gui/TextInput.js?25"></script>
<script src="js/gui/ParseTableInput.js?25"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-44071587-1']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="page">
<header>
<div id="nav_minimize_overlay"></div>
<nav>
<div>
<div>
<div id="menu_MainTab">
<div>
<div id="logo">
<div><span>C</span><div>ontext-</div><span>F</span><div>ree</div></div>
<div><span>G</span><div>rammar </div><span>E</span><div>xplorer</div></div>
</div>
<div id="footer">
<a href="https://github.com/petee-d/cfge">source (GitHub)</a>,
Petee <span title="Copyleft">©</span> 2013-14
</div>
</div>
</div>
<div>
<div>
<span>input / output</span>
<ul>
<li id="menu_RichInput">grammar (rich)</li>
<li id="menu_TextInput">grammar (text)</li>
<li id="menu_ParseTableInput">parse table</li>
</ul>
</div>
</div>
</div>
<div>
<div>
<div>
<span>normal forms</span>
<ul id="menu_normal_forms">
</ul>
</div>
</div>
</div>
<div>
<div>
<div>
<span>word parsing</span>
<ul id="menu_parsing">
<li id="menu_CYKParseTree">CYK</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
<div class="button" id="nav_minimize">Hide menu</div>
</header>
<div id="content">
<div id="original_grammar"><div></div></div>
<div id="notification_bar"><div></div></div>
<div id="tabs">
<div id="tab_MainTab">
<h3>Welcome to Context-Free Grammar Explorer</h3>
<p>Please start by clicking the top bar to open the menu and chose one of the <b>grammar input methods</b>. There is a handful of <b>grammar examples</b> located in the section for text input, meant to demonstrate some of the algorithms. You can even store a grammar in an HTTP link and share it with others.</p>
<p>Input format:</p>
<ul>
<li><b>Symbols</b> (terminals and nonterminals) are words over the ASCII letters (<i>a-z</i>, <i>A-Z</i>), digits (<i>0-9</i>), some special characters ( <i>_ + - * / ( ) [ ] ’ : ; ! ? @ $ #</i> ); no whitespaces.
<ul>
<li><b>Terminals</b> start with a lowercase letter, digit or a special character, <b>nonterminals</b> start with an uppercase letter (<i>A-Z</i>).</li>
<li>Symbols can optionally be indexed by appending the forward slash character ( <i>/</i> ) and any non-empty string of allowed characters.</li>
</ul>
</li>
<li><b>Words</b> consist of terminals/nonterminals, each separated by at least one space character; alternatively use <code>eps</code> for empty word</li>
</ul>
<p>You can immediatelly see which normal forms your grammar conforms to. Then you can choose one of the algorithms in the menu.</p>
<ul>
<li>Use the <b>list of steps or buttons to navigate</b> through the algorithm visualization. There are buttons to:
<ul>
<li>see the next/previous step</li>
<li>proceed to the next/previous task, skipping substeps</li>
<li>go to the end/beginning</li>
</ul>
</li>
<li>You can either <b>save the final grammar/parse table</b>, save any of the intermediate steps, or discard the changes entirely by leaving the section</li>
</ul>
<p>Please see the thesis for more information, link is on the <a href="https://github.com/petee-d/cfge">project's GitHub page</a>.</p>
</div>
<div id="tab_RichInput">
<div id="RI_container"></div>
</div>
<div id="tab_ParseTableInput">
<div id="PTI_container"></div>
</div>
<div id="tab_TextInput">
<a class="button active" id="TI_friendly">math-like</a>
<a class="button" id="TI_CFGC">brief</a>
<a class="button" id="TI_JSON">JSON</a>
<a class="button" id="TI_link">HTTP link</a>
<textarea id="TI_textarea"></textarea>
<a class="button" id="TI_save">Save</a>
<h2>Useful grammar examples:</h2>
<ul id="TI_examples">
<li class="template"><a href="#">name</a> - <span>description</span></li>
</ul>
</div>
<div id="tab_Algorithm">
<div id="algorithm_setup">
<div id="algorithm_progress"></div>
</div>
<div id="algorithm_container"></div>
<div id="algorithm_ParserInput">
<div>
Input word:
<input />
<a class="button">Parse</a>
</div>
<div id="PI_grammar">
</div>
</div>
</div>
<div id="tab_CYKParseTree">
<p id="PT_notInChomsky">
The CYK algorithm used to parse the input requires a grammar in strict Chomsky normal form. Please modify the grammar yourself or convert it automatically using the option in menu.
</p>
<p id="PT_first">Input word:
<input id="PT_input" />
<a class="button" id="PT_execute">Parse with CYK</a>
</p>
<p id="PT_progress">CYK parsing in progress...
<span>
<span id="PT_progessbar"></span>
<span></span>
</span>
</p>
<p id="PT_result">
The input word
<span id="PT_inputRich"></span>
<span id="PT_success">is generated</span>
<span id="PT_failure">is not generated</span>
by this grammar.
<a class="button" id="PT_anotherCYKParseTree">Display random parse tree</a>
</p>
<div id="PT_tree"></div>
<div id="PT_leftmostDerivation">
<p>Leftmost derivation: </p>
<div></div>
</div>
<div id="PT_rightmostDerivation">
<p>Rightmost derivation: </p>
<div></div>
</div>
</div>
</div>
</div>
</div>
<div id="toolbox">
<div id="algorithm_toolbox">
<div id="algorithm_tools">
<ul id="algorithm_arrows">
<li id="algorithm_goStart"></li>
<li id="algorithm_goPrev"></li>
<li id="algorithm_goBackward"></li>
<li id="algorithm_goForward"></li>
<li id="algorithm_goNext"></li>
<li id="algorithm_goEnd"></li>
</ul>
<h2 id="algorithm_name"></h2>
<table id="algorithm_table">
</table>
<a class="button" id="algorithm_save_result">Save final result and return to input</a>
<a class="button" id="algorithm_save_current">Save current state and return to input</a>
</div>
<div id="algorithm_steps">
<select size="2"></select>
</div>
</div>
</div>
<div id="templates">
<div id="grammar_template" class="template">
<div class="grammar">
<div class="set_box tuple_box">
<div class="set_map">
<div>
<span class="set_mapping" title="Nonterminals - use uppercase letters">
<span class="syntax">N</span>
<span class="syntax">=</span>
</span>
<div>
<div class="set_box">
<div class="set_list nonterminals">
</div>
</div><!--<span class="syntax comma">,</span>-->
</div>
</div>
<div>
<span class="set_mapping" title="Terminals - use lowercase letters">
<span class="syntax">T</span>
<span class="syntax">=</span>
</span>
<div>
<div class="set_box">
<div class="set_list terminals">
</div>
</div><!--<span class="syntax comma">,</span>-->
</div>
</div>
<div>
<span class="set_mapping" title="Rules - use a single nonterminal on the left side and any word on the right side">
<span class="syntax">P</span>
<span class="syntax">=</span>
</span>
<div>
<div class="set_box">
<div class="set_map rules">
</div>
</div><!--<span class="syntax comma">,</span>-->
</div>
</div>
<div>
<span class="set_mapping" title="Starting nonterminal">
<span class="syntax">S</span>
<span class="syntax">=</span>
</span>
<div class="set_list starting_nonterminal"><span class="nonterminal"></span></div>
</div>
</div>
</div>
</div>
</div>
<div id="rule_template" class="template">
<div class="rule">
<span class="set_mapping">
<span class="nonterminal"></span>
<span class="syntax">→</span>
</span>
<div>
<div class="set_list">
</div>
</div>
</div>
</div>
<div id="set_structure_template" class="template">
<div class="set_map structure">
<div>
<span class="set_mapping">
<span class="syntax">=</span>
</span>
<div>
<div class="set_box">
<div class="set_list">
</div>
</div><!--<span class="syntax comma">,</span>-->
</div>
</div>
</div>
</div>
<div id="graph_options_template" class="template">
<select id="graph_option_renderer">
<option value="none">Hide graph</option>
<option value="dagre">dagre-d3</option>
<option value="graphviz">Viz.js</option>
</select>
<select id="graph_option_direction">
<option value="TB">top-bottom</option>
<option value="LR">left-to-right</option>
</select>
</div>
<div id="scratchpad"></div>
</div>
<!-- <div id="page_top"><div id="grammar_evaluation"></div><div id="button_original_grammar">show original grammar</div></div> -->
<div id="error_log" style="display: none">
<div></div>
<textarea></textarea>
</div>
<script type="text/javascript">
Loader();
</script>
</body>
</html>