blob: dc3c98be66fc141755b5ce8c1c213f024aa5c436 (
plain)
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
|
// globals
var EPSILON = '~';
var NEXTSTATE = 0;
var EMPTYSYMBOL = '%';
var ALPHABET = 'abc'+EMPTYSYMBOL;
var REDELIMITER = '$';
var regex = 'a*b|b*a' //(a|b)*'//'a(a|b)*a');
var word = 'ba'; //'abba';
function main() {
// parse regular expression
var parser = new RegexParser();
var nfa = parser.parse(regex);
document.write('Parsing: '+parser.getErrorMessage()+'<br />');
// simulate
var simulator = new NfaSimulator(nfa);
document.write('\''+word+'\' in <em>L</em>: '+simulator.simulate(word)+'<br />');
// nfa -> dfa
document.write('<pre>');
var dfa = new Nfa2Dfa(nfa);
var ttable = dfa.do();
document.write('</pre>');
//drawGraph()
}
|