What does "error: expected open delimiter" mean when calling a rust macro?

I have a macro like this:

macro_rules! expect_token (
    ([$($token:matchers, $result:expr)|+] <= $tokens:ident, $parsed_tokens:ident, $error:expr) => (
        match $tokens.pop() {
            $(
                Some($token) => {
                    $parsed_tokens.push($token);
                    $result
                },
             )+
             None => {
                 $parsed_tokens.reverse();
                 $tokens.extend($parsed_tokens.into_iter());
                 return NotComplete;
             },
            _ => return error(expr)
        }
    );
)

      

when i call it on error expect_token!([Ident(name), name] <= tokens, parsed_tokens, "expected function name in prototype");

i get the error ": expected open delimiter".

What does this error mean and what am I doing wrong?

PS If you are wondering what the definition of type ids is NotComplete

, you can look at https://github.com/jauhien/iron-kaleidoscope/blob/master/src/parser.rs , but this is not relevant to this question as far as I understand, since the problem is not with the body of the macro, but with its call.

+3


source to share


1 answer


Ok, I found the answer: matchers

must be enclosed in parentheses in macro calls. The problem was that I didn't understand matches as the left side of the matching rules, while they follow the macro rules that are clearly stated in the documentation.



PS As for all the macros I gave as an example, this is so wrong. )

0


source







All Articles