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

Allows readers to interpret macro invocations as encoding directives. #976

Conversation

tgregg
Copy link
Contributor

@tgregg tgregg commented Oct 17, 2024

Description of changes:
Builds on #973 to allow the readers to correctly interpret the set_macros, add_macros, set_symbols, and add_symbols system macros as encoding directives.

As noted in the JavaDoc atop the EncodingDirectiveReader class, this PR includes some duplication between the top-level EncodingDirectiveReader and the one built into the core binary reader. We have a path to unifying these implementations in the future, but that is out of scope for this PR.

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

@tgregg tgregg requested a review from popematt October 17, 2024 19:47
override fun iterateTypeAnnotations(): MutableIterator<String>? = currentValueExpression?.annotations?.mapTo(mutableListOf()) { it.assumeText() }?.iterator()
override fun iterateTypeAnnotations(): MutableIterator<String> {
return currentValueExpression?.annotations?.mapTo(mutableListOf()) { it.assumeText() }?.iterator()
?: return Collections.emptyIterator()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IonReader.iterateTypeAnnotations() is documented to return non-null.

@@ -22,8 +22,11 @@ internal class EncodingDirectiveReader(private val reader: IonReader, readerAdap
private var state: State = State.READING_VALUE

var isSymbolTableAppend = false
var isMacroTableAppend = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious... can this non-append concatenations?

$ion_encoding::(
  (symbol_table [a, b, c] $ion_encoding [g, h, i])
  (macro_table (macro pi () 3.14159) $ion_encoding)
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, not yet. I created #977

return makeSymbolsMap(FIRST_LOCAL_SYMBOL_ID, symbols);
}

private static void writeSymbolTableAppendMacroInvocation(IonRawWriter_1_1 writer, Map<String, Integer> existingSymbols, String... newSymbols) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The combination of "SymbolTableAppendMacro" got me confused. Maybe E-Expression would be a better choice here (and in the similar methods)?

Suggested change
private static void writeSymbolTableAppendMacroInvocation(IonRawWriter_1_1 writer, Map<String, Integer> existingSymbols, String... newSymbols) {
private static void writeSymbolTableAppendEExpression(IonRawWriter_1_1 writer, Map<String, Integer> existingSymbols, String... newSymbols) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@tgregg tgregg force-pushed the ion-11-encoding-read-encoding-directives-from-invocations branch from bf2951e to 64610d7 Compare October 17, 2024 21:32
@tgregg tgregg merged commit c608965 into ion-11-encoding Oct 17, 2024
16 checks passed
@tgregg tgregg deleted the ion-11-encoding-read-encoding-directives-from-invocations branch October 17, 2024 21:38
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