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

Field Summary
protected  java.util.List<TokenFilter> filters
          List of token filters
protected  java.util.List<GrammarMatcher> gm
          List of grammar matchers
protected  Jep jep
          The Jep instance associated with this parser
protected  java.util.List<TokenMatcher> m
          List of token matchers
protected  Tokenizer tk
          Tokenizer
 
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()
           
 JepComponent getLightWeightInstance()
          Gets a light-weight instance suitable for using in multiple threads.
 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
 

Field Detail

m

protected java.util.List<TokenMatcher> m
List of token matchers


filters

protected java.util.List<TokenFilter> filters
List of token filters


gm

protected java.util.List<GrammarMatcher> gm
List of grammar matchers


tk

protected transient Tokenizer tk
Tokenizer


jep

protected transient Jep jep
The Jep instance associated with this parser

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. Performs the scan, filter and parse steps on the stream provided.

Specified by:
parse in interface Parser
Parameters:
stream - the input stream to read from
Returns:
root 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()

getLightWeightInstance

public JepComponent getLightWeightInstance()
Description copied from interface: JepComponent
Gets a light-weight instance suitable for using in multiple threads.

Specified by:
getLightWeightInstance in interface JepComponent
Returns:
null


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