slogo.parser
Class ExpressionParser

java.lang.Object
  extended by slogo.parser.ExpressionParser
All Implemented Interfaces:
Parser

public class ExpressionParser
extends java.lang.Object
implements Parser

This is a recursive descent parser for parsing expressions using the standard grammar for expressions (follows).

 expression ::= term
            ::= term + expression
            ::= term - expression
 term       ::= factor
            ::= factor * term
            ::= factor / term
 factor     ::= number
            ::= - factor
            ::= ( expression )
 
This class has undergone basic though not thorough testing

Author:
Owen Astrachan

Field Summary
private  SLogoParser myParser
           
private static ExpressionParser ourInstance
           
 
Constructor Summary
private ExpressionParser()
          Parse expressions from a parser
 
Method Summary
static ExpressionParser getInstance()
           
 GrammarElement parse(SLogoParser ep)
           
protected  GrammarElement parseExpression()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ourInstance

private static ExpressionParser ourInstance

myParser

private SLogoParser myParser
Constructor Detail

ExpressionParser

private ExpressionParser()
Parse expressions from a parser

Method Detail

getInstance

public static ExpressionParser getInstance()

parse

public GrammarElement parse(SLogoParser ep)
Specified by:
parse in interface Parser

parseExpression

protected GrammarElement parseExpression()