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

[new-parser] end with succeeding rule in the same line fails #5727

Closed
tkobayas opened this issue Feb 22, 2024 · 4 comments
Closed

[new-parser] end with succeeding rule in the same line fails #5727

tkobayas opened this issue Feb 22, 2024 · 4 comments
Assignees

Comments

@tkobayas
Copy link
Contributor

Parent issue

Failing tests

Notes

The new Lexer assumes that end ends with NewLine or EOF. If rule follows in the same line, end is not detected.

For example:

    "end " + // no new line

    "rule 'Rule 2' " +

produces:

	end cannot be resolved to a type
	Syntax error on token ""Rule 2"", = expected
        ...

Complete STANDARD_FROM_DRL output

java.lang.AssertionError: 
[Message [id=1, kieBase=defaultKieBase, level=ERROR, path=r0.drl, line=-1, column=0
   text=Rule Compilation error end cannot be resolved to a type
Syntax error on token ""Rule 2"", = expected
agenda cannot be resolved to a variable
The target type of this expression must be a functional interface
Syntax error on token ""End"", -> expected
Syntax error on token "when", ? expected
Syntax error, insert ";" to complete LocalVariableDeclarationStatement
Syntax error on token "then", invalid AssignmentOperator]]
	at org.drools.model.codegen.execmodel.BaseModelTest.createKieBuilder(BaseModelTest.java:157)
	at org.drools.model.codegen.execmodel.BaseModelTest.createKieBuilder(BaseModelTest.java:132)
	at org.drools.model.codegen.execmodel.BaseModelTest.getKieContainer(BaseModelTest.java:121)
	at org.drools.model.codegen.execmodel.BaseModelTest.getKieContainer(BaseModelTest.java:114)
	at org.drools.model.codegen.execmodel.BaseModelTest.getKieSession(BaseModelTest.java:110)
	at org.drools.model.codegen.execmodel.BaseModelTest.getKieSession(BaseModelTest.java:106)
	at org.drools.model.codegen.execmodel.RuleAttributesTest.testCrossNoLoopWithNodeSharing(RuleAttributesTest.java:171)

Complete PATTERN_DSL output

11:51:21.111 [main] ERROR o.d.c.k.b.impl.AbstractKieProject.buildKnowledgePackages:280 - Unable to build KieBaseModel:defaultKieBase
InvalidExpressionErrorResult: Unable to parse consequence caused by: (line 2,col 60) Parse error. Found  "\"Rule 2\"" <STRING_LITERAL>, expected one of  "," ";" "=" "@" "["
Problem stacktrace : 
  com.github.javaparser.GeneratedJavaParser.generateParseException(GeneratedJavaParser.java:13933)
  com.github.javaparser.GeneratedJavaParser.jj_consume_token(GeneratedJavaParser.java:13778)
  com.github.javaparser.GeneratedJavaParser.BlockStatement(GeneratedJavaParser.java:5807)
  com.github.javaparser.GeneratedJavaParser.Statements(GeneratedJavaParser.java:2773)
  com.github.javaparser.GeneratedJavaParser.Block(GeneratedJavaParser.java:5744)
  com.github.javaparser.GeneratedJavaParser.BlockParseStart(GeneratedJavaParser.java:8238)
  com.github.javaparser.JavaParser.parse(JavaParser.java:125)
  com.github.javaparser.JavaParser.parseBlock(JavaParser.java:317)
  org.drools.model.codegen.execmodel.generator.DrlxParseUtil.parseBlock(DrlxParseUtil.java:500)
  org.drools.model.codegen.execmodel.generator.Consequence.rewriteConsequence(Consequence.java:229)
  org.drools.model.codegen.execmodel.generator.Consequence.createCall(Consequence.java:143)
  org.drools.model.codegen.execmodel.generator.ModelGenerator.processRule(ModelGenerator.java:242)
  org.drools.model.codegen.execmodel.generator.ModelGenerator.processRuleDescr(ModelGenerator.java:185)
  org.drools.model.codegen.execmodel.generator.ModelGenerator.processRules(ModelGenerator.java:164)
  org.drools.model.codegen.execmodel.generator.ModelGenerator.generateModel(ModelGenerator.java:130)
  org.drools.model.codegen.execmodel.processors.ModelGeneratorPhase.process(ModelGeneratorPhase.java:48)
  org.drools.compiler.builder.impl.processors.IteratingPhase.process(IteratingPhase.java:53)
  org.drools.model.codegen.execmodel.processors.ModelMainCompilationPhase.process(ModelMainCompilationPhase.java:104)
  org.drools.model.codegen.execmodel.ModelBuilderImpl.doSecondBuildStep(ModelBuilderImpl.java:114)
  org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:125)
  org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:109)
  org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:274)
  org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:220)
  org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:84)
  org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:285)
  org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:251)
  org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:208)
  org.drools.model.codegen.execmodel.BaseModelTest.createKieBuilder(BaseModelTest.java:149)
  org.drools.model.codegen.execmodel.BaseModelTest.createKieBuilder(BaseModelTest.java:132)
  org.drools.model.codegen.execmodel.BaseModelTest.getKieContainer(BaseModelTest.java:121)
  org.drools.model.codegen.execmodel.BaseModelTest.getKieContainer(BaseModelTest.java:114)
  org.drools.model.codegen.execmodel.BaseModelTest.getKieSession(BaseModelTest.java:110)
  org.drools.model.codegen.execmodel.BaseModelTest.getKieSession(BaseModelTest.java:106)
  org.drools.model.codegen.execmodel.RuleAttributesTest.testCrossNoLoopWithNodeSharing(RuleAttributesTest.java:171)
@tkobayas
Copy link
Contributor Author

It was already discussed in kiegroup/drools-lsp#26 (comment)

Experiment: kiegroup/drools-lsp@0734bab

@tkobayas
Copy link
Contributor Author

tkobayas commented Mar 4, 2024

Fixed by #5726

@tkobayas tkobayas closed this as completed Mar 4, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to 🎯 Done in 🦉 KIE Podling Board Mar 4, 2024
@tkobayas
Copy link
Contributor Author

org.drools.model.codegen.execmodel.RuleAttributesTest#testCrossNoLoopWithNodeSharing fails again. Regression or overlooked something. I'll investigate again.

@tkobayas
Copy link
Contributor Author

Fixed by #5855

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

1 participant