diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-11-18 09:54:16 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-11-18 17:47:12 +0800 |
commit | c1794a25c7dcecb008565ffe63623ea6cc007db5 (patch) | |
tree | 80f9f1fa1869190262e94e3ee33df1115e498719 | |
parent | 2134d5f477bdb45de99aeb758b1f36a1009446f8 (diff) | |
download | mrust-c1794a25c7dcecb008565ffe63623ea6cc007db5.tar.gz |
macro_rules - Support parsing if-elseif chains
-rw-r--r-- | src/macro_rules/eval.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/macro_rules/eval.cpp b/src/macro_rules/eval.cpp index 05c02248..6344b26a 100644 --- a/src/macro_rules/eval.cpp +++ b/src/macro_rules/eval.cpp @@ -1325,17 +1325,35 @@ namespace consume_tt(lex); break; case TOK_RWORD_IF: - lex.consume(); - consume_expr(lex, true); - if( lex.next() != TOK_BRACE_OPEN ) - return false; - consume_tt(lex); - if( lex.next() == TOK_RWORD_ELSE ) + while(1) { + assert(lex.next() == TOK_RWORD_IF); lex.consume(); + if(lex.next() == TOK_RWORD_LET) + { + lex.consume(); + if( !consume_pat(lex) ) + return false; + if( lex.next() != TOK_EQUAL ) + return false; + lex.consume(); + } + if( !consume_expr(lex, true) ) + return false; if( lex.next() != TOK_BRACE_OPEN ) return false; consume_tt(lex); + if( lex.next() != TOK_RWORD_ELSE ) + break; + lex.consume(); + + if( lex.next() != TOK_RWORD_IF ) + { + if( lex.next() != TOK_BRACE_OPEN ) + return false; + consume_tt(lex); + break; + } } break; default: |