Skip to content
This repository has been archived by the owner on Nov 12, 2023. It is now read-only.

XRBK macro: rewrite with chumsky crate #98

Open
Antikyth opened this issue Feb 3, 2023 · 0 comments
Open

XRBK macro: rewrite with chumsky crate #98

Antikyth opened this issue Feb 3, 2023 · 0 comments
Labels
bug Something isn't working enhancement New feature or request task An essential task for a planned milestone.

Comments

@Antikyth
Copy link
Collaborator

Antikyth commented Feb 3, 2023

I believe it should be possible to use chumsky to interpret the tokens of a proc macro. I think that chumsky's API, with the use of parser combinators, can allow for much more concise code for XRBK macro with much faster prototyping/syntax changes. I also think it can allow for much easier recovery for errors (e.g. if a reply has no #[sequence] attribute).

My rough understanding from ~15 minutes of research is that chumsky can be used where:

  • proc_macro::TokenTree is the most basic form of token which is processed.
  • syntax errors to do with XRBK macro's syntax are emitted instead of the output, turned into a compile_error!(...) macro invocation (unresolved question: what happens if you generate the output which could be recovered as well as putting the compile_error!(...) in the place where the error is? could an IDE still provide suggestions for the other code in that case?).
  • syntax errors in normal Rust syntax are completely recovered, with the invalid Rust syntax being output. This is so the existing Rust tools can handle those errors properly, which they can do better than XRBK macro would be able to do with just a compile_error!(...) invocation.
@Antikyth Antikyth added bug Something isn't working enhancement New feature or request task An essential task for a planned milestone. labels Feb 3, 2023
@github-project-automation github-project-automation bot moved this to Unassigned in X Rust Bindings Feb 3, 2023
@Antikyth Antikyth pinned this issue Feb 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement New feature or request task An essential task for a planned milestone.
Projects
Status: Unassigned
Development

Successfully merging a pull request may close this issue.

1 participant