Hilbert II - Version 0.03.04

org.qedeq.kernel.parser
Class MathParser

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

public abstract class MathParser
extends Object

Parse term or formula data into Terms.

Version:
$Revision: 1.5 $

Constructor Summary
MathParser(MementoTextInput input, List operators)
          Constructor.
 
Method Summary
protected  void clearMark()
          Forget last remembered position.
 boolean eof()
          Are there still any characters to read?
protected abstract  boolean eot(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(String token)
          Get an operator for that token.
protected  List getOperators()
           
protected abstract  List getOperators(String token)
          Get operators for that token.
 int getRewindStackSize()
          Get rewind stack size.
 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  String readToken()
          Read next token from input and move reading position.
protected  long rewindPosition()
          Rewind to previous marked position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathParser

public MathParser(MementoTextInput input,
                  List operators)
Constructor.

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

getOperators

protected final 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(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 List getOperators(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 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 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(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.

Hilbert II - Version 0.03.04

©left GNU General Public Licence
All Rights Reserved.