Are macros with "inline matchers" possible? #972
Replies: 1 comment 15 replies
-
Could you separate the error creation from populating the span?
Then don't use
I don't follow this part. An alternative approach, might be to just make all the values options:
And then check each of the options for None in the action code and return errors accordingly. I haven't thought too hard about whether this approach ends up equivalent after macro expansion or not though. Possibly it would cause parse generation errors. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Let's suppose I have the following matcher:
Given the nature of the syntax, pretty much every expression is surrounded by parenthesis. With my goal to provide as good of an error message as possible, I'm looking to make the parenthesis "optional", and push an error if that was the case. So I tried creating the following macro:
Now, I would basically like to inline my complete matcher in this macro, but I'm not sure how that would syntactically work, even given just
@L
, and@R
, probably not like this:Maybe something like this would be possible?
What currently seems to work, is creating an "Inner" parser that does not contain any parenthesis, e.g.:
and then creating the normal parser like this:
But now,
left
, andright
are inside the parenthesis, which isn't terrible, but not what I wanted. In addition, I would have to declare two of every parser, which is a bit "meh" as well.Is there any clever trick / syntax I'm missing?
Thanks for any help and pointers in advance! :)
Beta Was this translation helpful? Give feedback.
All reactions