ch.uzh.ifi.attempto.chartparser
Class ChartParser

java.lang.Object
  extended by ch.uzh.ifi.attempto.chartparser.ChartParser

public class ChartParser
extends java.lang.Object

This is a chart parser (concretely an Earley parser) fully implemented in Java. However, there is a Prolog-based format called "Codeco" that can be transformed into Java (at compile time).

Author:
Tobias Kuhn
See Also:
Grammar

Constructor Summary
ChartParser(Grammar grammar)
          Creates a new chart parser for the given grammar.
 
Method Summary
 void addToken(Terminal... token)
          Adds the token to the token sequence and makes one more parsing step to process it.
 void addTokens(java.util.List<Terminal> tokens)
          Adds the tokens to the token sequence and processes them.
 void debug(boolean debug)
          This method can be used to switch on/off debug mode (default is off).
 java.util.List<Restriction> getNextTokenRestrictions()
          This method looks ahead and returns the restrictions at least one of which the next token has to fulfill.
 java.util.List<Terminal[]> getTokens()
          Returns the current token sequence.
 void removeAllTokens()
          Removes all tokens in the current token sequence and resets the chart.
 void removeToken()
          Removes the last token and reverts the last parsing step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChartParser

public ChartParser(Grammar grammar)
Creates a new chart parser for the given grammar. The grammar must not be changed afterwards.

Parameters:
grammar - The grammar to be used by the chart parser.
Method Detail

debug

public void debug(boolean debug)
This method can be used to switch on/off debug mode (default is off). In debug mode, messages about the actions of the chart parser are printed onto the standard error device.

Parameters:
debug - true to switch on debug mode or false to switch it off.

addToken

public void addToken(Terminal... token)
Adds the token to the token sequence and makes one more parsing step to process it. If several tokens are given then these tokens are treated in a parallel way representing a token that can have multiple forms.

Parameters:
token - The token to be added to the token sequence.

addTokens

public void addTokens(java.util.List<Terminal> tokens)
Adds the tokens to the token sequence and processes them.

Parameters:
tokens - The tokens to be added to the token sequence.

removeToken

public void removeToken()
Removes the last token and reverts the last parsing step.


removeAllTokens

public void removeAllTokens()
Removes all tokens in the current token sequence and resets the chart.


getTokens

public java.util.List<Terminal[]> getTokens()
Returns the current token sequence.

Returns:
The current token sequence.

getNextTokenRestrictions

public java.util.List<Restriction> getNextTokenRestrictions()
This method looks ahead and returns the restrictions at least one of which the next token has to fulfill.

Returns:
The restrictions.


Copyright 2008-2009, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch)