Package snap.parse
Class ParseRule
java.lang.Object
snap.parse.ParseRule
A class to represent a parse rule.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected ParseRule
protected ParseRule
protected int
protected ParseRule.Op
protected String
-
Constructor Summary
ConstructorDescriptionConstructor.Creates a new parse rule for given nameParseRule
(String aName, ParseRule.Op anOp, ParseRule aPR) Creates a new parse rule for given name, op and child rule.ParseRule
(String aName, ParseRule.Op anOp, ParseRule aPR1, ParseRule aPR2) Creates a new parse rule for given name, op and child rules.ParseRule
(ParseRule.Op anOp, ParseRule aPR) Creates a new parse rule for given nameParseRule
(ParseRule.Op anOp, ParseRule aPR1, ParseRule aPR2) Creates a new parse rule for given op and child rules. -
Method Summary
Modifier and TypeMethodDescriptionAdds an And rule to this rule with given pattern.Adds an And rule to this rule with given count and pattern.Adds an And rule to this rule with given rule.Adds an And rule to this rule with given rule.Returns the first child.Returns the second child.ParseHandler<?>
Returns the handler for this rule.getId()
Returns an identifier string for this rule - either the name or the pattern or null.int
Returns the look ahead count.getName()
Returns rule name.getOp()
Returns the op.Returns the rule pattern if simple pattern.Returns a rule with given name.boolean
Returns whether rule is anonymous - true if rule has no name and no pattern.boolean
Returns whether rule is look ahead.boolean
Returns whether rule is optional.Adds an Or rule to this rule with given pattern.Adds an Or rule to this rule with given count and pattern.Adds an Or rule to this rule with given rule.Adds an Or rule to this rule with given rule.setHandler
(ParseHandler<?> aHandler) Sets the handler for this rule.void
setLookAheadCount
(int aValue) Sets the look ahead count.void
Sets rule name.setPattern
(String anPattern) Sets the rule pattern if simple pattern.toString()
Returns a string representation.
-
Field Details
-
_op
-
_child0
-
_child1
-
_pattern
-
_lookAheadCount
protected int _lookAheadCount
-
-
Constructor Details
-
ParseRule
public ParseRule()Constructor. -
ParseRule
Creates a new parse rule for given name -
ParseRule
Creates a new parse rule for given name -
ParseRule
Creates a new parse rule for given op and child rules. -
ParseRule
Creates a new parse rule for given name, op and child rule. -
ParseRule
Creates a new parse rule for given name, op and child rules.
-
-
Method Details
-
getName
Returns rule name. -
setName
Sets rule name. -
getId
Returns an identifier string for this rule - either the name or the pattern or null. -
getOp
Returns the op. -
getChild0
Returns the first child. -
getChild1
Returns the second child. -
getPattern
Returns the rule pattern if simple pattern. -
setPattern
Sets the rule pattern if simple pattern. -
isAnonymous
public boolean isAnonymous()Returns whether rule is anonymous - true if rule has no name and no pattern. -
isOptional
public boolean isOptional()Returns whether rule is optional. -
getHandler
Returns the handler for this rule. -
setHandler
Sets the handler for this rule. -
isLookAhead
public boolean isLookAhead()Returns whether rule is look ahead. -
getLookAheadCount
public int getLookAheadCount()Returns the look ahead count. -
setLookAheadCount
public void setLookAheadCount(int aValue) Sets the look ahead count. -
getRule
Returns a rule with given name. -
or
Adds an Or rule to this rule with given pattern. -
or
Adds an Or rule to this rule with given count and pattern. -
or
Adds an Or rule to this rule with given rule. -
or
Adds an Or rule to this rule with given rule. -
and
Adds an And rule to this rule with given pattern. -
and
Adds an And rule to this rule with given count and pattern. -
and
Adds an And rule to this rule with given rule. -
and
Adds an And rule to this rule with given rule. -
toString
Returns a string representation.
-