ch.uzh.ifi.attempto.acewiki.gf
Class GFPredictiveParser

java.lang.Object
  extended by ch.uzh.ifi.attempto.acewiki.gf.GFPredictiveParser
All Implemented Interfaces:
PredictiveParser

public class GFPredictiveParser
extends java.lang.Object
implements PredictiveParser

This is a predictive parser connecting to the JPGF implementation of GF.

Author:
Tobias Kuhn

Constructor Summary
GFPredictiveParser(GFGrammar gfGrammar, java.lang.String language)
          Creates a new parser object for the given language.
 
Method Summary
 void addToken(java.lang.String token)
          Adds the token to the end of the token sequence.
 void addTokens(java.util.List<java.lang.String> tokens)
          Adds the tokens to the token list.
 NextTokenOptions getNextTokenOptions()
          This method returns the options for the next token to be added at the end.
 int getReference()
          This method should return the token number to which the last token refers, if it is a reference like "it".
 int getTokenCount()
          Returns the number of tokens of the current (partial) text.
 java.util.List<java.lang.String> getTokens()
          Returns the current token sequence.
 boolean isComplete()
          Returns true if the current token sequence is a complete statement.
 boolean isPossibleNextToken(java.lang.String token)
          Returns whether the given token is a possible next token.
 void removeAllTokens()
          Removes all tokens in the current token sequence.
 void removeToken()
          Removes the last token.
 void setTokens(java.util.List<java.lang.String> tokens)
          Sets the given tokens.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GFPredictiveParser

public GFPredictiveParser(GFGrammar gfGrammar,
                          java.lang.String language)
Creates a new parser object for the given language.

Parameters:
gfGrammar - The grammar object.
language - The language.
Method Detail

addToken

public void addToken(java.lang.String token)
Description copied from interface: PredictiveParser
Adds the token to the end of the token sequence.

Specified by:
addToken in interface PredictiveParser
Parameters:
token - The new token to be added.

addTokens

public void addTokens(java.util.List<java.lang.String> tokens)
Description copied from interface: PredictiveParser
Adds the tokens to the token list.

Specified by:
addTokens in interface PredictiveParser
Parameters:
tokens - The tokens to be added.

removeToken

public void removeToken()
Description copied from interface: PredictiveParser
Removes the last token.

Specified by:
removeToken in interface PredictiveParser

removeAllTokens

public void removeAllTokens()
Description copied from interface: PredictiveParser
Removes all tokens in the current token sequence.

Specified by:
removeAllTokens in interface PredictiveParser

setTokens

public void setTokens(java.util.List<java.lang.String> tokens)
Description copied from interface: PredictiveParser
Sets the given tokens. Existing tokens are removed.

Specified by:
setTokens in interface PredictiveParser
Parameters:
tokens - The tokens.

getTokens

public java.util.List<java.lang.String> getTokens()
Description copied from interface: PredictiveParser
Returns the current token sequence.

Specified by:
getTokens in interface PredictiveParser
Returns:
The current token sequence.

getTokenCount

public int getTokenCount()
Description copied from interface: PredictiveParser
Returns the number of tokens of the current (partial) text.

Specified by:
getTokenCount in interface PredictiveParser
Returns:
The number of tokens.

getNextTokenOptions

public NextTokenOptions getNextTokenOptions()
Description copied from interface: PredictiveParser
This method returns the options for the next token to be added at the end.

Specified by:
getNextTokenOptions in interface PredictiveParser
Returns:
The options describing the possible next tokens.

isPossibleNextToken

public boolean isPossibleNextToken(java.lang.String token)
Description copied from interface: PredictiveParser
Returns whether the given token is a possible next token.

Specified by:
isPossibleNextToken in interface PredictiveParser
Parameters:
token - The token.
Returns:
true if the token is a possible next token.

isComplete

public boolean isComplete()
Description copied from interface: PredictiveParser
Returns true if the current token sequence is a complete statement.

Specified by:
isComplete in interface PredictiveParser
Returns:
true if the current token sequence is complete.

getReference

public int getReference()
Description copied from interface: PredictiveParser
This method should return the token number to which the last token refers, if it is a reference like "it". -1 should be returned if the last token is not a reference, or if reference resolution is not implemented.

Specified by:
getReference in interface PredictiveParser
Returns:
The token number to which the last token refers.


Copyright 2008-2012, AceWiki developers