diff c/regexParser/transition.cc @ 111:1d30f70702df pairPro

add determinize.cc and transition.cc
author masa
date Sat, 21 Nov 2015 18:04:25 +0900
parents
children ec485345daf9
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/c/regexParser/transition.cc	Sat Nov 21 18:04:25 2015 +0900
@@ -0,0 +1,34 @@
+#include "transition.h"
+
+TransitionPtr createTransition(CharClassPtr cc, BitVectorPtr state) {
+    TransitionPtr transition = (TransitionPtr)malloc(sizeof(Transition));
+    transition->condition = cc;
+    transition->nextState = state;
+    return transition;
+}
+
+TransitionPtr appendTransition0(TransitionPtr x, TransitionPtr y) {
+    TransitionPtr x0 = x;
+    for(;;) {
+        if (x->next == NULL) {
+            x->next = y
+            return x0;
+        }
+    }
+    return x;
+}
+
+TransitionPtr appendTransition(TransitionPtr x, TransitionPtr y) {
+    TransitionPtr x0 = createTransition(x->condition, x->nextState);
+    TransitionPtr x1 = x0;
+    for(;;) {
+        if (x->next == NULL) {
+            x1->next = y;
+            return x0;
+        }
+        x = x->next;
+        x1->next = createTransition(x->condition, x->nextState);
+        x1 = x1->next;
+    }
+    return x0;
+}