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

XRBK macro: rewrite with chumsky crate #98

@Antikyth

Description

@Antikyth

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or requesttaskAn essential task for a planned milestone.

    Type

    No type

    Projects

    Status

    Unassigned

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions