diff Implab/Formats/TextScanner.cs @ 182:76e8f2ba12b8 ref20160224

pretty print DFA, the minimization is still buggy
author cin
date Thu, 24 Mar 2016 18:52:10 +0300
parents b2b6a6640aa3
children
line wrap: on
line diff
--- a/Implab/Formats/TextScanner.cs	Thu Mar 24 03:54:46 2016 +0300
+++ b/Implab/Formats/TextScanner.cs	Thu Mar 24 18:52:10 2016 +0300
@@ -53,29 +53,24 @@
             tag = null;
 
             var maxSymbol = alphabet.Length - 1;
-
+            int next;
             do {
                 // after the next chunk is read the offset in the buffer may change
                 int pos = m_bufferOffset + m_tokenLength;
-
+                next = state;
                 while (pos < m_bufferSize) {
                     var ch = m_buffer[pos];
 
-                    try {
-                    var next = dfa[state, ch > maxSymbol ? AutomatonConst.UNCLASSIFIED_INPUT : alphabet[ch]];
+                    next = dfa[next, ch > maxSymbol ? AutomatonConst.UNCLASSIFIED_INPUT : alphabet[ch]];
                     
                     if (next == AutomatonConst.UNREACHABLE_STATE)
                         break;
-
+                 
                     state = next;
-                    }catch {
-                        throw;
-                    }
                     pos++;
                 }
-
                 m_tokenLength = pos - m_bufferOffset;
-            } while (state != AutomatonConst.UNREACHABLE_STATE && Feed());
+            } while (next != AutomatonConst.UNREACHABLE_STATE && Feed());
 
             m_tokenOffset = m_bufferOffset;
             m_bufferOffset += m_tokenLength;
@@ -150,7 +145,7 @@
         }
 
         public void CopyTokenTo(char[] buffer, int offset) {
-            m_buffer.CopyTo(buffer, offset);
+            Array.Copy(m_buffer, m_tokenOffset,buffer, offset, m_tokenLength);
         }
 
         public void CopyTokenTo(StringBuilder sb) {