add support for empty nd-array syntax#4
Conversation
What's still missing here is the correct compat check, since this is only supported in Julia 1.8. I wasn't sure how to check for this in `check_ncat_compat`.
There was a problem hiding this comment.
Awesome, this is the first PR to this repo!
For now, this will need the tests like [;;] ==> (ncat 2) added in test/parser.jl (actually this should be (ncat-2) because the 2 is stored in the flags, not as a child node in the tree. Search for similar tests to figure out where best to add them.
For interactively developing the parser and tests, I'd suggest using the itest_parse function which will check several things and do some pretty printing:
julia> include("test/test_utils.jl")
julia> itest_parse(JuliaSyntax.parse_atom, "[;;]")
# Code:
[;;]
# Green tree:
1:4 │[error] ✘
1:4 │ [ncat]
1:1 │ [ "["
2:2 │ ; ";"
3:3 │ ; ";"
4:4 │ ] "]"
Error: unexpected closing token:
[;;]
Error: multidimensional array syntax not supported in Julia version 1.6 < 1.7:
[;;]
# SyntaxNode:
(error (ncat-2))
# Julia Expr:
:($(Expr(:error, :([;;]))))
# AST dump
Expr
head: Symbol error
args: Array{Any}((1,))
1: Expr
head: Symbol ncat
args: Array{Any}((1,))
1: Int64 2
# flisp Julia Expr:
:($(Expr(:error, "unexpected \";\"")))
Also, optional... but perhaps consider moving this logic to the top of On second though, I don't know if this is useful. Either way is fine and what you have is more direct.parse_array, because that's the function which handles the rest of ncat syntax?
I wasn't sure how to check for this in
check_ncat_compat.
This should already work as-is, because you emit K"ncat" and check_ncat_compat just checks for that.
Oh, I see the problem... it's not the same version check as other We could consider adding the version check immediately where you detect the |
Ok, I can do that. My initial thought was that we could maybe also just check if the |
We'd have to add more sophisticated ways of looking back on the output to make that easy. That's possible, but I do like to avoid it because I think it leads to confusing code. I'd even like to remove |
| # [;;] ==> (ncat 2) | ||
| # [;; \n ] ==> (ncat 2) |
There was a problem hiding this comment.
I'll fix these separately to keep them in sync with the actual tests (yeah, I need to improve the tooling so we don't need to repeat ourselves 😅 )
There was a problem hiding this comment.
Oops! Yeah, I think I was just thinking of the s-expression syntax instead of JuliaSyntax' one.
|
This looks excellent, thanks :-D |
What's still missing here is the correct compat check, since this is
only supported in Julia 1.8. I wasn't sure how to check for this in
check_ncat_compat.