Class SymbolNode

    • Constructor Detail

      • SymbolNode

        public SymbolNode​(SymbolNode parent,
                          int character)
        Constructs a SymbolNode with the given parent, representing the given character.
        Parameters:
        parent - This node's parent
        character - This node's associated character.
    • Method Detail

      • ensureChildWithChar

        public SymbolNode ensureChildWithChar​(int value)
                                       throws Exception
        Find or create a child for the given character.
        Parameters:
        value -
        Throws:
        Exception
      • addDescendantLine

        public void addDescendantLine​(String value,
                                      TokenType tokenType)
                               throws Exception
        Add a line of descendants that represent the characters in the given string.
        Parameters:
        value -
        tokenType -
        Throws:
        Exception
      • deepestRead

        public SymbolNode deepestRead​(IScanner scanner)
        Find the descendant that takes as many characters as possible from the input.
        Parameters:
        scanner -
      • findChildWithChar

        public SymbolNode findChildWithChar​(int value)
        Find a child with the given character.
        Parameters:
        value -
      • unreadToValid

        public SymbolNode unreadToValid​(IScanner scanner)
        Unwind to a valid node; this node is "valid" if its ancestry represents a complete symbol. If this node is not valid, put back the character and ask the parent to unwind.
        Parameters:
        scanner -
      • getValid

        public boolean getValid()
      • setValid

        public void setValid​(boolean value)
      • getTokenType

        public TokenType getTokenType()
      • setTokenType

        public void setTokenType​(TokenType value)
      • ancestry

        public String ancestry()
        Show the symbol this node represents.
        Returns:
        The symbol this node represents.