From e674cb99edf50de91f8f5aed3188e30ffb7c88d7 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 18 Feb 2016 21:34:00 +1100 Subject: Parser - box Patterns, edge bug fix --- src/parse/lex.cpp | 2 +- src/parse/pattern.cpp | 6 ++++++ src/parse/root.cpp | 1 - 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/parse') diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp index cb97022d..2338adcd 100644 --- a/src/parse/lex.cpp +++ b/src/parse/lex.cpp @@ -989,7 +989,7 @@ void TokenStream::putback(Token tok) { if( m_cache_valid ) { - DEBUG("" << getPosition()); + DEBUG("" << getPosition() << " - Double putback: " << tok << " but " << m_cache); throw ParseError::BugCheck("Double putback"); } else diff --git a/src/parse/pattern.cpp b/src/parse/pattern.cpp index 02286ceb..32d1b017 100644 --- a/src/parse/pattern.cpp +++ b/src/parse/pattern.cpp @@ -108,6 +108,10 @@ AST::Pattern Parse_Pattern(TokenStream& lex, bool is_refutable) return Parse_PatternReal_Path(lex, path, is_refutable); } } + else + { + // Otherwise, fall through + } lex.putback(tok); AST::Pattern pat = Parse_PatternReal(lex, is_refutable); @@ -153,6 +157,8 @@ AST::Pattern Parse_PatternReal1(TokenStream& lex, bool is_refutable) return AST::Pattern( ); case TOK_DOUBLE_DOT: return AST::Pattern( AST::Pattern::TagWildcard() ); + case TOK_RWORD_BOX: + return AST::Pattern( AST::Pattern::TagBox(), Parse_Pattern(lex, is_refutable) ); case TOK_DOUBLE_AMP: lex.putback(TOK_AMP); case TOK_AMP: diff --git a/src/parse/root.cpp b/src/parse/root.cpp index 93b360f1..fb7249e4 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -265,7 +265,6 @@ AST::Function Parse_FunctionDef(TokenStream& lex, ::std::string abi, AST::MetaIt else { // Unbound method - lex.putback(tok); // un-eat the '&' } } else if( tok.type() == TOK_RWORD_MUT ) -- cgit v1.2.3