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

Updates TDL syntax for macro invocations, expr groups, and variable expansions #951

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

popematt
Copy link
Contributor

@popematt popematt commented Oct 3, 2024

Issue #, if available:

amazon-ion/ion-docs#343
amazon-ion/ion-docs#344

Description of changes:

This updates ion-java to use the TDL syntax proposed in the above issues. (But this PR does not include updating the E-Expression syntax for expression groups.)

Overall, I think the proposed syntax results in simpler code for writing macro definitions in the managed writer and simpler code for compiling the macro templates. So it seems like the proposed changes are positive for users and implementors.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

codecov bot commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 74.71264% with 22 lines in your changes missing coverage. Please review.

Please upload report for BASE (ion-11-encoding@492323f). Learn more about missing BASE report.

Files with missing lines Patch % Lines
.../com/amazon/ion/impl/bin/IonRawBinaryWriter_1_1.kt 0.00% 12 Missing ⚠️
...in/java/com/amazon/ion/impl/macro/MacroCompiler.kt 84.09% 3 Missing and 4 partials ⚠️
...va/com/amazon/ion/impl/bin/IonManagedWriter_1_1.kt 86.66% 0 Missing and 2 partials ⚠️
...n/java/com/amazon/ion/impl/IonRawTextWriter_1_1.kt 93.75% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##             ion-11-encoding     #951   +/-   ##
==================================================
  Coverage                   ?   70.02%           
  Complexity                 ?     6879           
==================================================
  Files                      ?      196           
  Lines                      ?    27110           
  Branches                   ?     4899           
==================================================
  Hits                       ?    18985           
  Misses                     ?     6612           
  Partials                   ?     1513           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -30,6 +30,8 @@

/**
* Tests that Ion 1.1 encoding directives are correctly compiled from streams of Ion data.
*
* Don't attempt fix this without ensuring that MacroCompilerTest and IonManagesWriter_1_1_Test are working first.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, that was a note to myself that I should resolve failing tests in the other test classes before dealing with the tests in this class. I'll remove it.

@@ -115,7 +115,7 @@ class MacroCompilerTest {
BoolValue(emptyList(), false),
)
),
"""(macro using_expr_group () (values (; 42 "hello" false)))""" shouldCompileTo TemplateMacro(
"""(macro using_expr_group () (.values (.. 42 "hello" false)))""" shouldCompileTo TemplateMacro(
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we allowing (..42 "hello" false) (i.e., no whitespace after ..)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, they are already syntactically identical because of the rules for parsing symbols inside of s-expressions. For example, (+x) is equivalent to ( + x ), and this falls under those same rules.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, just wanted to make sure we're not planning to go out of our way to prohibit that in this case. I'm happy not to.

@popematt popematt merged commit fc8f49e into amazon-ion:ion-11-encoding Oct 3, 2024
9 checks passed
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.

2 participants