|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--diva.sketch.parser2d.Parser2D
A simple CFG parser for graph grammars. This is currently the most trivial and inefficient strictly bottom-up implementation, just to see how much we inefficiency can get away with in parsing graph grammars.
The parser successively applies a set of rules ot the input constituent set, and if the rules match a subset of the constituents, it substitutes the left side of the rule for the matching constituents in the right side. This forms a new constuent set which is then passed to the parser again along with the remaining constituents. This chain continues until there are no rule matches. If the constituent at the end of the chain is a successful parse (definition of which is probably application-dependent) this is returned as part of the results.
Constructor Summary | |
Parser2D(Rule[] grammar)
Construct a new parser with the specified grammar rules. |
|
Parser2D(java.lang.String grammarURL)
Construct a new parser with the grammar rules specified in the file at the given URL (can be a relative file too). |
Method Summary | |
void |
clearMemoization()
Clear the cached (memoized) results. |
static java.util.List |
completeParses(java.util.List parses)
Return the subset of this list of parses that are complete parses (i.e. |
static void |
debug(java.lang.String s)
Debugging output. |
static boolean |
isComplete(ConstituentSet cs)
Return whether or not this parse is complete (has no loose ends). |
java.util.List |
parse(ConstituentSet in)
Parse the given constituent set (initially terminals) into a coherent parse tree. |
protected java.util.List |
parseNoMemoize(ConstituentSet in)
Parse the given constituent set (initially terminals) into a coherent parse tree. |
static java.util.List |
removeDuplicates(java.util.List in)
Return the given list without duplicates. |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public Parser2D(Rule[] grammar)
public Parser2D(java.lang.String grammarURL) throws java.lang.Exception
Method Detail |
public static void debug(java.lang.String s)
public java.util.List parse(ConstituentSet in)
protected java.util.List parseNoMemoize(ConstituentSet in)
public void clearMemoization()
public static java.util.List removeDuplicates(java.util.List in)
public static java.util.List completeParses(java.util.List parses)
public static boolean isComplete(ConstituentSet cs)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |