|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpobs.PDirective
Maintains all state information for the POBS framework such as parser policies. Directive also provides a number of support methods which helps parsers implement the directives, it is ultimately up to the implementor of a parser to handle the directives, this class cannot force parsers to abide by the directives. All parsers supplied with POBS obey these directives fully.
Field Summary | |
static byte |
FIRST
|
static byte |
LONGEST
|
static byte |
SHORTEST
|
Constructor Summary | |
PDirective()
Empty constructor with all set to default. |
|
PDirective(PObject skipper)
Construct a new object with a specified skipper. |
Method Summary | |
PMatch |
alternative(PMatch a,
PMatch b)
Determines the match of two matches based upon the alternatives directive. |
char |
convert(char character)
Converts a character based on whether the directive for case sensitivity is set. |
byte |
getAlternatives()
gets the alternatives mode used in this directive. |
PObject |
getSkipper()
gets the parser used in this directive for skipping. |
boolean |
isActions()
Checks whether actions are enabled for this PContext. |
boolean |
isCaseSensitive()
checks whether case sensitivity is enabled for this PContext. |
boolean |
isSkip()
Checks whether skipping is enabled for this PContext. |
void |
setActions(boolean actions)
Enables or disables actions for this PContext. |
void |
setAlternatives(byte alternatives)
Sets the alternatives mode for this PContext. |
void |
setCaseSensitive(boolean caseSensitive)
Enables or disables case sensitivity for this PContext. |
void |
setSkip(boolean skip)
Enables or disables skipping for this PContext. |
void |
setSkipper(PObject skipper)
Sets the parser to use for skipping. |
long |
skip(PScanner input,
long begin)
Support method for skipping. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final byte FIRST
public static final byte LONGEST
public static final byte SHORTEST
Constructor Detail |
public PDirective()
public PDirective(PObject skipper)
Method Detail |
public PMatch alternative(PMatch a, PMatch b)
a
- the first alternative (leftmost in parser)b
- the second alternative (rightmost in parser)public char convert(char character)
character
- the char to convert
public byte getAlternatives()
public PObject getSkipper()
PObject
public boolean isActions()
public boolean isCaseSensitive()
public boolean isSkip()
public void setActions(boolean actions)
actions
- true to enable actions.public void setAlternatives(byte alternatives)
alternatives
- either FIRST, LONGEST or SHORTEST alternatives.public void setCaseSensitive(boolean caseSensitive)
caseSensitive
- true to enable case sensitivitypublic void setSkip(boolean skip)
skip
- true to enable skippingpublic void setSkipper(PObject skipper)
parser
to use for skipping. This does not
enable skipping but merely specifies which skipper to use when skipping
is enabled.
skipper
- a parser to use for skippingpublic long skip(PScanner input, long begin)
iterator
and begin
position then add the returned length to it's own internal position
variable, there is no need for the parser implementer to check any of the
directives, this method will always return the expected result. Contrary
to instinct, skipping is not commonly implemented in terminal
parsers. Since skipping occurs between terminals, it needs only
to be implemented in those parsers which can parse sequences of (possibly
terminal) parsers such as and
PRepeat
.
input
- iterator in which to skipbegin
- location from which to start skipping
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |