Skip to content
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

[incubator-kie-drools#5742] [new-parser] Broken inline cast #5806

Merged

Conversation

tkobayas
Copy link
Contributor

Issue:

How to replicate CI configuration locally?

Build Chain tool does "simple" maven build(s), the builds are just Maven commands, but because the repositories relates and depends on each other and any change in API or class method could affect several of those repositories there is a need to use build-chain tool to handle cross repository builds and be sure that we always use latest version of the code for each repository.

build-chain tool is a build tool which can be used on command line locally or in Github Actions workflow(s), in case you need to change multiple repositories and send multiple dependent pull requests related with a change you can easily reproduce the same build by executing it on Github hosted environment or locally in your development environment. See local execution details to get more information about it.

How to retest this PR or trigger a specific build:
  • for pull request and downstream checks

    • Push a new commit to the PR. An empty commit would be enough.
  • for a full downstream build

    • for github actions job: add the label run_fdb
  • for Jenkins PR check only

@tkobayas
Copy link
Contributor Author

Before PR
drools-model-codegen

[ERROR] Tests run: 2434, Failures: 220, Errors: 0, Skipped: 9

After PR
drools-model-codegen

[ERROR] Tests run: 2434, Failures: 200, Errors: 0, Skipped: 9

@@ -230,6 +230,7 @@ drlIdentifier returns [Token token]
| PERMITS
| RECORD
| VAR
| THIS
Copy link
Contributor Author

@tkobayas tkobayas Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, I add THIS to drlIdentifier (in both DRLParser.g4 and DRL6Expressions.g4) because the original DRL6Expressions.g treated this as ID in primary rule (remember that | this_key ... line was commented out). this is involved with DRL specific syntax like inline cast (this#Person) and null dereference (this.address!.city). So I think it's better to include it in drlIdentifier so that we can keep parser rules simple.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with this is that the parser will now allow this to appear at impossible places, for example, Person( age.this.getSomething() ). I feel slightly uncomfortable about this 🙂

But on second thought, I think it's OK because:

  1. A slightly more permissive parser is not a big problem as opposed to a parser that's unable to accept a valid input.
  2. It's in line with the old parser's behavior (no THIS token => this recognized as ID => accepted in the example above).
  3. Yes, this is probably the most pragmatic approach. Simplicity over (maybe redundant) correctness.

So +0.9.

Copy link
Contributor Author

@tkobayas tkobayas Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, especially the reason "2" is the point. We'd like to minimize deviation from the old parser behaviour at this stage. (Hoping cleaner refactoring in the future)

@@ -671,7 +672,6 @@ primary returns [BaseDescr result]
: expr=parExpression { if( buildDescr ) { $result = $expr.result; } }
| nonWildcardTypeArguments (explicitGenericInvocationSuffix | this_key arguments)
| literal { if( buildDescr ) { $result = new AtomicExprDescr( $literal.text, true ); } }
| this_key (DOT drlIdentifier)* identifierSuffix?
Copy link
Contributor Author

@tkobayas tkobayas Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was added by #5791 , but now this is handled by the later lines | i1=drlIdentifier ... which can process DOT, HASH and NULL_SAFE_DOT.

Comment on lines +326 to +329
| inlineCast
;

inlineCast : drlIdentifier HASH drlIdentifier ;
Copy link
Contributor Author

@tkobayas tkobayas Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In DRLParser.g4, we mimic the parser syntax of DRL6Expressions.g4. However, here looks a little different. DRL6Expressions.g4's primary rule handles more complex structure (e.g. DOT chaining) while such a structure is handled in drlExpression in DRLParser.g4 because drlExpression is inherited from JavaParser.g4's expression.

This time, I prioritized simplicity for the changes in DRLParser.g4. But I filed #5807 to review drlExpression and drlPrimary to make them closer to DRL6Expressions.g4.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also filed #5808 for further refactoring for the parsers.

@tkobayas
Copy link
Contributor Author

@yurloc @mariofusco @gitgabrio Please review, thanks!

@mariofusco mariofusco self-requested a review March 27, 2024 15:14
Copy link
Contributor

@yurloc yurloc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the identical test issue. Otherwise LGTM.

final String text = "package org.drools\n" +
"rule R1\n" +
"when\n" +
" $a : ICA( someB#ICB.someC#ICC.onlyConcrete() == \"Hello\" )\n" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is identical to the inlineCastMultiple() test below. Looks like a copy-paste error. Please fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for spotting this!

Copy link
Contributor

@yurloc yurloc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Let's merge.

@tkobayas tkobayas merged commit f9123bc into apache:dev-new-parser Mar 28, 2024
0 of 3 checks passed
@yurloc
Copy link
Contributor

yurloc commented Apr 1, 2024

Overall fixing progress: There were 270 failed tests.

tkobayas added a commit to tkobayas/drools that referenced this pull request Jun 11, 2024
)

* [incubator-kie-drools#5742] [new-parser] Broken inline cast

* fixed duplicate test
tkobayas added a commit to tkobayas/drools that referenced this pull request Oct 2, 2024
)

* [incubator-kie-drools#5742] [new-parser] Broken inline cast

* fixed duplicate test
tkobayas added a commit to tkobayas/drools that referenced this pull request Oct 11, 2024
)

* [incubator-kie-drools#5742] [new-parser] Broken inline cast

* fixed duplicate test
tkobayas added a commit that referenced this pull request Oct 11, 2024
* [incubator-kie-drools#5742] [new-parser] Broken inline cast

* fixed duplicate test
rgdoliveira pushed a commit to rgdoliveira/drools that referenced this pull request Oct 24, 2024
)

* [incubator-kie-drools#5742] [new-parser] Broken inline cast

* fixed duplicate test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants