[#8188] Add support for labels in procedural blocks
This commit is contained in:
parent
2eb09a7247
commit
fd1179677d
@ -46,7 +46,8 @@ dmlStatement =
|
||||
proceduralStatements = ( proceduralStatement ';' )+
|
||||
;
|
||||
|
||||
proceduralStatement =
|
||||
proceduralStatement = [ label ]
|
||||
(
|
||||
query
|
||||
| declareStatement
|
||||
| assignmentStatement
|
||||
@ -56,6 +57,10 @@ proceduralStatement =
|
||||
| continueStatement
|
||||
| exitStatement
|
||||
| nullStatement
|
||||
)
|
||||
;
|
||||
|
||||
label = '<<' identifier '>>'
|
||||
;
|
||||
|
||||
blockStatement =
|
||||
@ -93,11 +98,11 @@ whileStatement =
|
||||
;
|
||||
|
||||
continueStatement =
|
||||
'CONTINUE' [ 'WHEN' condition ]
|
||||
'CONTINUE' [ identifier ] [ 'WHEN' condition ]
|
||||
;
|
||||
|
||||
exitStatement =
|
||||
'EXIT' [ 'WHEN' condition ]
|
||||
'EXIT' [ identifier ] [ 'WHEN' condition ]
|
||||
;
|
||||
|
||||
nullStatement = 'NULL'
|
||||
|
||||
56
jOOQ/src/main/java/org/jooq/ContinueWhen.java
Normal file
56
jOOQ/src/main/java/org/jooq/ContinueWhen.java
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
56
jOOQ/src/main/java/org/jooq/ExitWhen.java
Normal file
56
jOOQ/src/main/java/org/jooq/ExitWhen.java
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
55
jOOQ/src/main/java/org/jooq/Label.java
Normal file
55
jOOQ/src/main/java/org/jooq/Label.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -58,6 +58,19 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -166,6 +166,7 @@ import org.jooq.ConstraintForeignKeyReferencesStep8;
|
||||
import org.jooq.ConstraintForeignKeyReferencesStep9;
|
||||
import org.jooq.ConstraintForeignKeyReferencesStepN;
|
||||
import org.jooq.ConstraintTypeStep;
|
||||
// ...
|
||||
import org.jooq.CreateIndexStep;
|
||||
import org.jooq.CreateSchemaFinalStep;
|
||||
import org.jooq.CreateSequenceFlagsStep;
|
||||
@ -185,6 +186,7 @@ import org.jooq.DropSequenceFinalStep;
|
||||
import org.jooq.DropTableStep;
|
||||
import org.jooq.DropTypeStep;
|
||||
import org.jooq.DropViewFinalStep;
|
||||
// ...
|
||||
import org.jooq.False;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.FieldOrRow;
|
||||
@ -222,6 +224,7 @@ import org.jooq.InsertValuesStepN;
|
||||
import org.jooq.Keyword;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import org.jooq.Merge;
|
||||
import org.jooq.MergeKeyStep1;
|
||||
import org.jooq.MergeKeyStep10;
|
||||
@ -9858,6 +9861,44 @@ public class DSL {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -58,6 +58,19 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
75
jOOQ/src/main/java/org/jooq/impl/LabelImpl.java
Normal file
75
jOOQ/src/main/java/org/jooq/impl/LabelImpl.java
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
70
jOOQ/src/main/java/org/jooq/impl/LabelledStatement.java
Normal file
70
jOOQ/src/main/java/org/jooq/impl/LabelledStatement.java
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -381,6 +381,7 @@ import org.jooq.InsertSetStep;
|
||||
import org.jooq.InsertValuesStepN;
|
||||
import org.jooq.JoinType;
|
||||
import org.jooq.Keyword;
|
||||
// ...
|
||||
import org.jooq.Merge;
|
||||
import org.jooq.MergeFinalStep;
|
||||
import org.jooq.MergeMatchedStep;
|
||||
@ -2213,10 +2214,22 @@ final class ParserImpl implements Parser {
|
||||
List<Statement> statements = new ArrayList<Statement>();
|
||||
|
||||
for (;;) {
|
||||
Statement statement = parseStatement(ctx);
|
||||
statements.add(statement);
|
||||
Statement parsed;
|
||||
Statement stored;
|
||||
|
||||
if (!(statement instanceof Block))
|
||||
|
||||
|
||||
|
||||
stored = parsed = parseStatement(ctx);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
statements.add(stored);
|
||||
|
||||
if (!(parsed instanceof Block))
|
||||
parse(ctx, ';');
|
||||
|
||||
if (peekKeyword(ctx, peek))
|
||||
@ -2238,6 +2251,25 @@ final class ParserImpl implements Parser {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static final Block parseDo(ParserContext ctx) {
|
||||
@ -2446,6 +2478,18 @@ final class ParserImpl implements Parser {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -8934,6 +8978,15 @@ final class ParserImpl implements Parser {
|
||||
return ctx.substring(start, stop);
|
||||
}
|
||||
|
||||
private static final boolean parse(ParserContext ctx, String string) {
|
||||
boolean result = parseIf(ctx, string);
|
||||
|
||||
if (!result)
|
||||
throw ctx.expected(string);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final boolean parseIf(ParserContext ctx, String string) {
|
||||
return parseIf(ctx, string, true);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user