-
Notifications
You must be signed in to change notification settings - Fork 12
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
Bugfix/nw23001440/zadd result array #407
Conversation
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.
Good practices:
- understanding the parse tree
- make yourself this question: is there an extension function
parseTreeNode.toAst
that I can use?
In practice:
Add to your test:
assertCanBeParsed(exampleName = "smeup/T10_A20_P19", printTree = true)
When you run it you will see:
<csZ_ADD>
Z-ADD
<cspec_fixed_standard_parts>
<factor>
<factorContent>
10
</factorContent>
</factor>
<resultType>
A20_AR1(1)
</resultType>
<resultIndicator/>
<resultIndicator/>
<resultIndicator/>
</cspec_fixed_standard_parts>
</csZ_ADD>
This is the part of the parse tree for the Z-ADD
operation code.
How you can see the result is inside this node:
<resultType>
A20_AR1(1)
</resultType>
If you remember, for each node in the parse tree, antlr will create a class named <NodeName>Context
, in this case: ResultTypeContext
.
If you search for ResultTypeContext.toAst
you can use it because this method converts a parse tree node (instance of org.antlr.v4.runtime.tree.Tree
) into the generic ast node (instance of com.strumenta.kolasu.model.Node
).
In this case the concrete class returned by ResultTypeContext.toAst
is com.smeup.rpgparser.parsing.ast.AssignableExpression
Try to use these suggestions and you will see that your implementation costs one or two lines of code
Thank you Marco for your suggestion. If I understand correctly, I could change line 1414 of
in
removing unused code, as I did in last today's commit. I look your feedback, |
I would make it just as you say.
Il giorno gio 1 feb 2024 alle ore 09:18 Davide ***@***.***>
ha scritto:
… Good practices:
* understanding the parse tree
* make yourself this question: is there an extension function `parseTreeNode.toAst` that I can use?
In practice: Add to your test: assertCanBeParsed(exampleName =
"smeup/T10_A20_P19", printTree = true) When you run it you will see:
<csZ_ADD>
Z-ADD
<cspec_fixed_standard_parts>
<factor>
<factorContent>
10
</factorContent>
</factor>
<resultType>
A20_AR1(1)
</resultType>
<resultIndicator/>
<resultIndicator/>
<resultIndicator/>
</cspec_fixed_standard_parts>
</csZ_ADD>
This is the part of the parse tree for the Z-ADD operation code. How you
can see the result is inside this node:
<resultType>
A20_AR1(1)
</resultType>
If you remember, for each node in the parse tree, antlr will create a
class named <NodeName>Context, in this case: ResultTypeContext.
If you search for ResultTypeContext.toAst you can use it because this
method converts a parse tree node (instance of
org.antlr.v4.runtime.tree.Tree) into the generic ast node (instance of
com.strumenta.kolasu.model.Node). In this case the concrete class
returned by ResultTypeContext.toAst is
com.smeup.rpgparser.parsing.ast.AssignableExpression
Try to use these suggestions and you will see that your implementation
costs one or two lines of code
Thank you Marco for your suggestion. If I understand correctly, I could
change line 1414 of misc.kt
return ZAddStmt(resultExpression, dataDefinition, expression, position)
in
return ZAddStmt(this.cspec_fixed_standard_parts().result.toAst(conf),
dataDefinition, expression, position)
removing unused code, as I did in last today's commit.
I look your feedback,
Davide.
—
Reply to this email directly, view it on GitHub
<#407 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJR622QWMFY5DOYCCNDOTFDYRNFVRAVCNFSM6AAAAABCTAP6WOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRQG42DKMRVGU>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
--
[image: smeup] <https://www.smeup.com>
Marco Lanari
R&D Department - Developer
Office: 0521940611 <00390521940611>
www.smeup.com
*SMEUP LAB SRL*
Via Carra, 8 - 43122 Parma (PR)
|
Thank you. I did it in new commit. |
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.
Another little step...
rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/parsetreetoast/misc.kt
Outdated
Show resolved
Hide resolved
rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt
Outdated
Show resolved
Hide resolved
rpgJavaInterpreter-core/src/test/resources/smeup/T10_A20_P19F.rpgle
Outdated
Show resolved
Hide resolved
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.
I forgot that also the PR comment must be revised.
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.
Ok.
Description
To fix this issue, I improved
CsZ_ADDContext.toAst
by passingthis.cspec_fixed_standard_parts().result.toAst(conf)
insteadDataRefExpr(ReferenceByName(name), position)
for the first parameter (target
) ofZAddStmt
.Related to:
T10_A20_P19
Checklist:
./gradlew ktlintCheck
)./gradlew check
)docs
directory