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

[v2] more predictable slashdash #407

Merged
merged 5 commits into from
Nov 29, 2024
Merged

[v2] more predictable slashdash #407

merged 5 commits into from
Nov 29, 2024

Conversation

zkat
Copy link
Member

@zkat zkat commented Nov 27, 2024

Fixes: #401

@zkat zkat requested review from tabatkins and larsgw November 27, 2024 08:06
@zkat zkat marked this pull request as draft November 27, 2024 08:07
@zkat zkat marked this pull request as ready for review November 28, 2024 07:51
@zkat
Copy link
Member Author

zkat commented Nov 28, 2024

Alright, this is ready. I actually really like these changes, but I could use a second set of eyes. Getting rid of the weird optional/required-node-space shenanigans and not treating slashdash as grammatical whitespace really simplified things, imo. So, as far as the parser is concerned, /- is a full node, it's just one that won't show up in the post-parse document data.

@zkat
Copy link
Member Author

zkat commented Nov 28, 2024

also worth noting: This restricts /- { child1 } to only being present after props and arguments, so the following is not legal:

node /-{child1} foo;

but this is:

node foo /-{one} {two} /-{three}

I believe this is what you were hoping for, @tabatkins?

@zkat zkat force-pushed the zkat/refine/- branch 2 times, most recently from e99256e to b05079c Compare November 28, 2024 08:21
@zkat zkat linked an issue Nov 28, 2024 that may be closed by this pull request
Copy link
Contributor

@tabatkins tabatkins left a comment

Choose a reason for hiding this comment

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

Very minor style nit, otherwise r+

SPEC.md Outdated
final-node := base-node optional-node-space node-terminator?
node-prop-or-arg := prop | value
base-node := slashdash? type? node-space* string
(node-space+ node-prop-or-arg)*
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for consistency, I'd move the optional slashdash to here, rather than putting it into node-prop-or-arg.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. Additionally, I just realized I didn’t put any space allowances around the /-. I’m thinking of making it like:

slashdash := '/-' line-space*

Which means that these would both be legal:

// Very reasonable, IMO
/-
node 1 2 3

// interesting and I think acceptable—it means you can use them like esclines:

node 1 /-
2 3

We can totally ban the second behavior but I think it’s better than having to special case allowing esclines after the /-. This way, we just say “/- consumes all following line-space, and the next “item”, regardless of where you put it (as long as it’s a legal /- location“.

Interestingly, that implies the following are legal too:

node /- //next thing is commented
  foo

node /- /* commented */ foo

I’ll have to adjust the spec prose too, to clarify that these cases are possible.

@zkat zkat requested a review from tabatkins November 29, 2024 05:03
@zkat zkat merged commit 90e22bc into kdl-v2 Nov 29, 2024
@zkat zkat deleted the zkat/refine/- branch November 29, 2024 06:53
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.

optional-node-space around equals sign in properties
2 participants