org.qedeq.kernel.bo.parser
Class MathParser

java.lang.Object
  extended by org.qedeq.kernel.bo.parser.MathParser
Direct Known Subclasses:
AsciiMathParser, LatexMathParser, SimpleMathParser

public abstract class MathParser
extends java.lang.Object

Parse term or formula data into Terms.

Author:
Michael Meyling

Constructor Summary
MathParser()
          Constructor.
 
Method Summary
protected  void clearMark()
          Forget last remembered position.
 boolean eof()
          Are there still any characters to read?
protected abstract  boolean eot(java.lang.String token)
          Is this an end of term token?
protected  int getChar()
          Reads a single character and does not change the reading position.
protected abstract  Operator getOperator(java.lang.String token)
          Get an operator for that token.
protected  java.util.List getOperators()
           
protected abstract  java.util.List getOperators(java.lang.String token)
          Get operators for that token.
 int getRewindStackSize()
          Get rewind stack size.
 java.lang.String getToken()
          Read next token from input but don't move reading position.
protected  void markPosition()
          Remember current position.
protected  int readChar()
          Reads a single character and increments the reading position by one.
 Term readTerm()
          Reads (maximal possible) Term from input.
protected abstract  java.lang.String readToken()
          Read next token from input and move reading position.
protected  long rewindPosition()
          Rewind to previous marked position.
 void setParameters(MementoTextInput input, java.util.List operators)
          Set input source and defined parameters.
 void setParameters(java.lang.StringBuffer input, java.util.List operators)
          Set input source and defined parameters.
 void setParameters(java.lang.String input, java.util.List operators)
          Set input source and defined parameters.
 void setParameters(TextInput input, java.util.List operators)
          Set input source and defined parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathParser

public MathParser()
Constructor.

Method Detail

setParameters

public void setParameters(MementoTextInput input,
                          java.util.List operators)
Set input source and defined parameters.

Parameters:
input - Input source to parse.
operators - Operator list.

setParameters

public void setParameters(TextInput input,
                          java.util.List operators)
Set input source and defined parameters.

Parameters:
input - Input source to parse.
operators - Operator list.

setParameters

public void setParameters(java.lang.StringBuffer input,
                          java.util.List operators)
Set input source and defined parameters.

Parameters:
input - Input source to parse.
operators - Operator list.

setParameters

public void setParameters(java.lang.String input,
                          java.util.List operators)
Set input source and defined parameters.

Parameters:
input - Input source to parse.
operators - Operator list.

getOperators

protected final java.util.List getOperators()

readTerm

public final Term readTerm()
                    throws ParserException
Reads (maximal possible) Term from input.

Returns:
Read term.
Throws:
ParserException - Parsing failed.

getOperator

protected abstract Operator getOperator(java.lang.String token)
Get an operator for that token. If there are more than one possibilities the first matching is returned.

Parameters:
token - Get an operator for this token.
Returns:
Operator. Might be null.

getOperators

protected abstract java.util.List getOperators(java.lang.String token)
Get operators for that token. If there are more than one possibilities all matching are returned.

Parameters:
token - Get operators for this token.
Returns:
Operators. Might be null.

readToken

protected abstract java.lang.String readToken()
Read next token from input and move reading position. A token is a recognized character sequence. A token is no elementary whitespace. Also a dosn't start or end with elementary whitespace.

Returns:
Token read, is null if end of data reached.

getToken

public final java.lang.String getToken()
Read next token from input but don't move reading position. A token is a recognised character sequence. A token is no elementary whitespace. Also a dosn't start or end with elementary whitespace.

Returns:
Token read, is null if end of data reached.

markPosition

protected final void markPosition()
Remember current position.


rewindPosition

protected final long rewindPosition()
Rewind to previous marked position. Also clears the mark.

Returns:
Current position before pop.

clearMark

protected final void clearMark()
Forget last remembered position.


getChar

protected final int getChar()
Reads a single character and does not change the reading position.

Returns:
character read, if there are no more chars Character.MAX_VALUE is returned

readChar

protected final int readChar()
Reads a single character and increments the reading position by one.

Returns:
character read, if there are no more chars Character.MAX_VALUE is returned

eot

protected abstract boolean eot(java.lang.String token)
Is this an end of term token?

Parameters:
token - Check this token.
Returns:
Is this an end of term token.

eof

public final boolean eof()
Are there still any characters to read?

Returns:
Anything left for reading further?

getRewindStackSize

public final int getRewindStackSize()
Get rewind stack size.

Returns:
Rewind stack size.


Copyright © 2014. All Rights Reserved.