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)
      Creates a new parse rule for given name
    • ParseRule

      public ParseRule(ParseRule.Op anOp, ParseRule aPR)
      Creates a new parse rule for given name
    • ParseRule

      public ParseRule(ParseRule.Op anOp, ParseRule aPR1, ParseRule aPR2)
      Creates a new parse rule for given op and child rules.
    • ParseRule

      public ParseRule(String aName, ParseRule.Op anOp, ParseRule aPR)
      Creates a new parse rule for given name, op and child rule.
    • ParseRule

      public ParseRule(String aName, ParseRule.Op anOp, ParseRule aPR1, ParseRule aPR2)
      Creates a new parse rule for given name, op and child rules.
  • Method Details

    • getName

      public String getName()
      Returns rule name.
    • setName

      public 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

      public 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

      public void setLookAheadCount(int aValue)
      Sets the look ahead count.
    • getRule

      public ParseRule getRule(String aName)
      Returns a rule with given name.
    • or

      public ParseRule or(String aPattern)
      Adds an Or rule to this rule with given pattern.
    • or

      public ParseRule or(String aPattern, char aCount)
      Adds an Or rule to this rule with given count and pattern.
    • or

      public ParseRule or(ParseRule aRule)
      Adds an Or rule to this rule with given rule.
    • or

      public ParseRule or(ParseRule aRule, char aCount)
      Adds an Or rule to this rule with given rule.
    • and

      public ParseRule and(String aPattern)
      Adds an And rule to this rule with given pattern.
    • and

      public ParseRule and(String aPattern, char aCount)
      Adds an And rule to this rule with given count and pattern.
    • and

      public ParseRule and(ParseRule aRule)
      Adds an And rule to this rule with given rule.
    • and

      public ParseRule and(ParseRule aRule, char aCount)
      Adds an And rule to this rule with given rule.
    • toString

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