Example #1
0
		public CGTContent(CGTStructure structure)
		{
			if (structure.Records.Count < 3)
				throw new CGTContentException("File does not have enough records");
			parameters = new Parameters(structure.Records[0]);
			tableCounts = new TableCounts(structure.Records[1]);
			
			int initialStatesStart = 2;
			int characterSetStart = initialStatesStart + 1;
			int symbolStart = characterSetStart + TableCounts.CharacterSetTable;
			int ruleStart = symbolStart + TableCounts.SymbolTable;
			int dfaStart = ruleStart + TableCounts.RuleTable;
			int lalrStart = dfaStart + TableCounts.DFATable;
			int specifiedRecordCount = lalrStart + TableCounts.LALRTable;
			if (structure.Records.Count != specifiedRecordCount)
				throw new CGTContentException("Invalid number of records");
			
			characterSetTable =	new CharacterSetTable(structure,
													  characterSetStart,
													  TableCounts.CharacterSetTable);
			symbolTable = new SymbolTable(structure,
				symbolStart,
				TableCounts.SymbolTable);

			ruleTable = new RuleTable(structure,
									  ruleStart,
									  TableCounts.RuleTable);
			initialStates = new InitialStatesRecord(structure.Records[initialStatesStart]);
			dfaStateTable = new DFAStateTable(structure,dfaStart,TableCounts.DFATable);
			lalrStateTable = new LALRStateTable(structure,lalrStart,TableCounts.LALRTable);
		}
Example #2
0
        public CGTContent(CGTStructure structure)
        {
            if (structure.Records.Count < 3)
            {
                throw new CGTContentException("File does not have enough records");
            }
            parameters  = new Parameters(structure.Records[0]);
            tableCounts = new TableCounts(structure.Records[1]);

            int initialStatesStart   = 2;
            int characterSetStart    = initialStatesStart + 1;
            int symbolStart          = characterSetStart + TableCounts.CharacterSetTable;
            int ruleStart            = symbolStart + TableCounts.SymbolTable;
            int dfaStart             = ruleStart + TableCounts.RuleTable;
            int lalrStart            = dfaStart + TableCounts.DFATable;
            int specifiedRecordCount = lalrStart + TableCounts.LALRTable;

            if (structure.Records.Count != specifiedRecordCount)
            {
                throw new CGTContentException("Invalid number of records");
            }

            characterSetTable = new CharacterSetTable(structure, characterSetStart, TableCounts.CharacterSetTable);
            symbolTable       = new SymbolTable(structure, symbolStart, TableCounts.SymbolTable);

            ruleTable      = new RuleTable(structure, ruleStart, TableCounts.RuleTable);
            initialStates  = new InitialStatesRecord(structure.Records[initialStatesStart]);
            dfaStateTable  = new DFAStateTable(structure, dfaStart, TableCounts.DFATable);
            lalrStateTable = new LALRStateTable(structure, lalrStart, TableCounts.LALRTable);
        }