|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.uzh.ifi.attempto.chartparser.ChartParser
public class ChartParser
This is a chart parser (concretely an Earley parser) that implements the predictive parser interface.
Grammar
Constructor Summary | |
---|---|
ChartParser(Grammar grammar,
java.lang.String startCategoryName)
Creates a new chart parser for the given grammar. |
|
ChartParser(Grammar grammar,
java.lang.String startCategoryName,
java.util.List<Nonterminal> context)
Creates a new chart parser for the given grammar. |
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. |
void |
debug(boolean debug)
This method can be used to switch on/off debug mode (default is off). |
java.util.Set<CPAbstractOption> |
getAbstractOptions()
This method returns a set of abstract options describing the possible next tokens at the end position in an abstract way. |
java.util.Set<CPAbstractOption> |
getAbstractOptions(int position)
This method returns a set of abstract options describing the possible next tokens at the given position in an abstract way. |
java.util.List<FeatureMap> |
getBackwardReferences()
Returns a list of feature maps that show how the backward references at the end of the token sequence can be resolved. |
java.util.List<FeatureMap> |
getBackwardReferences(int pos)
Return a list of feature maps that show how the backward references at the given position in the text can be resolved. |
java.util.Set<CPConcreteOption> |
getConcreteOptions()
This method returns a set of concrete options describing the possible next tokens at the end position in a concrete way. |
java.util.Set<CPConcreteOption> |
getConcreteOptions(int position)
This method returns a set of concrete options describing the possible next tokens at the given position in a concrete way. |
CPNextTokenOptions |
getNextTokenOptions()
This method returns the options for the next token to be added at the end. |
CPNextTokenOptions |
getNextTokenOptions(int position)
This methods shows the possible tokens that could be used to continue the text at the given position. |
ParseTree |
getParseTree()
Returns the parse tree of the parsed text if it is a complete statement according to the given grammar and start category. |
ParseTree |
getParseTree(java.lang.String categoryName)
Returns the parse tree of the parsed text if it is a complete statement according to the given grammar and category. |
int |
getReference()
This method should return the token number to which the last token refers, if it is a reference like "it". |
int |
getReference(int pos)
This method returns the token number to which the token at the given position refers, if it is a reference. |
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 |
setDynamicLexicon(DynamicLexicon dynLexicon)
Sets the dynamic lexicon. |
void |
setPositionIdentifierPrefix(java.lang.String prefix)
Sets the prefix for the position identifiers that are assigned to the variables of the position operator "#". |
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 |
---|
public ChartParser(Grammar grammar, java.lang.String startCategoryName, java.util.List<Nonterminal> context)
grammar
- The grammar to be used by the chart parser.startCategoryName
- The name of the start category.context
- A list of forward references and scope openers that define the context.public ChartParser(Grammar grammar, java.lang.String startCategoryName)
grammar
- The grammar to be used by the chart parser.startCategoryName
- The name of the start category.Method Detail |
---|
public void debug(boolean debug)
debug
- true to switch debug mode on, or false to switch it off.public void setDynamicLexicon(DynamicLexicon dynLexicon)
dynLexicon
- The dynamic lexicon.public void setPositionIdentifierPrefix(java.lang.String prefix)
prefix
- The new prefix.public void addToken(java.lang.String token)
PredictiveParser
addToken
in interface PredictiveParser
token
- The new token to be added.public void addTokens(java.util.List<java.lang.String> tokens)
PredictiveParser
addTokens
in interface PredictiveParser
tokens
- The tokens to be added.public void removeToken()
PredictiveParser
removeToken
in interface PredictiveParser
public void removeAllTokens()
PredictiveParser
removeAllTokens
in interface PredictiveParser
public void setTokens(java.util.List<java.lang.String> tokens)
PredictiveParser
setTokens
in interface PredictiveParser
tokens
- The tokens.public java.util.List<java.lang.String> getTokens()
PredictiveParser
getTokens
in interface PredictiveParser
public int getTokenCount()
PredictiveParser
getTokenCount
in interface PredictiveParser
public int getReference(int pos)
pos
- The position of the token for which the reference should be returned.
public int getReference()
PredictiveParser
getReference
in interface PredictiveParser
public java.util.List<FeatureMap> getBackwardReferences(int pos)
pos
- The position of the backward reference.
public java.util.List<FeatureMap> getBackwardReferences()
public boolean isComplete()
PredictiveParser
isComplete
in interface PredictiveParser
public ParseTree getParseTree(java.lang.String categoryName)
categoryName
- The category name.
public ParseTree getParseTree()
public CPNextTokenOptions getNextTokenOptions(int position)
position
- The position at which the possible next tokens should be found.
public CPNextTokenOptions getNextTokenOptions()
PredictiveParser
getNextTokenOptions
in interface PredictiveParser
public java.util.Set<CPAbstractOption> getAbstractOptions(int position)
position
- The position at which the possible next tokens should be found.
public java.util.Set<CPAbstractOption> getAbstractOptions()
public java.util.Set<CPConcreteOption> getConcreteOptions(int position)
position
- The position at which the possible next tokens should be found.
public java.util.Set<CPConcreteOption> getConcreteOptions()
public boolean isPossibleNextToken(java.lang.String token)
PredictiveParser
isPossibleNextToken
in interface PredictiveParser
token
- The token.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |