itec.minicompiler
Class FirstSet

java.lang.Object
  extended byitec.minicompiler.FirstSet
All Implemented Interfaces:
ConstantsInterface

public class FirstSet
extends java.lang.Object
implements ConstantsInterface

The FirstSet implements the FIRST-Sets of all non-terminals in the grammar. As a most adequate structure the HashSet is used to implement a particular FIRST-Set of a non-terminal. In a Hashtable the several HashSets are brought together.

To get the several FIRST-Sets the algorithm in the book

"COMPILERS Principles, Techniques and Tools" by Aho, Sethi, Ullmann
was used. The entries were mainly calculated by hand.

Version:
1.0 (29.09.2004)
Author:
Stefan Leitner, Stefan Schauer

Field Summary
private  java.util.Hashtable first
          The overall structure of all the FIRST-Sets.
 
Fields inherited from interface itec.minicompiler.ConstantsInterface
ACTUALPARAMETERS, AND, ARRAY, ARRAYTYPE, ASSIGNMENT, BECOMES, BEGIN, COLON, COMMA, CONST, DECLARATIONS, DIV, DO, ELSE, ELSIF, EMPTY, END, EPSILON, EQUAL, ERR_EXP_ARRAY, ERR_EXP_BECOMES, ERR_EXP_COLON, ERR_EXP_COMMA, ERR_EXP_DO, ERR_EXP_END, ERR_EXP_EQUAL, ERR_EXP_IDENT, ERR_EXP_IF, ERR_EXP_LPAREN, ERR_EXP_MODULE, ERR_EXP_OF, ERR_EXP_PERIOD, ERR_EXP_PROCEDURE, ERR_EXP_RBRAK, ERR_EXP_RECORD, ERR_EXP_REPEAT, ERR_EXP_RPAREN, ERR_EXP_SEMICOLON, ERR_EXP_THEN, ERR_EXP_UNTIL, ERR_EXP_WHILE, ERR_INV_FACTOR, ERR_INV_STATEMENT, ERR_INV_TYPE, ERR_INVALID_CHARACTER, ERR_NOT_EXP_DECLARATIONS, ERR_NOT_EXP_FACTOR, ERR_NOT_EXP_STATEMENT, ERR_NOT_EXP_TYPE, ERR_NOT_TERMINATED, ERR_NUMBER_TOO_HIGH, EXPRESSION, FACTOR, FIELDLIST, FORMALPARAMETERS, FPSECTION, GEQ, GREATER, IDENT, IDENTLIST, IF, IFSTATEMENT, KEYWORD, LBRAK, LEQ, LESS, LPAREN, MINICOMP, MINUS, MOD, MODULE, NOT, NOTEQUAL, NUMBER, OF, OR, PERIOD, PLUS, PROCEDURE, PROCEDUREBODY, PROCEDURECALL, PROCEDUREDECLARATION, PROCEDUREHEADING, RBRAK, RECORD, RECORDTYPE, REPEAT, REPEATSTATEMENT, RPAREN, SELECTOR, SEMICOLON, SIMPLEEXPRESSION, SINGLE, STATEMENT, STATEMENTSEQUENCE, TERM, THEN, TIMES, TYP, TYPE, UNTIL, VAR, WHILE, WHILESTATEMENT
 
Constructor Summary
FirstSet()
          Initialize the FIRST-Set of each particular non-terminal in the grammar.
 
Method Summary
 java.util.HashSet getFirst(int nonTerminal)
          Return the FIRST-Set of a nonTerminal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

first

private java.util.Hashtable first
The overall structure of all the FIRST-Sets. The Hashtable contains the FIRST-Sets of the different non-terminals. Each entry is a HashSet as implementation of a FIRST-Set.

Constructor Detail

FirstSet

public FirstSet()
Initialize the FIRST-Set of each particular non-terminal in the grammar. The values of the several HashSets were mainly calculated by hand and checked for errors with JCoco.

Method Detail

getFirst

public java.util.HashSet getFirst(int nonTerminal)
Return the FIRST-Set of a nonTerminal.

Parameters:
nonTerminal - A non-terminal in the grammar
Returns:
A HashSet implementing the FIRST-Set of nonTerminal