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

Reworking some Julia AST forms #88

Closed
33 tasks done
c42f opened this issue Sep 1, 2022 · 3 comments
Closed
33 tasks done

Reworking some Julia AST forms #88

c42f opened this issue Sep 1, 2022 · 3 comments
Labels
design enhancement New feature or request trees
Milestone

Comments

@c42f
Copy link
Member

c42f commented Sep 1, 2022

With JuliaSyntax, we've got our own green tree (GreenNode) and AST (SyntaxNode) which often differ from Expr, due to the requirement that children are strictly in source order. Some current differences are described in https://github.com/JuliaLang/JuliaSyntax.jl#tree-differences-between-greennode-and-expr. Given that we've been forced to diverge we might as well make the most of this and reconsider some aspects of Expr for two reasons:

  • To give extra textural information to users of green tree (eg, presence of parentheses), without the need to recompute this information by inspecting the trivia. (These nodes will probably be elided during AST conversion?)
  • To give extra information to AST users like macro writers (eg, conditional ternary is the same as :if for Expr users)

List of possible changes

Considered and rejected for now

  • :toplevel expressions occur both at file scope and as ;-delimited expressions at file scope. This seems kind of weird?
  • Is it possible to improve the representation of global x,y vs global x vs global (x,y) = (1,2) vs global (x,y)? (In particular, the variables might or might not be enclosed in a tuple.)
  • Lower cmd strings to Core.@cmd later, not inside parser
  • Lower custom string and cmd macros to macrocall later, not inside parser
  • Infix vs prefix calls - should this be managed in flags or a kind like K"infix_call"? (considered and decided against in AST inconsistency between parsing of = vs kw  #99 and Record fixity of call type in flags #124)
@c42f c42f added the enhancement New feature or request label Sep 2, 2022
@c42f c42f added the design label Sep 21, 2022
c42f added a commit that referenced this issue Sep 21, 2022
This allows REPL completion to work correctly. It works by pattern matching the parse tree, rather than hard coding incomplete expression detection into the parser itself. There's still more changes from #88 which would help make this nicer but for now it works.

The tests here are somewhat derived from Base, but had to be reviewed and tweaked because they turn out to not really be consistent. For example, "begin;" and "begin" are both the prefix of a block construct, one of them shouldn't come out as `:other`.
@c42f c42f added the trees label Sep 21, 2022
This was referenced Mar 28, 2023
@c42f c42f added this to the 0.4 milestone Mar 31, 2023
c42f added a commit that referenced this issue Apr 23, 2023
Copy this list from issue #88 to the docs.
@c42f
Copy link
Member Author

c42f commented Apr 23, 2023

I think this is done for now. It's become quite an epic list of changes 😬

There might be more but they can go in separate issues I guess.

@c42f c42f closed this as completed Apr 23, 2023
c42f added a commit that referenced this issue Apr 23, 2023
Copy this list from issue #88 to the docs.
@timholy
Copy link
Member

timholy commented Apr 23, 2023

Seems like a considerable increase in consistency!

@c42f
Copy link
Member Author

c42f commented Apr 24, 2023

Thanks I hope so! It added up to a lot of rearrangement :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design enhancement New feature or request trees
Projects
None yet
Development

No branches or pull requests

2 participants