fix: empty _command_list_body and list_body#234
fix: empty _command_list_body and list_body#234blindFS wants to merge 7 commits intonushell:mainfrom
Conversation
|
@mkatychev, sorry to ping you on an irrelevant PR. I'm confused at the failed CI pipeline, do you happen to know what's going on? |
|
I'll look more into it tomorrow but I've encountered similar messages and it was an issue with the |
|
@blindFS I finally narrowed down the problem, until tree-sitter/node-tree-sitter#258 is merged, node isn't compatible with 0.25 basically since there's breaking ABI changes that haven't been addressed. So either temporarily drop node support or temporarily downgrade the ABI. |
Thanks a lot, I'll disable BTW, it will be super helpful if you review this PR in your spare time. A lot of conflicts for this minor edge case is kinda silly, but I really run out of ideas here. The basic idea behind this PR is that, previously, there's a [
,
]which covers the commas and newlines between brackets, it's somewhat annoying for topiary, so I make this kind of empty body contents anonymous in this PR. The |
|
ping me when you're ready to land it. |
Sure |
|
@blindFS I'll post my general comments initially:
I managed to greatly simplify the
In general handling whitespace explicitly (the
With the whitespace mention above Ideally a list node should have a simple definition: ...this could further be reduced by keeping newlines as part of extras Footnotes
|
| ), | ||
| general_body_rules('entry', $.val_entry, $._entry_separator, $._newline), | ||
|
|
||
| _list_body_or_empty: ($) => |
There was a problem hiding this comment.
going more off of #234 (comment)
the presences of rules like _list_body_or_empty feels like a smell because such a type should be simply handled by a repeat.
Ideally a list should have as simple a rule as possible so that most edge cases are handled within the _*_entry rule:
list: ($) => seq('[', repeat(choice($._list_entry, ',')), ']'),
Handling newlines explicitly where their presence does not matter feels like a design problem (exclusion from extras).
In topiary's case I think turning an |
|
@mkatychev Thanks a lot for the reviewing. The removing of newline in extras #139 does seem to cause a lot of trouble. As I recall, it mainly solves the issue of multiline binary-op. That issue might be solvable with some careful tuning of precedence. I'll try it on the old grammar.js before #139 but I feel pessimistic about it. I'll let you know if I run into troubles. |
|
Please let me know if you have issues, you can generally get away with this kind of thing without resorting to |
You mean getting rid of |
|
@mkatychev Oh, I think I remember what was the problem: There's a fundamental difference between (foo
bar # bar is the argument of command foo
)
foo
bar # a different commandIt seems the only way to differentiate them is to specify newlines in an explicit way. Two possibilities: Explicit
|
|
I think moving |
|
I see your case, I think the terminator case is most similar to python/justfile indentation: |
|
Hi @mkatychev, I've managed to fix most of the Then I found another trickier problem: To prevent However the spaces introduced in explicit JS rules always have higher precedence than those of Then the following code will be parsed incorrectly, as a block with single command of 3 string arguments: {
print foo
print foo
}BC the spaces before the 2nd |
|
Would you mind elaborating on |
Actually I'm not quite sure how it ended up like that (after conflict resolving), but the parser thought |
Make it easy for blindFS/topiary-nushell#39 (comment)
Also fixes a minor issue of empty command_list
Although this PR introduces 6 more conflicts, it hardly hurts lex state counts and WASM comp time, should be safe to merge.