Example #1
0
        /// <summary>
        /// Initializes a new automaton from the given binary stream
        /// </summary>
        /// <param name="reader">The binary stream to load from</param>
        public LRkAutomaton(BinaryReader reader)
        {
            ncols   = reader.ReadUInt16();
            nstates = reader.ReadUInt16();
            int nprod = reader.ReadUInt16();

            columns = new ColumnMap();
            for (int i = 0; i != ncols; i++)
            {
                columns.Add(reader.ReadUInt16(), i);
            }
            contexts = new LRContexts[nstates];
            for (int i = 0; i != nstates; i++)
            {
                contexts[i] = new LRContexts(reader);
            }
            table = new LRAction[nstates * ncols];
            for (int i = 0; i != nstates * ncols; i++)
            {
                table[i] = new LRAction(reader);
            }
            productions = new LRProduction[nprod];
            for (int i = 0; i != nprod; i++)
            {
                productions[i] = new LRProduction(reader);
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new automaton from the given binary stream
        /// </summary>
        /// <param name="reader">The binary stream to load from</param>
        public RNGLRAutomaton(BinaryReader reader)
        {
            axiom   = reader.ReadUInt16();
            ncols   = reader.ReadUInt16();
            nstates = reader.ReadUInt16();
            int nactions = (int)reader.ReadUInt32();
            int nprod    = reader.ReadUInt16();
            int nnprod   = reader.ReadUInt16();

            columns = new ColumnMap();
            for (int i = 0; i != ncols; i++)
            {
                columns.Add(reader.ReadUInt16(), i);
            }
            contexts = new LRContexts[nstates];
            for (int i = 0; i != nstates; i++)
            {
                contexts[i] = new LRContexts(reader);
            }
            table = new Cell[nstates * ncols];
            for (int i = 0; i != table.Length; i++)
            {
                table[i] = new Cell(reader);
            }
            actions = new LRAction[nactions];
            for (int i = 0; i != nactions; i++)
            {
                actions[i] = new LRAction(reader);
            }
            productions = new LRProduction[nprod];
            for (int i = 0; i != nprod; i++)
            {
                productions[i] = new LRProduction(reader);
            }
            nullables = new ushort[nnprod];
            for (int i = 0; i != nnprod; i++)
            {
                nullables[i] = reader.ReadUInt16();
            }
        }