Package snap.parse

Class ParseRule

java.lang.Object
snap.parse.ParseRule

public class ParseRule extends Object
A class to represent a parse rule.
  • Field Details

    • _op

      protected ParseRule.Op _op
    • _child0

      protected ParseRule _child0
    • _child1

      protected ParseRule _child1
    • _pattern

      protected String _pattern
    • _lookAheadCount

      protected int _lookAheadCount
  • Constructor Details

    • ParseRule

      public ParseRule()
      Constructor.
    • ParseRule

      public ParseRule(String aName)
      Constructor for given name
    • ParseRule

      public ParseRule(ParseRule.Op anOp, ParseRule aPR)
      Constructor for op and child rule
    • ParseRule

      public ParseRule(ParseRule.Op anOp, ParseRule aPR1, ParseRule aPR2)
      Constructor for given op and child rules.
    • ParseRule

      public ParseRule(String aName, ParseRule.Op anOp, ParseRule aPR1, ParseRule aPR2)
      Constructor for given name, op and child rules.
  • Method Details

    • getName

      public String getName()
      Returns rule name.
    • setName

      protected void setName(String aName)
      Sets rule name.
    • getId

      public String getId()
      Returns an identifier string for this rule - either the name or the pattern or null.
    • getOp

      public ParseRule.Op getOp()
      Returns the op.
    • getChild0

      public ParseRule getChild0()
      Returns the first child.
    • getChild1

      public ParseRule getChild1()
      Returns the second child.
    • getPattern

      public String getPattern()
      Returns the rule pattern if simple pattern.
    • setPattern

      protected ParseRule setPattern(String anPattern)
      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

      public ParseHandler<?> getHandler()
      Returns the handler for this rule.
    • setHandler

      public ParseRule setHandler(ParseHandler<?> aHandler)
      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

      protected void setLookAheadCount(int aValue)
      Sets the look ahead count.
    • toString

      public String toString()
      Returns a string representation.
      Overrides:
      toString in class Object