Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ch.uzh.ifi.attempto.chartparser
Class ChartParser

    java.lang.Object
      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 format ("Attempto Chartparser Grammar Notation" or "ACGN") 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(java.lang.String token)` Adds the token to the token sequence and makes one more parsing step to process it.
`void` | `addTokens(java.util.List<java.lang.String> 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).
`boolean[]` | `getAccessiblePositions(java.lang.String nextToken)` Returns a boolean array that describes which of the tokens of the current token sequence are accessible (true) and which are not (false) for the given next token.
`java.util.List<Terminal>` | `getTokens()` Returns the current token sequence.
`java.util.List<Terminal>` | `nextTokens()` Returns all tokens that are allowed to follow the current token sequence according to the grammar.
`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(java.lang.String token)

  Adds the token to the token sequence and makes one more parsing step to process it.

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

### addTokens

    public void addTokens(java.util.List<java.lang.String> 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.

### nextTokens

    public java.util.List<Terminal> nextTokens()

  Returns all tokens that are allowed to follow the current token sequence according to the grammar.

  Returns:
    The possible next tokens.

### getAccessiblePositions

    public boolean[] getAccessiblePositions(java.lang.String nextToken)

  Returns a boolean array that describes which of the tokens of the current token sequence are accessible (true) and which are not (false) for the given next token.

  Parameters:
    `nextToken` - The next token for which the tokens should be checked for accessibility.
  Returns:
    A boolean array where each element stands for one token of the token sequence.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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