Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro invocations + macro_rules! #50

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

Bromeon
Copy link
Collaborator

@Bromeon Bromeon commented Jan 23, 2024

Initial support for declarative/function-style procedural macro invocations, as well as macro_rules! declarations.

fn_macro!(args);

block_macro! {
    fn inner_fn() -> bool;
}

#[macro_export]
macro_rules! stringificate {
    ($item:item) => {
        stringify!($item)
    };
}

Currently limited to mod/impl/trait blocks.

Later I'd like to add support for struct, enum and union, so that a macro can appear in place of a struct field or enum/union variant (e.g. between commas).

I do not plan to support all possible positions where macros are syntactically allowed in Rust (e.g. where clauses), as that would significantly increase the complexity of the parser, for relatively little benefit in everyday life. The above-mentioned items on the other hand are rather common candidates for macros.

So far limited to mod, impl, trait blocks.
@PoignardAzur
Copy link
Owner

LGTM.

@PoignardAzur PoignardAzur self-requested a review January 25, 2024 12:30
@Bromeon Bromeon merged commit da16d1e into PoignardAzur:main Jan 25, 2024
3 checks passed
@Bromeon Bromeon deleted the feature/macros branch January 25, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants