Package net.emustudio.edigen.nodes
Class Subrule
- java.lang.Object
-
- net.emustudio.edigen.nodes.TreeNode
-
- net.emustudio.edigen.nodes.Subrule
-
public class Subrule extends TreeNode
A subrule is a rule name contained in a variant.
-
-
Constructor Summary
Constructors Constructor Description Subrule(java.lang.String name)Constructs the subrule with an unspecified length.Subrule(java.lang.String name, java.lang.Integer length, Pattern prePattern)Constructs the subrule with the specified length and pre-pattern.Subrule(java.lang.String name, Pattern prePattern)Constructs the subrule with the specified pre-pattern.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(Visitor visitor)Accepts the visitor.booleanequals(java.lang.Object o)java.lang.StringgetFieldName()Returns the field name which should be generated for this subrule.java.lang.IntegergetLength()Returns the subrule length.java.lang.StringgetName()Returns the subrule name, as obtained from the input.PatterngetPrePattern()Returns the forward pattern information.RulegetRule()Returns the rule to which this subrule refers.java.lang.IntegergetStart()Returns the starting offset relative to the variant start.inthashCode()SubrulesetRule(Rule rule)Specifies to which rule this subrule refers.voidsetStart(int start)Sets the starting offset relative to the variant start.TreeNodeshallowCopy()java.lang.StringtoString()Returns a string representation of the object containing the rule name and optionally start and length.-
Methods inherited from class net.emustudio.edigen.nodes.TreeNode
acceptChildren, addChild, addChildren, addChildren, childCount, copy, dump, getChild, getChildren, getLine, getParent, remove, setLine
-
-
-
-
Constructor Detail
-
Subrule
public Subrule(java.lang.String name)
Constructs the subrule with an unspecified length. Can be located only at the end of a variant.- Parameters:
name- the subrule name
-
Subrule
public Subrule(java.lang.String name, Pattern prePattern)Constructs the subrule with the specified pre-pattern. Can be located only at the end of a variant.- Parameters:
name- the subrule nameprePattern- the forward pattern information
-
Subrule
public Subrule(java.lang.String name, java.lang.Integer length, Pattern prePattern)Constructs the subrule with the specified length and pre-pattern.- Parameters:
name- the subrule namelength- the subrule lengthprePattern- the forward pattern information
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the subrule name, as obtained from the input.- Returns:
- the subrule name
-
getStart
public java.lang.Integer getStart()
Returns the starting offset relative to the variant start. The result is null if it is not yet determined.- Returns:
- the starting offset, in bits
-
setStart
public void setStart(int start)
Sets the starting offset relative to the variant start.- Parameters:
start- the starting offset, in bits
-
getLength
public java.lang.Integer getLength()
Returns the subrule length. The result is null for a rule with an unspecified length.- Returns:
- the length in bits
-
getRule
public Rule getRule()
Returns the rule to which this subrule refers. The result is null if the name was not yet resolved or the subrule does not refer to any rule.- Returns:
- the rule object or null
-
getPrePattern
public Pattern getPrePattern()
Returns the forward pattern information.- Returns:
- the pre-pattern
-
setRule
public Subrule setRule(Rule rule)
Specifies to which rule this subrule refers. Used during name resolution.- Parameters:
rule- the rule object- Returns:
- this
-
getFieldName
public java.lang.String getFieldName()
Returns the field name which should be generated for this subrule.- Returns:
- the field name
-
accept
public void accept(Visitor visitor) throws SemanticException
Accepts the visitor.- Overrides:
acceptin classTreeNode- Parameters:
visitor- the visitor object- Throws:
SemanticException- depends on the specific visitor
-
toString
public java.lang.String toString()
Returns a string representation of the object containing the rule name and optionally start and length.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
shallowCopy
public TreeNode shallowCopy()
- Specified by:
shallowCopyin classTreeNode
-
-