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.
- Check
- 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.