3
24
Fork
You've already forked krabby
0

Implement declarative macro expansion #13

Open
opened 2025年12月15日 12:45:34 +01:00 by bal-e · 2 comments
Owner
Copy link

rustc-expand is rustc's internal crate for this; the underlying logic needs to be ported over (with as few modifications as possible). It also includes proc macro stuff, but we can address that separately -- it has many more complications. Ideally, the result should be a fairly stand-alone krabby-decl-macros crate.

Implementation steps:

  • A type definition for a declarative macro (effectively its HIR).
    • Check rustc-expand's support for declarative attribute macros.
  • Parsing macro_rules! into that definition.
  • Helpers to parse/validate meta-variables.
    • Note, may end up in the middle of a doc comment token.
    • Expressions.
    • Patterns.
    • Items.
    • Statements.
    • Types.
    • Paths.
    • Token trees.
    • Token streams (for tt-munchers).
  • Recognizing match arms against an input (and capturing meta-variables).
  • Assigning hard-coded output tokens the right hygiene context.
  • Substituting meta-variables into an output expression.
  • The top-level invocation function.
`rustc-expand` is rustc's internal crate for this; the underlying logic needs to be ported over (with as few modifications as possible). It also includes proc macro stuff, but we can address that separately -- it has many more complications. Ideally, the result should be a fairly stand-alone `krabby-decl-macros` crate. Implementation steps: - [x] A type definition for a declarative macro (effectively its HIR). - [ ] Check `rustc-expand`'s support for declarative attribute macros. - [ ] Parsing `macro_rules!` into that definition. - [ ] Helpers to parse/validate meta-variables. - Note, may end up in the middle of a doc comment token. - [ ] Expressions. - [ ] Patterns. - [ ] Items. - [ ] Statements. - [ ] Types. - [ ] Paths. - [ ] Token trees. - [ ] Token streams (for tt-munchers). - [ ] Recognizing match arms against an input (and capturing meta-variables). - [ ] Assigning hard-coded output tokens the right hygiene context. - [ ] Substituting meta-variables into an output expression. - [ ] The top-level invocation function.
Collaborator
Copy link

Can you assign me on this issue?

Can you assign me on this issue?
Author
Owner
Copy link

I'll assign you the whole issue for now, but you can choose to split it up and take on one sub-topic at a time.

I'll assign you the whole issue for now, but you can choose to split it up and take on one sub-topic at a time.
Sign in to join this conversation.
No Branch/Tag specified
main
decl-macros
diagnostics
query
nameres
type-ir
scalar-lexer
No results found.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bal-e/krabby#13
Reference in a new issue
bal-e/krabby
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?