Add support for epsilon symbols
diff --git a/datokenizer.go b/datokenizer.go
index 5868a36..fe57dde 100644
--- a/datokenizer.go
+++ b/datokenizer.go
@@ -523,25 +523,36 @@
t := 1 // Start position
chars := []rune(input)
i := 0
+ var a int
+ var tu int
+ var ok bool
+
// fmt.Println("Length of string is", len(chars))
for ; i < len(chars); i++ {
- a, ok := tok.sigma[chars[i]]
+ a, ok = tok.sigma[chars[i]]
// Support identity symbol if char not in sigma
if !ok && IDENTITY != -1 {
fmt.Println("IDENTITY symbol", chars[i], "->", IDENTITY)
a = IDENTITY
}
- tu := t
+ tu = t
CHECK:
t = tok.get_base(tu) + a
if t > tok.get_check(1) || tok.get_check(t) != tu {
fmt.Println("Match is not fine!", t, "and", tok.get_check(t), "vs", tu)
// Try again with unknown symbol, in case identity failed
- if !ok && a == IDENTITY {
- a = UNKNOWN
- goto CHECK
+ if ok {
+ if a == IDENTITY {
+ fmt.Println("UNKNOWN symbol", chars[i], "->", UNKNOWN)
+ a = UNKNOWN
+ goto CHECK
+ } else if a == UNKNOWN {
+ fmt.Println("EPSILON symbol", chars[i], "->", EPSILON)
+ a = EPSILON
+ goto CHECK
+ }
}
break
} else if tok.get_base(t) < 0 {
@@ -557,12 +568,34 @@
return false
}
- fmt.Println("Hmm...", tok.get_check(tok.get_base(t)+FINAL), "-", t)
+ // fmt.Println("Hmm...", tok.get_check(tok.get_base(t)+FINAL), "-", t)
+FINALCHECK:
if tok.get_check(tok.get_base(t)+FINAL) == t {
return true
}
- return false
+
+ // if a != EPSILON {
+ // EPSILONCHECK:
+ tu = t
+ a = EPSILON
+
+ t = tok.get_base(tu) + a
+ if t > tok.get_check(1) || tok.get_check(t) != tu {
+ fmt.Println("xMatch is not fine!", t, "and", tok.get_check(t), "vs", tu)
+ return false
+ } else if tok.get_base(t) < 0 {
+ // Move to representative state
+ t = -1 * tok.get_base(t)
+ goto FINALCHECK
+ }
+ goto FINALCHECK
+ // return true
+ /*
+ }
+
+ return false
+ */
}
// In the final realization, the states can only have 30 bits: