Class BaseParser

    • Field Detail

      • LOG

        protected static final Log LOG
    • Method Detail

      • getDefaultDelimiter

        protected Delimiter getDefaultDelimiter()
      • getIdentifierQuote

        protected char getIdentifierQuote()
      • getAlternativeIdentifierQuote

        protected char getAlternativeIdentifierQuote()
      • getAlternativeStringLiteralQuote

        protected char getAlternativeStringLiteralQuote()
      • getOpeningIdentifierSymbol

        protected char getOpeningIdentifierSymbol()
      • getClosingIdentifierSymbol

        protected char getClosingIdentifierSymbol()
      • getValidKeywords

        protected Set<String> getValidKeywords()
      • supportsPeekingMultipleLines

        protected boolean supportsPeekingMultipleLines()
      • parse

        public final SqlStatementIterator parse​(Resource resource,
                                                SqlScriptMetadata metadata)
        Description copied from interface: Parser
        Parses this resource into a stream of statements.
        Specified by:
        parse in interface Parser
        Parameters:
        resource - The resource to parse.
        metadata - The resource's metadata
        Returns:
        The statements.
      • replacePlaceholders

        protected Reader replacePlaceholders​(Reader reader,
                                             SqlScriptMetadata metadata)
        Configures this reader for placeholder replacement.
        Parameters:
        reader - The original reader.
        metadata - The resource's metadata.
        Returns:
        The new reader with placeholder replacement.
      • shouldDiscard

        protected boolean shouldDiscard​(Token token,
                                        boolean nonCommentPartSeen)
        Whether the current set of tokens should be discarded.
        Parameters:
        token - The latest token.
        nonCommentPartSeen - Whether a non-comment part has already been seen.
        Returns:
        true if it should, false if not.
      • resetDelimiter

        protected void resetDelimiter​(ParserContext context)
        Resets the delimiter to its default value before parsing a new statement.
      • adjustDelimiter

        protected void adjustDelimiter​(ParserContext context,
                                       StatementType statementType)
        Adjusts the delimiter if necessary for this statement type.
        Parameters:
        statementType - The statement type.
      • getTransactionalDetectionCutoff

        protected int getTransactionalDetectionCutoff()
        Returns:
        The cutoff point in terms of number of tokens after which a statement can no longer be non-transactional.
      • getLastKeywordIndex

        protected int getLastKeywordIndex​(List<Token> tokens)
      • getLastKeywordIndex

        protected int getLastKeywordIndex​(List<Token> tokens,
                                          int endIndex)
      • getPreviousToken

        protected static Token getPreviousToken​(List<Token> tokens,
                                                int parensDepth)
      • lastTokenIs

        protected static boolean lastTokenIs​(List<Token> tokens,
                                             int parensDepth,
                                             String tokenText)
      • lastTokenIsOnLine

        protected static boolean lastTokenIsOnLine​(List<Token> tokens,
                                                   int parensDepth,
                                                   int line)
      • tokenAtIndexIs

        protected static boolean tokenAtIndexIs​(List<Token> tokens,
                                                int index,
                                                String tokenText)
      • doTokensMatchPattern

        protected boolean doTokensMatchPattern​(List<Token> previousTokens,
                                               Token current,
                                               Pattern regex)
      • detectCanExecuteInTransaction

        protected Boolean detectCanExecuteInTransaction​(String simplifiedStatement,
                                                        List<Token> keywords)
      • isAlternativeStringLiteral

        protected boolean isAlternativeStringLiteral​(String peek)
      • isDelimiter

        protected boolean isDelimiter​(String peek,
                                      ParserContext context,
                                      int col,
                                      int colIgnoringWhitespace)
      • isLetter

        protected boolean isLetter​(char c,
                                   ParserContext context)
      • isSingleLineComment

        protected boolean isSingleLineComment​(String peek,
                                              ParserContext context,
                                              int col)
      • isKeyword

        protected boolean isKeyword​(String text)
      • isCommentDirective

        protected boolean isCommentDirective​(String peek)