Class ParserImpl

  • All Implemented Interfaces:
    Parser

    public class ParserImpl
    extends java.lang.Object
    implements Parser
    • Field Detail

      • binaryOperators

        private final java.util.Map<java.lang.String,​BinaryOperator> binaryOperators
        Binary operators
      • unaryOperators

        private final java.util.Map<java.lang.String,​UnaryOperator> unaryOperators
        Unary operators
      • tokenParsers

        private final java.util.Map<java.lang.String,​TokenParser> tokenParsers
        Token parsers
      • expressionParser

        private ExpressionParser expressionParser
        An expression parser.
      • stream

        private TokenStream stream
        The TokenStream that we are converting into an Abstract Syntax Tree.
      • blockStack

        private java.util.LinkedList<java.lang.String> blockStack
        used to keep track of the name of the block that we are currently inside of. This is purely just for the parent() function.
      • parserOptions

        private ParserOptions parserOptions
        parser options
    • Constructor Detail

      • ParserImpl

        public ParserImpl​(java.util.Map<java.lang.String,​UnaryOperator> unaryOperators,
                          java.util.Map<java.lang.String,​BinaryOperator> binaryOperators,
                          java.util.Map<java.lang.String,​TokenParser> tokenParsers,
                          ParserOptions parserOptions)
        Constructor
        Parameters:
        binaryOperators - A map of binary operators
        unaryOperators - A map of unary operators
        tokenParsers - A map of token parsers
    • Method Detail

      • subparse

        public BodyNode subparse​(StoppingCondition stopCondition)
        Description copied from interface: Parser
        Parses the existing TokenStream, starting at the current Token, and ending when the stopCondition is fullfilled.
        Specified by:
        subparse in interface Parser
        Parameters:
        stopCondition - The condition to stop parsing a segment of the template.
        Returns:
        A node representing the parsed section
      • getStream

        public TokenStream getStream()
        Description copied from interface: Parser
        Provides the stream of tokens which ultimately need to be "parsed" into Nodes.
        Specified by:
        getStream in interface Parser
        Returns:
        TokenStream
      • setStream

        public void setStream​(TokenStream stream)
      • peekBlockStack

        public java.lang.String peekBlockStack()
        Specified by:
        peekBlockStack in interface Parser
      • popBlockStack

        public java.lang.String popBlockStack()
        Specified by:
        popBlockStack in interface Parser
      • pushBlockStack

        public void pushBlockStack​(java.lang.String blockName)
        Specified by:
        pushBlockStack in interface Parser