Exemplo n.º 1
0
        /// <summary>
        /// Read DFA state information.
        /// </summary>
        /// <param name="context"></param>
        private void ReadDfaState(LoadContext context)
        {
            DfaState dfaState     = GetDfaState(context.ReadIntegerEntry());
            Symbol   acceptSymbol = null;
            bool     acceptState  = context.ReadBoolEntry();

            if (acceptState)
            {
                acceptSymbol = symbolTable[context.ReadIntegerEntry()];
            }
            else
            {
                context.ReadIntegerEntry();                 // Skip the entry.
            }
            context.ReadEmptyEntry();
            // Read DFA edges
            DfaEdge[] edges = new DfaEdge[context.EntryCount / 3];
            for (int i = 0; i < edges.Length; i++)
            {
                edges[i] = new DfaEdge(context.ReadIntegerEntry(), context.ReadIntegerEntry());
                context.ReadEmptyEntry();
            }
            // Create DFA state and store it in DFA state table
            dfaState.Initialize(acceptSymbol, edges);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Read DFA state information.
        /// </summary>
        private void ReadDfaStates()
        {
            int    index        = ReadInt16Entry();
            Symbol acceptSymbol = null;
            bool   acceptState  = ReadBoolEntry();

            if (acceptState)
            {
                acceptSymbol = m_symbolTable[ReadInt16Entry()];
            }
            else
            {
                ReadInt16Entry();                  // Skip the entry.
            }
            ReadEmptyEntry();

            // Read DFA edges
            DfaEdge[] edges = new DfaEdge[m_entryCount / 3];
            for (int i = 0; i < edges.Length; i++)
            {
                edges[i].CharSetIndex = ReadInt16Entry();
                edges[i].TargetIndex  = ReadInt16Entry();
                ReadEmptyEntry();
            }

            // Create DFA state and store it in DFA state table
            ObjectMap transitionVector = CreateDfaTransitionVector(edges);
            DfaState  dfaState         = new DfaState(index, acceptSymbol, transitionVector);

            m_dfaStateTable[index] = dfaState;
        }
Exemplo n.º 3
0
		/// <summary>
		/// Read DFA state information.
		/// </summary>
		/// <param name="context"></param>
		private void ReadDfaState(LoadContext context) {
			DfaState dfaState = GetDfaState(context.ReadIntegerEntry());
			Symbol acceptSymbol = null;
			bool acceptState = context.ReadBoolEntry();
			if (acceptState) {
				acceptSymbol = symbolTable[context.ReadIntegerEntry()];
			} else {
				context.ReadIntegerEntry(); // Skip the entry.
			}
			context.ReadEmptyEntry();
			// Read DFA edges
			DfaEdge[] edges = new DfaEdge[context.EntryCount/3];
			for (int i = 0; i < edges.Length; i++) {
				edges[i] = new DfaEdge(context.ReadIntegerEntry(), context.ReadIntegerEntry());
				context.ReadEmptyEntry();
			}
			// Create DFA state and store it in DFA state table
			dfaState.Initialize(acceptSymbol, edges);
		}
Exemplo n.º 4
0
		/// <summary>
		/// Creates the DFA state transition vector.
		/// </summary>
		/// <param name="edges">Array of automata edges.</param>
		/// <returns>Hashtable with the transition information.</returns>
		private ObjectMap CreateDfaTransitionVector(DfaEdge[] edges)
		{
			var transitionVector = new ObjectMap();
			for (Int32 i = edges.Length - 1; i >= 0; i--)
			{
				String charSet = m_CharSetTable[edges[i].CharSetIndex];
				foreach (Char ch in charSet)
				{
					transitionVector[ch] = edges[i].TargetIndex;
				}
			}
			return transitionVector;
		}
Exemplo n.º 5
0
		/// <summary>
		/// Read DFA state information.
		/// </summary>
		private void ReadDfaStates(BinaryReader reader)
		{
			Int32 index = ReadInt16Entry(reader);
			Boolean acceptState = ReadBoolEntry(reader);
			Int16 acceptIndex = ReadInt16Entry(reader);
			ReadEmptyEntry(reader);

			// Read DFA edges
			var edges = new DfaEdge[m_EntryCount / 3];
			for (Int32 i = 0; i < edges.Length; i++)
			{
				edges[i] = new DfaEdge(ReadInt16Entry(reader), ReadInt16Entry(reader));
				ReadEmptyEntry(reader);
			}

			// Create DFA state and store it in DFA state table
			Symbol acceptSymbol = acceptState ? m_SymbolTable[acceptIndex] : null;
			ObjectMap transitionVector = CreateDfaTransitionVector(edges);
			var dfaState = new DfaState(index, acceptSymbol, transitionVector);
			m_DfaStateTable[index] = dfaState;
		}
Exemplo n.º 6
0
        /// <summary>
        /// Read DFA state information.
        /// </summary>
        private void ReadDfaStates()
        {
            int index = ReadInt16Entry();
            Symbol acceptSymbol = null;
            bool acceptState = ReadBoolEntry();
            if (acceptState)
            {
                acceptSymbol = m_symbolTable[ReadInt16Entry()];
            }
            else
            {
                ReadInt16Entry(); // Skip the entry.
            }
            ReadEmptyEntry();

            // Read DFA edges
            DfaEdge[] edges = new DfaEdge[m_entryCount/3];
            for (int i = 0; i < edges.Length; i++)
            {
                edges[i].CharSetIndex = ReadInt16Entry();
                edges[i].TargetIndex = ReadInt16Entry();
                ReadEmptyEntry();
            }

            // Create DFA state and store it in DFA state table
            ObjectMap transitionVector = CreateDfaTransitionVector(edges);
            DfaState dfaState = new DfaState(index, acceptSymbol, transitionVector);
            m_dfaStateTable[index] = dfaState;
        }
Exemplo n.º 7
0
 /// <summary>
 /// Creates the DFA state transition vector.
 /// </summary>
 /// <param name="edges">Array of automata edges.</param>
 /// <returns>Hashtable with the transition information.</returns>
 private ObjectMap CreateDfaTransitionVector(DfaEdge[] edges)
 {
     ObjectMap transitionVector = new ObjectMap();
     for (int i = edges.Length; --i >= 0;)
     {
         string charSet = m_charSetTable[edges[i].CharSetIndex];
         for (int j = 0; j < charSet.Length; j++)
         {
             transitionVector[charSet[j]] = edges[i].TargetIndex;
         }
     }
     return transitionVector;
 }