/* PseudoCode Interpreted Language (PCIL): Part of the algoviz@vt collection of algorithm visualizations. Copyright (C) 2008 Brandon Malone, Frank Hadlock This file is part of the PseudoCode Interpreted Language. PseudoCode Interpreted Language is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. PseudoCode Interpreted Language is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with PseudoCode Interpreted Language. If not, see . */ /* * ParseTableCalculator.java * * Created on March 3, 2008, 1:36 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package syntacticanalysis; import java.util.ArrayList; import java.util.HashMap; /** * * @author Brandon */ public class ParseTableCalculator { /** Creates a new instance of ParseTableCalculator */ public ParseTableCalculator() { } /** * using the given rule signatures, construct the parse table */ public static void constructParseTable(Grammar grammar) { ArrayList rules = grammar.getRules(); grammar.parseTable = new HashMap(); /* for each of the rules */ for(int i=0; i signature = grammar.rulesSignature.get(i); for(GrammarToken token : signature) { ParseEntry entry = new ParseEntry((Terminal)token, (Nonterminal)lhs, i); grammar.parseTable.put(entry, rule); } } } }