diff options
-rw-r--r-- | src/ast/expr.cpp | 11 | ||||
-rw-r--r-- | src/ast/path.cpp | 2 | ||||
-rw-r--r-- | src/ast/pattern.cpp | 19 | ||||
-rw-r--r-- | src/parse/token.cpp | 6 |
4 files changed, 31 insertions, 7 deletions
diff --git a/src/ast/expr.cpp b/src/ast/expr.cpp index 6983221d..65048183 100644 --- a/src/ast/expr.cpp +++ b/src/ast/expr.cpp @@ -231,7 +231,16 @@ NODE(ExprNode_IfLet, { }) NODE(ExprNode_Integer, { - os << m_value << "_" << m_datatype; + if( m_datatype == CORETYPE_CHAR ) + os << "'\\u{" << ::std::hex << m_value << ::std::dec << "}'"; + else + { + os << m_value; + if( m_datatype == CORETYPE_ANY ) + ; + else + os << "_" << coretype_name(m_datatype); + } },{ return NEWNODE(ExprNode_Integer, m_value, m_datatype); }) diff --git a/src/ast/path.cpp b/src/ast/path.cpp index f02f48fb..da86b066 100644 --- a/src/ast/path.cpp +++ b/src/ast/path.cpp @@ -14,7 +14,7 @@ namespace AST { // --- AST::PathBinding ::std::ostream& operator<<(::std::ostream& os, const PathBinding& x) { TU_MATCH(PathBinding, (x), (i), - (Unbound, os << "UNBOUND"; ), + (Unbound, os << "_"; ), (Crate , os << "Crate"; ), (Module, os << "Module"; ), (Trait, os << "Trait"; ), diff --git a/src/ast/pattern.cpp b/src/ast/pattern.cpp index bfcc6eeb..b3c4f2f2 100644 --- a/src/ast/pattern.cpp +++ b/src/ast/pattern.cpp @@ -75,11 +75,23 @@ namespace AST { } return os; } +::std::ostream& operator<<(::std::ostream& os, const PatternBinding& pb) +{ + if( pb.m_mutable ) + os << "mut "; + switch(pb.m_type) + { + case PatternBinding::Type::MOVE: break; + case PatternBinding::Type::REF: os << "ref "; break; + case PatternBinding::Type::MUTREF: os << "ref mut "; break; + } + os << pb.m_name; + return os; +} ::std::ostream& operator<<(::std::ostream& os, const Pattern& pat) { - os << "Pattern("; if( pat.m_binding.is_valid() ) { - os << pat.m_binding.m_name << " @ "; + os << pat.m_binding << " @ "; } TU_MATCH(Pattern::Data, (pat.m_data), (ent), (MaybeBind, @@ -128,7 +140,7 @@ namespace AST { os << ", "; } if( ent.extra_bind.is_valid() ) - os << ent.extra_bind.m_name; + os << ent.extra_bind; os << ".."; needs_comma = true; @@ -141,7 +153,6 @@ namespace AST { os << "]"; ) ) - os << ")"; return os; } void operator%(Serialiser& s, Pattern::Value::Tag c) { diff --git a/src/parse/token.cpp b/src/parse/token.cpp index 13af2043..69b952cc 100644 --- a/src/parse/token.cpp +++ b/src/parse/token.cpp @@ -293,7 +293,11 @@ struct EscapedString { case TOK_INTERPOLATED_TYPE: return "/*:ty*/"; case TOK_INTERPOLATED_PATH: return "/*:path*/"; case TOK_INTERPOLATED_PATTERN: return "/*:pat*/"; - case TOK_INTERPOLATED_EXPR: return "/*:expr*/"; + case TOK_INTERPOLATED_EXPR: { + ::std::stringstream ss; + reinterpret_cast<const ::AST::ExprNode*>(m_data.as_Fragment())->print(ss); + return ss.str(); + } case TOK_INTERPOLATED_STMT: return "/*:stmt*/"; case TOK_INTERPOLATED_BLOCK: return "/*:block*/"; case TOK_INTERPOLATED_META: return "/*:meta*/"; |