Class StringTreeBuilder

  • All Implemented Interfaces:
    TreeBuilder

    public class StringTreeBuilder
    extends java.lang.Object
    implements TreeBuilder
    A tree builder that returns the serialized tree as a string.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void endAmbiguity​(int id, int leftExtent, int rightExtent)
      Called at the end of an ambiguity that is not marked by a single nonterminal.
      void endNonterminal​(NonterminalSymbol symbol, java.util.Map<java.lang.String,​java.lang.String> attributes, int leftExtent, int rightExtent)
      Called when a nonterminal ends.
      void endTree​(boolean ambiguous, boolean absolutelyAmbiguous, boolean infinitelyAmbiguous)
      Called last, when construction finishes.
      java.lang.String getTree()  
      void startAmbiguity​(int id, int leftExtent, int rightExtent)
      Called at the start of an ambiguity that is not marked by a single nonterminal.
      void startNonterminal​(NonterminalSymbol symbol, java.util.Map<java.lang.String,​java.lang.String> attributes, int leftExtent, int rightExtent)
      Called when a new nonterminal begins.
      void startTree()
      Called first, when construction begins.
      void token​(Token token, java.util.Map<java.lang.String,​java.lang.String> attributes, int leftExtent, int rightExtent)
      Called when a terminal occurs.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringTreeBuilder

        public StringTreeBuilder()
      • StringTreeBuilder

        public StringTreeBuilder​(boolean debugAttributes)
    • Method Detail

      • getTree

        public java.lang.String getTree()
      • startTree

        public void startTree()
        Description copied from interface: TreeBuilder
        Called first, when construction begins.
        Specified by:
        startTree in interface TreeBuilder
      • endTree

        public void endTree​(boolean ambiguous,
                            boolean absolutelyAmbiguous,
                            boolean infinitelyAmbiguous)
        Description copied from interface: TreeBuilder
        Called last, when construction finishes.
        Specified by:
        endTree in interface TreeBuilder
        Parameters:
        ambiguous - was the parse ambiguous?
        absolutelyAmbiguous - is the graph ambiguous?
        infinitelyAmbiguous - is the graph infinitely ambiguous?
      • startNonterminal

        public void startNonterminal​(NonterminalSymbol symbol,
                                     java.util.Map<java.lang.String,​java.lang.String> attributes,
                                     int leftExtent,
                                     int rightExtent)
        Description copied from interface: TreeBuilder
        Called when a new nonterminal begins.
        Specified by:
        startNonterminal in interface TreeBuilder
        Parameters:
        symbol - The symbol.
        attributes - Its attributes.
        leftExtent - The starting position in the input.
        rightExtent - The ending position in the input.
      • endNonterminal

        public void endNonterminal​(NonterminalSymbol symbol,
                                   java.util.Map<java.lang.String,​java.lang.String> attributes,
                                   int leftExtent,
                                   int rightExtent)
        Description copied from interface: TreeBuilder
        Called when a nonterminal ends.
        Specified by:
        endNonterminal in interface TreeBuilder
        Parameters:
        symbol - The symbol.
        attributes - Its attributes.
        leftExtent - The starting position in the input.
        rightExtent - The ending position in the input.
      • token

        public void token​(Token token,
                          java.util.Map<java.lang.String,​java.lang.String> attributes,
                          int leftExtent,
                          int rightExtent)
        Description copied from interface: TreeBuilder
        Called when a terminal occurs.
        Specified by:
        token in interface TreeBuilder
        Parameters:
        token - The terminal token.
        attributes - Its attributes.
        leftExtent - The starting position in the input.
        rightExtent - The ending position in the input.
      • startAmbiguity

        public void startAmbiguity​(int id,
                                   int leftExtent,
                                   int rightExtent)
        Description copied from interface: TreeBuilder
        Called at the start of an ambiguity that is not marked by a single nonterminal.

        The ambiguity id will distinguish this ambiguity from any other ambiguity. The numbers are not sequential or guaranteed stable across parses.

        Specified by:
        startAmbiguity in interface TreeBuilder
        Parameters:
        id - The ambiguity id.
        leftExtent - The starting position in the input.
        rightExtent - The ending position in the input.
      • endAmbiguity

        public void endAmbiguity​(int id,
                                 int leftExtent,
                                 int rightExtent)
        Description copied from interface: TreeBuilder
        Called at the end of an ambiguity that is not marked by a single nonterminal.
        Specified by:
        endAmbiguity in interface TreeBuilder
        Parameters:
        id - The ambiguity id.
        leftExtent - The starting position in the input.
        rightExtent - The ending position in the input.