-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DO-NOT-MERGE][incubator-kie-drools-6220] Slim down DRL syntax with New Antlr4 Parser #6225
Draft
tkobayas
wants to merge
10
commits into
apache:main
Choose a base branch
from
tkobayas:incubator-kie-drools-6220-slimdown
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,647
−2,188
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4b03019
[incubator-kie-drools-6220] Slim down DRL syntax with New Antlr4 Parser
tkobayas d76bdd4
- a prefix for custom operator
tkobayas 6079976
- drop half constraint
tkobayas ef0a455
- drop infix doubleAmpersand and doublePipe
tkobayas 7be57d5
- drop Annotation inside LHS
tkobayas 5a28d5d
- additional test for end token
tkobayas e0872ff
- replace agenda-group with ruleflow-group
tkobayas 2a95d6c
- Add warnings for deprecated DRL syntax when used in DRL6
tkobayas 30ecdd1
- release notes and docs
tkobayas b7c1b54
- gha test DRL10
tkobayas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ nbproject | |
*.ipr | ||
*.iws | ||
*.iml | ||
build.log | ||
|
||
# generated files | ||
dependency-reduced-pom.xml | ||
|
146 changes: 146 additions & 0 deletions
146
drools-docs/src/modules/ROOT/pages/language-reference/_language-level.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
//// | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you 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. | ||
//// | ||
|
||
[id='language-level_drl-rules'] | ||
|
||
= Language Level | ||
|
||
Language Level is a feature that allows you to specify the version of the DRL (Drools Rule Language) syntax you want to use. | ||
|
||
Supported language levels are: | ||
|
||
* DRL6 (default) | ||
* DRL10 | ||
|
||
Some old language levels are deprecated and will be removed in the future: | ||
|
||
* DRL5 | ||
* DRL6_STRICT | ||
|
||
DRL6 is compatible with the previous Drools versions, while DRL10 introduces some changes to reduce ambiguity. | ||
|
||
Language Level can be specified by kmodule.xml or system property. Note that the configuration should be effective when rules are built. | ||
|
||
.kmodule.xml example | ||
[source,xml] | ||
---- | ||
<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://www.drools.org/xsd/kmodule"> | ||
<configuration> | ||
<property key="drools.lang.level" value="DRL10"/> | ||
</configuration> | ||
</kmodule> | ||
---- | ||
|
||
.System property example | ||
[source,java] | ||
---- | ||
System.setProperty("drools.lang.level", "DRL10"); | ||
---- | ||
|
||
== DRL10 | ||
|
||
DRL10 has been added, which is handled by the new parser based on ANTLR4. DRL10 introduces the following changes mainly to reduce ambiguity: | ||
|
||
* Require a prefix `##` to custom operators | ||
.DRL6 | ||
[source] | ||
---- | ||
Person(addresses supersetOf $alice.addresses) | ||
---- | ||
|
||
.DRL10 | ||
[source] | ||
---- | ||
Person(addresses ##supersetOf $alice.addresses) | ||
---- | ||
|
||
The custom operator's implementation Java code wouldn't need to be changed. | ||
|
||
* Drop half constraint syntax | ||
|
||
.DRL6 | ||
[source] | ||
---- | ||
Person(age > 10 && < 20) | ||
---- | ||
|
||
.DRL10 (also valid in DRL6) | ||
[source] | ||
---- | ||
Person(age > 10 && age < 20) | ||
---- | ||
|
||
* Drop double ampersand as infix and | ||
|
||
.DRL6 | ||
[source] | ||
---- | ||
( Person(age == 10) | ||
&& | ||
Person(age == 20) ) | ||
---- | ||
|
||
.DRL10 (also valid in DRL6) | ||
[source] | ||
---- | ||
( Person(age == 10) | ||
and | ||
Person(age == 20) ) | ||
---- | ||
|
||
`&&` in a constraint will remain supported. For example, `Person(age == 10 && age == 20)` is valid in DRL6 and DRL10. | ||
|
||
* Drop double pipe as infix or | ||
|
||
.DRL6 | ||
[source] | ||
---- | ||
( Person(age == 10) | ||
|| | ||
Person(age == 20) ) | ||
---- | ||
|
||
.DRL10 (also valid in DRL6) | ||
[source] | ||
---- | ||
( Person(age == 10) | ||
or | ||
Person(age == 20) ) | ||
---- | ||
|
||
`||` in a constraint will remain supported. For example, `Person(age == 10 || age == 20)` is valid in DRL6 and DRL10. | ||
|
||
* Drop annotation inside LHS pattern | ||
|
||
.DRL6 | ||
[source] | ||
---- | ||
( Double() | ||
or @Annot1 String() | ||
or @Annot2 Integer() ) | ||
---- | ||
|
||
There is no equivalent expression in DRL10. | ||
|
||
Annotation in other places will remain supported. For example, `Person(name == "Mario") @watch(*)` is valid in DRL6 and DRL10. | ||
|
||
Those syntaxes are deprecated and will be removed in the future. Warnings are logged when the deprecated syntax is used in DRL6. | ||
|
||
Warnings are logged when the deprecated syntax is used in DRL6. The warning logs can be suppressed by the log level of `org.drools.drl.parser.lang.ParserHelper`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
drools-docs/src/modules/ROOT/pages/release-notes/_release-notes-10.1.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//// | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you 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. | ||
//// | ||
|
||
== 10.1.0 release notes | ||
|
||
=== Language Level DRL10 | ||
New language level DRL10 has been added. DRL10 is handled by the new parser based on ANTLR4. The default language level is still DRL6. | ||
|
||
DRL10 introduces the following changes mainly to reduce ambiguity: | ||
|
||
* Require a prefix '##' to custom operators | ||
* Drop half constraint syntax | ||
* Drop double ampersand as infix and | ||
* Drop double pipe as infix or | ||
* Drop annotation inside LHS pattern | ||
|
||
Those syntaxes are deprecated and will be removed in the future. Warnings are logged when the deprecated syntax is used in DRL6. | ||
|
||
You can refer xref:language-reference/index.adoc#language-level_drl-rules[Language Level] for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,4 +72,8 @@ public P end() { | |
return parent; | ||
} | ||
|
||
@Override | ||
public P getParent() { | ||
return parent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a temporal change to test the new parser (= DRL10). I'll revert this after review.