Class RegExpTree


  • public abstract class RegExpTree
    extends java.lang.Object
    An AST for JavaScript regular expressions.
    • Constructor Summary

      Constructors 
      Constructor Description
      RegExpTree()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void appendDebugInfo​(java.lang.StringBuilder sb)  
      protected abstract void appendSourceCode​(java.lang.StringBuilder sb)
      Appends this regular expression source to the given buffer.
      abstract java.util.List<? extends RegExpTree> children()
      The children of this node.
      abstract boolean containsAnchor()
      True if the regular expression contains an anchor : ^ or $.
      abstract boolean equals​(java.lang.Object o)  
      boolean hasCapturingGroup()
      True if the regular expression contains capturing groups.
      abstract int hashCode()  
      abstract boolean isCaseSensitive()
      True if the presence or absence of an "i" flag would change the meaning of this regular expression.
      static boolean matchesWholeInput​(RegExpTree t, java.lang.String flags)
      True if, but not necessarily always when the, given regular expression must match the whole input or none of it.
      abstract int numCapturingGroups()
      The number of capturing groups.
      static RegExpTree parseRegExp​(java.lang.String pattern, java.lang.String flags)
      Parses a regular expression to an AST.
      abstract RegExpTree simplify​(java.lang.String flags)
      Returns a simpler regular expression that is semantically the same assuming the given flags.
      java.lang.String toDebugString()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RegExpTree

        public RegExpTree()
    • Method Detail

      • simplify

        public abstract RegExpTree simplify​(java.lang.String flags)
        Returns a simpler regular expression that is semantically the same assuming the given flags.
        Parameters:
        flags - Regular expression flags, e.g. "igm".
      • isCaseSensitive

        public abstract boolean isCaseSensitive()
        True if the presence or absence of an "i" flag would change the meaning of this regular expression.
      • containsAnchor

        public abstract boolean containsAnchor()
        True if the regular expression contains an anchor : ^ or $.
      • hasCapturingGroup

        public final boolean hasCapturingGroup()
        True if the regular expression contains capturing groups.
      • numCapturingGroups

        public abstract int numCapturingGroups()
        The number of capturing groups.
      • children

        public abstract java.util.List<? extends RegExpTree> children()
        The children of this node.
      • appendSourceCode

        protected abstract void appendSourceCode​(java.lang.StringBuilder sb)
        Appends this regular expression source to the given buffer.
      • appendDebugInfo

        protected abstract void appendDebugInfo​(java.lang.StringBuilder sb)
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toDebugString

        public final java.lang.String toDebugString()
      • equals

        public abstract boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public abstract int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • parseRegExp

        public static RegExpTree parseRegExp​(java.lang.String pattern,
                                             java.lang.String flags)
        Parses a regular expression to an AST.
        Parameters:
        pattern - The foo From /foo/i.
        flags - The i From /foo/i.
      • matchesWholeInput

        public static boolean matchesWholeInput​(RegExpTree t,
                                                java.lang.String flags)
        True if, but not necessarily always when the, given regular expression must match the whole input or none of it.