com.singularsys.jep.configurableparser
Class ConfigurableParser

java.lang.Object
  extended by com.singularsys.jep.configurableparser.ConfigurableParser
All Implemented Interfaces:
JepComponent, Parser, java.io.Serializable

public class ConfigurableParser
extends java.lang.Object
implements Parser

A configurable parser.

See Also:
Serialized Form

Constructor Summary
  ConfigurableParser()
          Create the standard configurable parser.
protected ConfigurableParser(boolean empty)
          Create a configurable parser with an empty lists of matchers.
  ConfigurableParser(java.util.List<TokenMatcher> tokenMatchers, java.util.List<TokenFilter> filters, java.util.List<GrammarMatcher> grammarMatchers)
          Create a parser with the specified set of matchers.
 
Method Summary
 Node continueParse()
          Parse the next equation from existing stream.
 java.util.Iterator<Token> filter(java.util.List<Token> input)
          Filters the tokens to remove whitespace etc.
 java.util.List<GrammarMatcher> getGrammarMatchers()
           
 java.util.List<TokenFilter> getTokenFilters()
           
 java.util.List<TokenMatcher> getTokenMatchers()
           
 void init(Jep jep)
          Initialize the component.
 Node parse(java.util.Iterator<Token> it)
          Perform the syntax analysis stage.
 Node parse(java.io.Reader stream)
          Parse a single equation.
 void restart(java.io.Reader stream)
          Load a new stream to read from.
 java.util.List<Token> scan()
          Scan next equations from an existing stream.
 java.util.List<Token> scan(java.io.Reader stream)
          Scan the input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurableParser

public ConfigurableParser()
Create the standard configurable parser.


ConfigurableParser

protected ConfigurableParser(boolean empty)
Create a configurable parser with an empty lists of matchers. For use by sub-classes which can use the getTokenMatchers(), getTokenFilters() and getGrammarMatchers() methods to get the appropriate lists.

Parameters:
empty -

ConfigurableParser

public ConfigurableParser(java.util.List<TokenMatcher> tokenMatchers,
                          java.util.List<TokenFilter> filters,
                          java.util.List<GrammarMatcher> grammarMatchers)
Create a parser with the specified set of matchers.

Parameters:
tokenMatchers - a list of TokenMatchers which to match the input sequence.
filters - a list of filters to remove whitespace etc.
grammarMatchers - matchers for syntactical elements
Method Detail

init

public void init(Jep jep)
Description copied from interface: JepComponent
Initialize the component. This methods is called whenever a component is added to Jep. Hence it allows components to keep track of the other components they may rely on.

Specified by:
init in interface JepComponent
Specified by:
init in interface Parser
Parameters:
jep - the current Jep instance

parse

public Node parse(java.io.Reader stream)
           throws ParseException
Parse a single equation.

Specified by:
parse in interface Parser
Parameters:
stream - the input stream to read from
Returns:
top node of the expression
Throws:
ParseException

restart

public void restart(java.io.Reader stream)
Load a new stream to read from.

Specified by:
restart in interface Parser
See Also:
continueParse()

continueParse

public Node continueParse()
                   throws ParseException
Parse the next equation from existing stream.

Specified by:
continueParse in interface Parser
Returns:
top node of the expression
Throws:
ParseException
See Also:
restart(java.io.Reader)

scan

public java.util.List<Token> scan(java.io.Reader stream)
                           throws ParseException
Scan the input. Just perform the tokenizing stage. Not for normal use.

Parameters:
stream -
Returns:
a list of tokens, including white space and comments.
Throws:
ParseException

scan

public java.util.List<Token> scan()
                           throws ParseException
Scan next equations from an existing stream. Not for normal use.

Returns:
List of tokens, including white space and comments.
Throws:
ParseException

filter

public java.util.Iterator<Token> filter(java.util.List<Token> input)
                                 throws ParseException
Filters the tokens to remove whitespace etc. Not for normal use.

Parameters:
input -
Returns:
and iterator with the filtered tokens
Throws:
ParseException

parse

public Node parse(java.util.Iterator<Token> it)
           throws ParseException
Perform the syntax analysis stage. Not for normal used.

Parameters:
it - an iterator with a list of tokens
Returns:
top node of the parsed expression
Throws:
ParseException

getGrammarMatchers

public java.util.List<GrammarMatcher> getGrammarMatchers()

getTokenMatchers

public java.util.List<TokenMatcher> getTokenMatchers()

getTokenFilters

public java.util.List<TokenFilter> getTokenFilters()


Copyright © 2007 Singular Systems http://www.singularsys.com/jep