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

Parse macro invocations containing $ #96

Merged
merged 6 commits into from
Mar 8, 2022

Conversation

ninevra
Copy link
Contributor

@ninevra ninevra commented Dec 2, 2020

Closes #95.

Adds a set of productions for general delimited token trees. These productions do not attempt to find macro_rules!-specific features like repetitions, and consider $ to be a normal token. For backwards compatibility, use of the new productions aliases them to token_tree.

Blocks draft #93, which adds similar productions; #93 could be rebased on top of this if relevant.

Copy link
Contributor

@aryx aryx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rebase on the latest so there is no conflict?


_non_delim_token: $ => choice(
$._non_special_token,
'$'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need other characters here? This is needed just for '$'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe $ is the only character we need to add here. _non_special_token is analogous to the first branch of the MacroMatch construction in the reference, which allows any token other than $ and delimiters.

@ninevra
Copy link
Contributor Author

ninevra commented Mar 5, 2022

Sorry, I've been away from github for a few months. I'll take a look at this and see if I can rebase & address comments soon.

Metavariables can only occur in macro transcribers, so matching them in 
invocations makes little sense. Instead, match $ and an identifier 
separately.
Allows deduplicating _common_token and _non_special_token
@ninevra ninevra force-pushed the macro-invocation-dollar-sign branch from e3ad491 to ae4bf74 Compare March 8, 2022 02:13
@ninevra
Copy link
Contributor Author

ninevra commented Mar 8, 2022

Rebased to resolve merge conflicts.

Removed special handling of metavariables ($ident, $crate) in macro invocations, as those are specific to macro transcribers.

@ninevra ninevra requested a review from aryx March 8, 2022 02:25
@aryx
Copy link
Contributor

aryx commented Mar 8, 2022

This looks good! I guess this can unblock your other PRs now!

@aryx aryx merged commit 9cede24 into tree-sitter:master Mar 8, 2022
@ninevra
Copy link
Contributor Author

ninevra commented Mar 8, 2022

Thanks for merging! I'll work on rebasing #93.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse error on $ in macro invocations
2 participants