diff --git a/velocity-custom-parser-example/pom.xml b/velocity-custom-parser-example/pom.xml index 7c609b23e..652f1ca0f 100644 --- a/velocity-custom-parser-example/pom.xml +++ b/velocity-custom-parser-example/pom.xml @@ -148,7 +148,7 @@ ${parser.debug} ${parser.debug} ${parser.debug} - ${maven.compiler.target} + 1.8 true ${parser.package}.node ${project.build.directory}/parser/org/apache/velocity/runtime/parser diff --git a/velocity-engine-core/src/main/parser/Parser.jjt b/velocity-engine-core/src/main/parser/Parser.jjt index 4e790735c..39e9521dd 100644 --- a/velocity-engine-core/src/main/parser/Parser.jjt +++ b/velocity-engine-core/src/main/parser/Parser.jjt @@ -1576,7 +1576,7 @@ boolean Statement(boolean afterNewline) #void : | LOOKAHEAD( { getToken(1).kind == WORD || getToken(1).kind == BRACKETED_WORD || afterNewline && getToken(1).kind == WHITESPACE && ( getToken(2).kind == WORD || getToken(2).kind == BRACKETED_WORD ) } ) afterNewline = Directive(afterNewline) { return afterNewline; } | afterNewline = Text() { return afterNewline; } | () #Text { return true; } -| ((() { afterNewline = false; } ) (() { afterNewline = true; })? ) #Text { return afterNewline; } +| ((() { afterNewline = false; } ) (LOOKAHEAD(2) () { afterNewline = true; })? ) #Text { return afterNewline; } | () #Text { return false; } | () #Text { return true; } | LOOKAHEAD(2) EndingZeroWidthWhitespace() { return afterNewline; } @@ -2113,11 +2113,11 @@ void IntegerRange() : {} */ void IndexParameter() #void: {} { - (|)* + (LOOKAHEAD(2) (|))* ( Expression() ) - (|)* + (LOOKAHEAD(2) (|))* } @@ -2493,7 +2493,7 @@ void MultiplicativeExpression() #void : {} void UnaryExpression() #void : {} { - ( | )* + (LOOKAHEAD(2) ( | ))* ( UnaryExpression() #NotNode(1) | PrimaryExpression() #NegateNode(1) @@ -2503,7 +2503,7 @@ void UnaryExpression() #void : {} void PrimaryExpression() #void : {} { - ( | )* + (LOOKAHEAD(2) ( | ))* ( StringLiteral() | Reference() @@ -2516,7 +2516,7 @@ void PrimaryExpression() #void : {} | False() | Expression() ) - ( | )* + (LOOKAHEAD(2) ( | ))* } /* ======================================================================