summaryrefslogtreecommitdiff
path: root/javascripts/Nfa.js
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2010-05-18 08:52:24 +0200
committerPatrick Simianer <p@simianer.de>2010-05-18 08:52:24 +0200
commitb90042ebc1f37fa5f911df54ce0d3827da074892 (patch)
tree271ffd81ccf00888380b8b578d9bf238d8e4387b /javascripts/Nfa.js
parentec3f1801c258dbba07dfccbd9864f9b2de0bfae6 (diff)
major
Diffstat (limited to 'javascripts/Nfa.js')
-rw-r--r--javascripts/Nfa.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/javascripts/Nfa.js b/javascripts/Nfa.js
index 1fd1991..12ffe23 100644
--- a/javascripts/Nfa.js
+++ b/javascripts/Nfa.js
@@ -3,12 +3,12 @@
*
*/
function Nfa(symbol) {
- this.startState;
- this.acceptingState;
-
+ this.startState = null;
+ this.acceptingState = null;
+
if (symbol) {
- this.setStartState(new State(symbol));
- this.setAcceptingState(new State(false));
+ this.setStartState(new NfaState(symbol));
+ this.setAcceptingState(new NfaState(false));
this.getStartState().setFollowUp(0, this.getAcceptingState());
}
}
@@ -18,15 +18,16 @@ Nfa.prototype.setStartState = function(s) { this.startState = s }
Nfa.prototype.getAcceptingState = function() { return this.acceptingState }
Nfa.prototype.setAcceptingState = function(s) { this.acceptingState = s }
-Nfa.prototype.concatenation = function(nfa) {
+Nfa.prototype.concat = function(nfa) {
this.getAcceptingState().setFollowUp(0, nfa.getStartState());
this.setAcceptingState(nfa.getAcceptingState());
- return this;
+
+ return this;
}
Nfa.prototype.union = function(nfa) {
- var s = new State();
- var t = new State();
+ var s = new NfaState();
+ var t = new NfaState();
s.setFollowUp(0, this.getStartState());
s.setFollowUp(1, nfa.getStartState());
@@ -36,11 +37,13 @@ Nfa.prototype.union = function(nfa) {
this.setStartState(s);
this.setAcceptingState(t);
+
+ return this;
}
-Nfa.prototype.star = function() {
- var s = new State();
- var t = new State();
+Nfa.prototype.kleene = function() {
+ var s = new NfaState();
+ var t = new NfaState();
s.setFollowUp(0, this.getStartState());
s.setFollowUp(1, t);
@@ -53,4 +56,3 @@ Nfa.prototype.star = function() {
return this;
}
-