com.edugility.objexj.parser
Class Parser

java.lang.Object
  extended by com.edugility.objexj.parser.Parser

public class Parser
extends Object

A parser that consumes Tokens from a PostfixTokenizer.

Author:
Laird Nelson

Constructor Summary
Parser()
          Creates a new Parser.
 
Method Summary
<T> Program<T>
parse(PostfixTokenizer tokenizer)
          Receives a feed of Tokens from the supplied PostfixTokenizer and parses them into a Program.
<T> Program<T>
parse(String input)
          Constructs a new PostfixTokenizer and associated Reader machinery and then calls the parse(PostfixTokenizer) method and returns its result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parser

public Parser()
Creates a new Parser.

Method Detail

parse

public <T> Program<T> parse(String input)
                 throws IOException,
                        ParseException
Constructs a new PostfixTokenizer and associated Reader machinery and then calls the parse(PostfixTokenizer) method and returns its result.

Type Parameters:
T - the type of Object the resulting Program will work with
Parameters:
input - the String representation of a Program; must not be null
Throws:
IllegalArgumentException - if input is null
IOException - if the String could not be read
ParseException
See Also:
parse(PostfixTokenizer), PostfixTokenizer

parse

public <T> Program<T> parse(PostfixTokenizer tokenizer)
                 throws ParseException
Receives a feed of Tokens from the supplied PostfixTokenizer and parses them into a Program.

This method never returns null.

Type Parameters:
T - the type of Object the returned Program will be capable of matching
Parameters:
tokenizer - the PostfixTokenizer that provides a token stream; must not be null
Returns:
a non-null Program
Throws:
IllegalArgumentException - if tokenizer is null
ParseException


Copyright © 2012–2013, Laird Nelson. All rights reserved.