✨ feat(mq-macros): add proc-macro crate and refactor builtin definitions#1682
✨ feat(mq-macros): add proc-macro crate and refactor builtin definitions#1682
Conversation
Introduce `mq-macros` crate with `#[mq_fn]` attribute macro to replace the local `define_builtin!` macro in `mq-lang`, making builtin function definitions more idiomatic and type-explicit.
There was a problem hiding this comment.
Pull request overview
This PR introduces a new internal procedural macro crate, mq-macros, and uses it to replace the local builtin-definition macro in mq-lang. In the broader codebase, this refactors how builtin functions are declared and dispatched without changing the builtin surface area itself.
Changes:
- Added a new
mq-macrosproc-macro crate with#[mq_fn]andbuiltin_dispatch!for builtin registration/lookup code generation. - Rewrote
mq-langbuiltin definitions from inline macro invocations to named Rust functions annotated with#[mq_fn]. - Wired the new crate into the workspace and
mq-langdependency graph.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/mq-macros/src/lib.rs | Adds the new proc-macro implementations for builtin statics and dispatch generation. |
| crates/mq-macros/Cargo.toml | Declares the new proc-macro crate and its parsing/codegen dependencies. |
| crates/mq-lang/src/eval/builtin.rs | Migrates builtin declarations to annotated functions and replaces manual hash dispatch with macro-generated dispatch. |
| crates/mq-lang/Cargo.toml | Adds the new internal macro crate as a dependency. |
| Cargo.toml | Registers mq-macros as a workspace member and workspace dependency. |
| Cargo.lock | Locks the new crate and dependency graph changes. |
| use proc_macro::TokenStream; | ||
| use proc_macro2::{Span, TokenStream as TokenStream2}; | ||
| use quote::quote; |
| #[proc_macro] | ||
| pub fn builtin_dispatch(input: TokenStream) -> TokenStream { |
|
@copilot |
Done in d543419. The
The duplicate definition in |
Introduce
mq-macroscrate with#[mq_fn]attribute macro to replace the localdefine_builtin!macro inmq-lang, making builtin function definitions more idiomatic and type-explicit.