From 387a8358dd42355fc88a0b8c4779a0e2b0296d32 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 25 Feb 2016 16:00:44 +0800 Subject: Parse/use - Fix parsing of braces and renames --- src/parse/root.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/parse/root.cpp b/src/parse/root.cpp index 5706d958..aa3b78d7 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -1024,17 +1024,28 @@ void Parse_Use_Set(TokenStream& lex, const AST::Path& base_path, ::std::function Token tok; do { - + AST::Path path; + ::std::string name; if( GET_TOK(tok, lex) == TOK_RWORD_SELF ) { - fcn(base_path, base_path[base_path.size()-1].name()); + path = ::AST::Path(base_path); + name = base_path[base_path.size()-1].name(); } else if( tok.type() == TOK_BRACE_CLOSE ) { break ; } else { CHECK_TOK(tok, TOK_IDENT); - fcn(base_path + AST::PathNode(tok.str(), {}), tok.str()); + path = base_path + AST::PathNode(tok.str(), {}); + name = mv$(tok.str()); + } + if( GET_TOK(tok, lex) == TOK_RWORD_AS ) { + GET_CHECK_TOK(tok, lex, TOK_IDENT); + name = mv$(tok.str()); + } + else { + lex.putback(tok); } + fcn(mv$(path), mv$(name)); } while( GET_TOK(tok, lex) == TOK_COMMA ); lex.putback(tok); } -- cgit v1.2.3