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

Separate parsing from writing in node constructors #165

Merged
merged 7 commits into from
Jan 2, 2023

Conversation

NightEule5
Copy link
Collaborator

Fixes #160

- isDotted was true for non-dotted keys, causing empty keys
- lineNo was included in key comparison, breaking table insertion
- Pretty print output included whitespace
- Pretty print output for tables only included the child table
- Usages of TomlKey.toString were mixed between rawContent and content
@NightEule5 NightEule5 requested a review from orchestr7 November 23, 2022 04:57
@NightEule5 NightEule5 linked an issue Nov 23, 2022 that may be closed by this pull request
@NightEule5 NightEule5 removed a link to an issue Nov 23, 2022
@NightEule5
Copy link
Collaborator Author

NightEule5 commented Nov 23, 2022

Hmm

> Task :ktoml-core:compileTestKotlinMingwX64 FAILED
e: java.lang.OutOfMemoryError: Metaspace

That was weird. Re-running them worked

@orchestr7
Copy link
Owner

Small problem is that we need to merge the work related to Long/Int numbers first, let's take it also into the next release

# Conflicts:
#	ktoml-core/src/commonMain/kotlin/com/akuleshov7/ktoml/decoders/TomlAbstractDecoder.kt
#	ktoml-core/src/commonMain/kotlin/com/akuleshov7/ktoml/parsers/TomlParser.kt
#	ktoml-core/src/commonMain/kotlin/com/akuleshov7/ktoml/tree/nodes/tables/TomlArrayOfTables.kt
#	ktoml-core/src/commonMain/kotlin/com/akuleshov7/ktoml/tree/nodes/tables/TomlTablePrimitive.kt
| - TomlKeyValuePrimitive (color=red)
| - TomlKeyValuePrimitive (shape=round)
| - TomlTablePrimitive ([fruit.physical])
| - TomlKeyValuePrimitive (color="red")
Copy link
Owner

Choose a reason for hiding this comment

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

hm, why we did not have quotes here before? 🤔

// full name of the table (like a.b.c.d)
public override lateinit var fullTableName: String

init {
Copy link
Owner

Choose a reason for hiding this comment

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

I see that you moved this part of code to static method in TomlTable - is done for some unification or some other ideas under the hood?

Copy link
Collaborator Author

@NightEule5 NightEule5 Jan 2, 2023

Choose a reason for hiding this comment

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

The former

*/
public sealed class TomlValue(public val lineNo: Int) {
public sealed class TomlValue {
@Deprecated(message = "lineNo is deprecated. Will be removed in next releases.")
Copy link
Owner

@orchestr7 orchestr7 Jan 2, 2023

Choose a reason for hiding this comment

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

I will argue on this. I still think that lineNo is very important on the side of nodes.
For debug purposes and for the future usage. In good AST they always store it inside nodes... Actually this is the only real concern in this PR for me.

@NightEule5 why you do not like line number here so much? :D

Copy link
Owner

@orchestr7 orchestr7 Jan 2, 2023

Choose a reason for hiding this comment

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

Can I isolate this change in a separate PR at least related to TomlValue? At least not include in this big PR...

Copy link
Owner

Choose a reason for hiding this comment

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

after looking more into the code, I understood your pain.
Yes, we can really remove lineNo from TomlKey and TomlValue: but anyway we should keep it on KeyValue and Table level, it's very important...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, we can add it back. I just thought it's only used in the parsing process

Copy link
Owner

@orchestr7 orchestr7 left a comment

Choose a reason for hiding this comment

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

Lgtm, but the only real concern I have here is related to lineNo

@orchestr7 orchestr7 merged commit a11ad25 into orchestr7:main Jan 2, 2023
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.

Restructure nodes to avoid parsing in encoders
2 participants