apache / incubator-kie-drools

Drools is a rule engine, DMN engine and complex event processing (CEP) engine for Java.
http://www.drools.org
Apache License 2.0
5.88k stars 2.5k forks source link

[new-parser] Operator `isA` not supported #5822

Closed yurloc closed 7 months ago

yurloc commented 7 months ago

Parent issue

Failing tests

Notes

Rule code snippet

rule "Init"
salience 10 
when
  $p : Person( this not isA Student )
then
  don( $p, Student.class );
end

Error output

18:31:13.199 [main] WARN  o.d.c.k.builder.impl.KieBuilderImpl.packageNameForFile:396 - File 'file0.drl' is in folder '' but declares package 'org.drools.text'. It is advised to have a correspondance between package and folder names.
### parse : ANTLR4_PARSER_ENABLED = true
line 16:24 no viable alternative at input 'this not isA'
line 16:28 no viable alternative at input 'isA Student'
18:31:13.202 [main] ERROR o.d.d.parser.antlr4.DRLParserWrapper.parse:77 - Exception while creating PackageDescr
java.lang.IllegalStateException: ctx.lhsPattern().size() == 0 : 
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitLhsPatternBind(DRLVisitorImpl.java:469)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitLhsPatternBind(DRLVisitorImpl.java:77)
    at org.drools.drl.parser.antlr4.DRLParser$LhsPatternBindContext.accept(DRLParser.java:2123)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitDescrChildren(DRLVisitorImpl.java:874)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitLhsUnary(DRLVisitorImpl.java:852)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitLhsUnary(DRLVisitorImpl.java:77)
    at org.drools.drl.parser.antlr4.DRLParser$LhsUnaryContext.accept(DRLParser.java:2024)
    at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
    at org.drools.drl.parser.antlr4.DRLParserBaseVisitor.visitLhsUnarySingle(DRLParserBaseVisitor.java:153)
    at org.drools.drl.parser.antlr4.DRLParser$LhsUnarySingleContext.accept(DRLParser.java:1677)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitDescrChildren(DRLVisitorImpl.java:874)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitLhs(DRLVisitorImpl.java:456)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitRuledef(DRLVisitorImpl.java:275)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitRuledef(DRLVisitorImpl.java:77)
    at org.drools.drl.parser.antlr4.DRLParser$RuledefContext.accept(DRLParser.java:1260)
    at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
    at org.drools.drl.parser.antlr4.DRLParserBaseVisitor.visitDrlStatementdef(DRLParserBaseVisitor.java:27)
    at org.drools.drl.parser.antlr4.DRLParser$DrlStatementdefContext.accept(DRLParser.java:420)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitDescrChildren(DRLVisitorImpl.java:874)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitCompilationUnit(DRLVisitorImpl.java:94)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitCompilationUnit(DRLVisitorImpl.java:77)
    at org.drools.drl.parser.antlr4.DRLParser$CompilationUnitContext.accept(DRLParser.java:333)
    at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
    at org.drools.drl.parser.antlr4.DRLParserHelper.compilationUnitContext2PackageDescr(DRLParserHelper.java:87)
    at org.drools.drl.parser.antlr4.DRLParserWrapper.parse(DRLParserWrapper.java:75)
    at org.drools.drl.parser.antlr4.DRLParserWrapper.parse(DRLParserWrapper.java:55)
    at org.drools.drl.parser.DrlParser.lambda$parse$2(DrlParser.java:189)
    at org.drools.drl.parser.DrlParser.compileWithAntlr4Parser(DrlParser.java:202)
    at org.drools.drl.parser.DrlParser.parse(DrlParser.java:189)
    at org.drools.drl.parser.DrlParser.parse(DrlParser.java:177)
    at org.drools.drl.parser.DrlParser.parse(DrlParser.java:166)
    at org.drools.compiler.builder.impl.resources.DrlResourceHandler.process(DrlResourceHandler.java:55)
    at org.drools.compiler.builder.impl.PackageDescrBuilder.buildResource(PackageDescrBuilder.java:73)
    at org.drools.compiler.builder.impl.PackageDescrBuilder.build(PackageDescrBuilder.java:51)
    at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackageDescr(CompositeKnowledgeBuilderImpl.java:173)
    at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:116)
    at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:109)
    at org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:274)
    at org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:220)
    at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:84)
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:285)
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:251)
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:198)
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:204)
    at org.kie.internal.utils.KieHelper.getKieContainer(KieHelper.java:124)
    at org.kie.internal.utils.KieHelper.build(KieHelper.java:89)
    at org.kie.internal.utils.KieHelper.build(KieHelper.java:84)
    at org.drools.traits.compiler.factmodel.traits.TraitTest.getSessionFromString(TraitTest.java:145)
    at org.drools.traits.compiler.factmodel.traits.TraitTest.testUpdateLegacyClass(TraitTest.java:3890)
18:31:13.202 [main] ERROR o.d.c.k.b.impl.AbstractKieProject.buildKnowledgePackages:280 - Unable to build KieBaseModel:defaultKieBase
[16,24]: no viable alternative at input 'this not isA'
[16,28]: no viable alternative at input 'isA Student'
[0,0]: 
[0,0]: Parser returned a null Package

java.lang.RuntimeException: [Message [id=1, kieBase=defaultKieBase, level=ERROR, path=file0.drl, line=16, column=0
   text=no viable alternative at input 'this not isA'], Message [id=2, kieBase=defaultKieBase, level=ERROR, path=file0.drl, line=16, column=0
   text=no viable alternative at input 'isA Student'], Message [id=3, kieBase=defaultKieBase, level=ERROR, path=file0.drl, line=0, column=0
   text=], Message [id=4, kieBase=defaultKieBase, level=ERROR, path=file0.drl, line=0, column=0
   text=Parser returned a null Package]]

    at org.kie.internal.utils.KieHelper.getKieContainer(KieHelper.java:127)
    at org.kie.internal.utils.KieHelper.build(KieHelper.java:89)
    at org.kie.internal.utils.KieHelper.build(KieHelper.java:84)
    at org.drools.traits.compiler.factmodel.traits.TraitTest.getSessionFromString(TraitTest.java:145)
    at org.drools.traits.compiler.factmodel.traits.TraitTest.testUpdateLegacyClass(TraitTest.java:3890)
yurloc commented 7 months ago

/take