Class Parser

java.lang.Object
  |
  +--Parser

public class Parser
extends java.lang.Object

A parser for RETRAN-2.

Version:
2.0 Oct 2003
Author:
Paul Bailes, modified from another parser by Phil Cook, Ned Martin, modified 02-Nov-2003

Field Summary
static int COMMA_SYM
           
private  java.lang.String currentName
           
private  int currentNumber
           
private  int currentSym
           
static int DIV_SYM
           
static int ELSE_SYM
           
static int EQEQ_SYM
           
static int EQUAL_SYM
           
static int GE_SYM
           
static int GT_SYM
           
static int IF_SYM
           
static int LE_SYM
           
static int LEFT_PAREN_SYM
           
static int LT_SYM
           
static int MINUS_SYM
           
static int MULT_SYM
           
static int NAME_SYM
           
static int NEQ_SYM
           
static int NO_SYM
           
static int NUMBER_SYM
           
static int PLUS_SYM
           
static int RIGHT_PAREN_SYM
           
private  Scanner scanner
           
static int SEMICOLON_SYM
           
static int THEN_SYM
           
static int WHERE_SYM
           
 
Constructor Summary
Parser(java.io.BufferedReader br)
          Constructs a Parser.
 
Method Summary
private  boolean getNextSym()
           
private  Expression parseArithExpression()
          Parses an ArithExpression
private  Declaration parseDeclaration()
          Parses a Declaration
private  DeclarationList parseDeclarationList()
          Parses a DeclarationList
private  Expression parseExpression()
          Parses an Expression
private  ExpressionList parseExpressionList()
          Parses an ExpressionList
private  Expression parseFactor()
          Parses a Factor
private  NameList parsenameList()
          Parses a nameList
 Program parseProgram()
          Parses the input and returns Program object corresponding to the input parsed.
private  Expression parseTerm()
          Parses a Term
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

NO_SYM

public static final int NO_SYM

LEFT_PAREN_SYM

public static final int LEFT_PAREN_SYM

RIGHT_PAREN_SYM

public static final int RIGHT_PAREN_SYM

NUMBER_SYM

public static final int NUMBER_SYM

NAME_SYM

public static final int NAME_SYM

EQUAL_SYM

public static final int EQUAL_SYM

SEMICOLON_SYM

public static final int SEMICOLON_SYM

IF_SYM

public static final int IF_SYM

THEN_SYM

public static final int THEN_SYM

ELSE_SYM

public static final int ELSE_SYM

WHERE_SYM

public static final int WHERE_SYM

PLUS_SYM

public static final int PLUS_SYM

MINUS_SYM

public static final int MINUS_SYM

MULT_SYM

public static final int MULT_SYM

DIV_SYM

public static final int DIV_SYM

LT_SYM

public static final int LT_SYM

GT_SYM

public static final int GT_SYM

EQEQ_SYM

public static final int EQEQ_SYM

NEQ_SYM

public static final int NEQ_SYM

LE_SYM

public static final int LE_SYM

GE_SYM

public static final int GE_SYM

COMMA_SYM

public static final int COMMA_SYM

currentSym

private int currentSym

currentNumber

private int currentNumber

currentName

private java.lang.String currentName

scanner

private Scanner scanner
Constructor Detail

Parser

public Parser(java.io.BufferedReader br)
Constructs a Parser.
Parameters:
br - BufferedReader to use as input stream
Method Detail

getNextSym

private boolean getNextSym()

parseProgram

public Program parseProgram()
Parses the input and returns Program object corresponding to the input parsed.

parseExpression

private Expression parseExpression()
Parses an Expression

parseArithExpression

private Expression parseArithExpression()
Parses an ArithExpression

parseTerm

private Expression parseTerm()
Parses a Term

parseFactor

private Expression parseFactor()
Parses a Factor

parseExpressionList

private ExpressionList parseExpressionList()
Parses an ExpressionList

parseDeclarationList

private DeclarationList parseDeclarationList()
Parses a DeclarationList

parseDeclaration

private Declaration parseDeclaration()
Parses a Declaration

parsenameList

private NameList parsenameList()
Parses a nameList