-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.html
386 lines (357 loc) · 13.2 KB
/
main.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
386
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Javascript and Regular Expressions</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<style>
</style>
<!--
<script language="Javascript" type="text/javascript" src="IKRS.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.Object.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.ArraySet.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexAttribute.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.Pattern.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.PushbackStringReader.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.StringBuffer.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexToken.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexTokenizer.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexParser.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.TokenSequence.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.ParseException.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.MatchResult.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.Analyzer.js"></script>
-->
<!-- These classes inherit from IKRS.Pattern -->
<!--
<script language="Javascript" type="text/javascript" src="IKRS.RegexConstant.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexUnion.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexIntersection.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexQuantifyer.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexConcatenation.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexCharacter.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexCharacterSet.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexCharacterRange.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexSpecialCharacter.js"></script>
-->
<!-- Predefined character classes (inherit from IKRS.RegexSpecialCharacter) -->
<!--
<script language="Javascript" type="text/javascript" src="IKRS.RegexWhitespace.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexDigit.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexWord.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexBeginOfInput.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexEndOfInput.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.RegexWildcard.js"></script>
-->
<!-- <script src="js/regular_expressions.lib.js"></script> -->
<script src="dist/regular_expressions.min.js"></script>
<script language="Javascript" type="text/javascript" src="js/main.js"></script>
<script language="Javascript" type="text/javascript" src="js/util.js"></script>
<script language="Javascript" type="text/javascript" src="js/version.js"></script>
</head>
<body>
<h3>Regular Expression Analyzer Test </h3>
Parser Test | <a href="main_analyzer.html">Analyzer Test</a> | <a href="main_extended.html">Extended Test</a><br/><br/>
<table border="0">
<colgroup>
<col width="560px"></col>
<col></col>
<col></col>
<col></col>
</colgroup>
<tr>
<td valign="top">
<form name="regex_form">
Regular Expression: <input type="text" name="input_regex" id="input_regex" size="45" value="([a-zA-Z]|\s)*" /><br/>
<div style="text-align: right;">
<!--
Input A (match): <input type="text" name="input_text_match" id="input_text_match" size="45" value="Your input" /><br/>
Input B (no match): <input type="text" name="input_text_nomatch" id="input_text_nomatch" size="45" value="!non-matching!" /><br/>
-->
Input A (match): <textarea cols="30" rows="4" name="input_text_match" id="input_text_match">Your input</textarea><br/>
Input B (no match): <textarea cols="30" rows="4" name="input_text_nomatch" id="input_text_nomatch">!non-matching!</textarea><br/>
</div>
<div style="text-align: right;"><script>document.write( VERSION_STRING );</script></div>
</form>
<button onclick="testPushbackStringReader();">Test PushbackStringReader</button><br/>
<button onclick="testRegexTokenizer();">Test RegexTokenizer</button><br/>
<button onclick="testRegexParser(true);">Test RegexParser</button><br/>
<button onclick="testRegex();">Test Regex</button><br/>
<button onclick="testTokenizeInput();">Tokenize</button><br/>
Output:<br/>
<div id="output_div" style="font-family: Courier New, Monospace;"></div>
</td>
<td valign="top">
Examples<br/>
<button class="presetButton" onclick="loadPreset('abc','abc','ab');">Constant</button><br/>
<button class="presetButton" onclick="loadPreset('(abc)','abc','bc');">(Constant)</button><br/>
<button class="presetButton" onclick="loadPreset('abc|XYZ','XYZ','abXY');">Constant Union</button><br/>
<button class="presetButton" onclick="loadPreset('abc*','abcabcabc','ababab');">STERN(*)</button><br/>
<button class="presetButton" onclick="loadPreset('ab(c)*','abccccc','Xbcccc');">CONSTANT CONSTANT STERN(*)</button><br/>
<button class="presetButton" onclick="loadPreset('abc+','abcabc','');">STERN(+)</button><br/>
<button class="presetButton" onclick="loadPreset('abc|XYZ+','XYZXYZ','abcXYZ');">UNION or STERN(+)</button><br/>
<button class="presetButton" onclick="loadPreset('(abc|XYZ)+','abcXYZabcabcXYZXYZ','abXYZ');">UNION or STERN(+) (2)</button><br/>
<button class="presetButton" onclick="loadPreset('(abc)(XYZ)','abcXYZ','XYZabc');">Concat</button><br/>
<button class="presetButton" onclick="loadPreset('[a-z]','b','B');">Range</button><br/>
<button class="presetButton" onclick="loadPreset('[^a-z]','A','a');">Range (negated)</button><br/>
<button class="presetButton" onclick="loadPreset('abcdef|[a-z]','a','abc');">Constant or Range</button><br/>
<button class="presetButton" onclick="loadPreset('[asdf]','s','b');">Character Set</button><br/>
<button class="presetButton" onclick="loadPreset('[a-z&&[^k-m]]','a','m');">Range and negated Range</button><br/>
<button class="presetButton" onclick="loadPreset('(abc|DEF){3}','abcDEFabc','abcDEF');">Quantifyer [3 times]</button><br/>
<button class="presetButton" onclick="loadPreset('(abc|DEF){3,}','abcDEFabcDEFabc','abcDEF');">Quantifyer [at least 3 times]</button><br/>
<button class="presetButton" onclick="loadPreset('(abc|DEF){3,5}','abcDEFabcDEF','abcDEFabcDEFabcDEFabc');">Quantifyer [at least 3 times, max 5 times]</button><br/>
<button class="presetButton" onclick="loadPreset('(abc)?DEF','abcDEF','abcabcDEF');">One-time Quantifyer [zero or one times 'abc']</button><br/>
<input type="checkbox" id="concat_presets"> Concatenate Presets<br/>
</td>
<td valign="top">
Examples (2)<br/>
<button class="presetButton" onclick="loadPreset('Trademark_\\u2122_Backslash_\\\\','Trademark_\u2122_Backslash_\\','xyz');">Constant</button><br/>
<button class="presetButton" onclick="loadPreset('^aaabbbccc$','aaabbbccc','aaabbbcccD');">Begin/End-of-Input</button><br/>
<button class="presetButton" onclick="loadPreset('a.c','abc','ac');">Wildcard Character</button><br/>
<button class="presetButton" onclick="loadPreset('a.*c','aXYZc','ab');">Wildcard Character (*)</button><br/>
<button class="presetButton" onclick="loadPreset('a.+c','abc','ac');">Wildcard Character (+)</button><br/>
</td>
<td valign="top">
<table border="0">
<tr>
<th colspan="2">Regular Grammars: Operators</th>
</tr>
<tr>
<td>AB</td>
<td>Concatenation Operator, concats A and B (has no symbol, implicit between operands).</td>
</tr>
<tr>
<td>A|B</td>
<td>Union Operator of A and B; correlates to logical OR.</td>
</tr>
<tr>
<td>A*</td>
<td>Quantifying: repetition Operator (Kleene Stern); repeat A n times where n=0 is allowed (empty expression).</td>
</tr>
<tr>
<td>A+</td>
<td>Quantifying: repetition Operator (non-empty); repeat A n times where n>0 is required (non-empty expression).</td>
</tr>
<tr>
<td>A{n}</td>
<td>Quantifying: repetition Operator (minimum); repeat A at least n times (more allowed).</td>
</tr>
<tr>
<td>A{n,}</td>
<td>Quantifying: repetition Operator (exact); repeat A exactly n times.</td>
</tr>
<tr>
<td>A{n,m}</td>
<td>Quantifying: repetition Operator (minimum and maximum); repeat A at least n times but not more than m times.</td>
</tr>
<tr>
<td>(A)</td>
<td>Parenthesis: bind composite expressions together against stronger operators.</td>
</tr>
<tr>
<td></td>
<td><b>Operator precedence:</b> <code>Union</code> < <code>Concatenation</code> < <code>Quantifying Operators</code> < <code>Parenthesis</code></td>
</tr>
<tr>
<th colspan="2">Regular Grammars: Notation</th>
</tr>
<tr>
<td>a</td>
<td>The single character a</td>
</tr>
<tr>
<td>asdf</td>
<td>The constant character sequence asdf</td>
</tr>
<tr>
<td>asdf|qwertz</td>
<td>The constant character sequence asdf OR qwertz</td>
</tr>
<tr>
<td>asdf*</td>
<td>The sequence asdf zero or n times.</td>
</tr>
<tr>
<td>asdf+</td>
<td>The sequence asdf at least one or n times.</td>
</tr>
<tr>
<td>(abcd|xyz)*</td>
<td>Any sequence (including empty) that cosists of abcd and xyz sub sequences only</td>
</tr>
<tr>
<td>cat{3}</td>
<td>The sequence cat three times: catcatcat</td>
</tr>
<tr>
<td>cat{3,5}</td>
<td>The sequence cat three to five times: catcatcat, catcatcatcat or catcatcatcatcat</td>
</tr>
<tr>
<td>cat{3,}</td>
<td>The sequence cat at least three times: catcatcat, catcatcatcat or catcatcatcatcat, catcatcatcatcatcat, ...</td>
</tr>
<tr>
<th colspan="2">Escaping Characters</th>
</tr>
<tr>
<td>\\</td>
<td>The backslash character</td>
</tr>
<tr>
<td>\.</td>
<td>Punctuation mark (to distinct from wildcard token)</td>
</tr>
<tr>
<td>\^</td>
<td>Circumflex (to distinct from begin-of-input token)</td>
</tr>
<tr>
<td>\$</td>
<td>Dollar (to distinct from end-of-input token)</td>
</tr>
<tr>
<td>\0n</td>
<td>The character with octal value 0n (0 <= n <= 7)</td>
</tr>
<tr>
<td>\0nn</td>
<td>The character with octal value 0nn (0 <= n <= 7)</td>
</tr>
<tr>
<td>\0mnn</td>
<td>The character with octal value 0mnn (0 <= m <= 3, 0 <= n <= 7)</td>
</tr>
<tr>
<td>\xhh</td>
<td>The character with hexadecimal value 0xhh</td>
</tr>
<tr>
<td>\uhhhh</td>
<td>The character with hexadecimal value 0xhhhh</td>
</tr>
<tr>
<td>\t</td>
<td>The tab character ('\u0009')</td>
</tr>
<tr>
<td>\n</td>
<td>The newline (line feed) character \u000A</td>
</tr>
<tr>
<td>\r</td>
<td>The carriage-return character \u000D</td>
</tr>
<tr>
<td>\f</td>
<td>The form-feed character ('\u000C')</td>
</tr>
<tr>
<td>\a</td>
<td>The alert (bell) character ('\u0007')</td>
</tr>
<tr>
<td>\e</td>
<td>The escape character ('\u001B')</td>
</tr>
<tr>
<td>\<operator></td>
<td>Any operator symbol escaped (use as non-operator token)</td>
</tr>
<tr>
<th colspan="2">Special tokens</th>
</tr>
<tr>
<td>^</td>
<td>Start of input.</td>
</tr>
<tr>
<td>$</td>
<td>End of input.</td>
</tr>
<tr>
<td>.</td>
<td>Any character (wild card).</td>
</tr>
<tr>
<th colspan="2">Character Sets and Ranges</th>
</tr>
<tr>
<td>[abc]</td>
<td>a, b, or c (simple class)</td>
</tr>
<tr>
<td>[^abc]</td>
<td>Any character except a, b, or c (negation)</td>
</tr>
<tr>
<td>[a-z]</td>
<td>a through z, inclusive (range)</td>
</tr>
<tr>
<td>[a-zA-Z]</td>
<td>a through z or A through Z, inclusive (range)</td>
</tr>
<tr>
<td>[^a-zA-Z]</td>
<td>Any character except a through z and A through Z (range and negation)</td>
</tr>
<!--
<tr>
<td>[a-d[m-p]]</td>
<td>a through d, or m through p: [a-dm-p] (union)</td>
</tr>
-->
<tr>
<td>[a-z&&[def]]</td>
<td>d, e, or f (intersection)</td>
</tr>
<tr>
<td>[a-z&&[^bc]]</td>
<td>a through z, except for b and c: [ad-z] (subtraction)</td>
</tr>
<tr>
<td>[a-z&&[^m-p]]</td>
<td>a through z, and not m through p: [a-lq-z](subtraction)</td>
</tr>
<tr>
<th colspan="2">Predefined Character Classes</th>
</tr>
<tr>
<td>\d</td>
<td>A digit: [0-9]</td>
</tr>
<tr>
<td>\D</td>
<td>A non-digit: [^0-9]</td>
</tr>
<tr>
<td>\s</td>
<td>A whitespace character: [\t\n\x0B\f\r]</td>
</tr>
<tr>
<td>\S</td>
<td>A non-whitespace character: [^\s]</td>
</tr>
<tr>
<td>\w</td>
<td>A word character: [a-zA-Z_0-9]</td>
</tr>
<tr>
<td>\W</td>
<td>A non-word character: [^\w]</td>
</tr>
</table>
<br/>
<br/>
<br/>
<b>To do:</b><br/>
<ul>
<li>--</li>
</ul>
</td>
</tr>
</table>
<br/>
</body>
</html>