[pslql] ParseException when parsing ELSIF

Fixes #1731
This commit is contained in:
Andreas Dangel
2019-03-28 16:51:08 +01:00
parent f6549d6c0b
commit ca6ad5fd22
3 changed files with 24 additions and 4 deletions

View File

@ -61,6 +61,8 @@ The designer will still be shipped with PMD's binaries.
* [#1701](https://github.com/pmd/pmd/issues/1701): \[java] UseTryWithResources does not handle multiple argument close methods
* java-codestyle
* [#1674](https://github.com/pmd/pmd/issues/1674): \[java] documentation of CommentDefaultAccessModifier is wrong
* plsql
* [#1731](https://github.com/pmd/pmd/issues/1731): \[pslql] ParseException when parsing ELSIF
### API Changes

View File

@ -2085,7 +2085,7 @@ ASTElseClause ElseClause() :
ASTElsifClause ElsifClause() :
{}
{
<ELSIF> Expression() <THEN> (Statement())+
<ELSIF> Expression() <THEN> (LOOKAHEAD(1, {!(getToken(1).kind == ELSIF)}) Statement())+
{ return jjtThis ; }
}
@ -2280,7 +2280,7 @@ ASTWhileStatement WhileStatement() :
ASTIfStatement IfStatement() :
{}
{
<IF> Expression() <THEN> (Statement())+
<IF> Expression() <THEN> (LOOKAHEAD(1, {!(getToken(1).kind == ELSIF)}) Statement())+
( ElsifClause() {jjtThis.setHasElse();} )*
[ ElseClause() {jjtThis.setHasElse();} ]
<END> <IF>
@ -6095,7 +6095,6 @@ ASTID ID(): {}
//| <DISTINCT> //RESERVED WORD
| <DO>
| <DROP> //RESERVED WORD
//| <ELSE> //SYNTAX //RESERVED WORD
| <ELSIF> //SYNTAX
//| <END> |<CURRENT_USER>
@ -6339,7 +6338,6 @@ ASTQualifiedID QualifiedID(): {}
//<DISTINCT>
| <DO>
//<DROP>
//<ELSE>
| <ELSIF>
//<END>
//<EXCEPTION>

View File

@ -0,0 +1,20 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.plsql.ast;
import org.junit.Assert;
import org.junit.Test;
import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst;
public class IfStatementTest extends AbstractPLSQLParserTst {
@Test
public void parseIfWithElseIf() throws Exception {
String code = "BEGIN\nIF 1 = 1 THEN null;\nELSIF (2 = 2) THEN null;\nELSE null;\nEND IF;\nEND;\n/\n";
ASTInput input = parsePLSQL(code);
Assert.assertNotNull(input);
}
}