| java.lang.Object xtc.parser.Result
All known Subclasses: xtc.parser.SemanticValue, xtc.parser.ParseError, xtc.parser.PackratParser,
Result | abstract public class Result (Code) | | The superclass of all parser results.
author: Robert Grimm version: $Revision: 1.22 $ |
Field Summary | |
final public int | index The index into the parser's memoization table. |
Constructor Summary | |
public | Result(int index) Create a new result with the specified index. |
Method Summary | |
abstract public SemanticValue | createValue(Object value, ParseError error) Create a semantic value based on this result. | abstract public boolean | hasValue() Determine whether this result has a value. | abstract public boolean | hasValue(String s) Determine whether this result has the specified string value.
The specified value must not be null .
Parameters: s - The string value. | abstract public boolean | hasValueIgnoreCase(String s) Determine whether this result has the specified string value,
ignoring case. | abstract public ParseError | parseError() Get the parse error for this result. | abstract public ParseError | select(ParseError error) Select the more specific parse error. | abstract public T | semanticValue() Get the semantic value for this result. |
index | final public int index(Code) | | The index into the parser's memoization table.
|
Result | public Result(int index)(Code) | | Create a new result with the specified index.
Parameters: index - The index. |
createValue | abstract public SemanticValue createValue(Object value, ParseError error)(Code) | | Create a semantic value based on this result. A straight-forward
implementation of this method simply creates a new semantic
value, using the specified actual value, this result's index,
and the specified parse error:
public SemanticValue value(Object value, ParseError error) {
return new SemanticValue(value, index, error);
}
However, for a result that already is a semantic value, a
more sophisticated implementation can avoid creating a new
semantic value if the specified actual value and parse error are
identical to those for this result.
Parameters: value - The actual value. Parameters: error - The embedded parse error. throws: IllegalStateException - Signals that this result is aparse error. |
hasValue | abstract public boolean hasValue()(Code) | | Determine whether this result has a value.
true if this result has a value. |
hasValue | abstract public boolean hasValue(String s)(Code) | | Determine whether this result has the specified string value.
The specified value must not be null .
Parameters: s - The string value. true if this result has the specified stringvalue. |
hasValueIgnoreCase | abstract public boolean hasValueIgnoreCase(String s)(Code) | | Determine whether this result has the specified string value,
ignoring case. The specified value must not be
null .
Parameters: s - The string value. true if this result has the specified stringvalue, ignoring case. |
parseError | abstract public ParseError parseError()(Code) | | Get the parse error for this result. If the result does not
represent a parse error or does not have an embedded parse error,
this method must return the
ParseError.DUMMY dummy parseerror .
The parse error for this result. |
select | abstract public ParseError select(ParseError error)(Code) | | Select the more specific parse error. This method compares this
result (i.e., either the parse error or the embedded parse error)
with the specified parse error and returns the one representing
the longer parse.
Parameters: error - The error. The more specific parse error. |
semanticValue | abstract public T semanticValue()(Code) | | Get the semantic value for this result.
The semantic value for this result. throws: IllegalStateException - Signals that this result does not have a semantic value. |
|
|