mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Add support for _ placeholder. (#661)
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
Jon Meow
parent
c3c89a77a4
commit
def98d1182
@@ -105,7 +105,8 @@ auto Expression::MakeIdentifierExpression(int line_num, std::string var)
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Expression::MakeBindingExpression(int line_num, std::string var,
|
||||
auto Expression::MakeBindingExpression(int line_num,
|
||||
std::optional<std::string> var,
|
||||
const Expression* type)
|
||||
-> const Expression* {
|
||||
auto* v = new Expression();
|
||||
@@ -280,11 +281,17 @@ void PrintExp(const Expression* e) {
|
||||
case ExpressionKind::IdentifierExpression:
|
||||
std::cout << e->GetIdentifierExpression().name;
|
||||
break;
|
||||
case ExpressionKind::BindingExpression:
|
||||
PrintExp(e->GetBindingExpression().type);
|
||||
case ExpressionKind::BindingExpression: {
|
||||
const BindingExpression& binding = e->GetBindingExpression();
|
||||
if (binding.name.has_value()) {
|
||||
std::cout << *binding.name;
|
||||
} else {
|
||||
std::cout << "_";
|
||||
}
|
||||
std::cout << ": ";
|
||||
std::cout << e->GetBindingExpression().name;
|
||||
PrintExp(e->GetBindingExpression().type);
|
||||
break;
|
||||
}
|
||||
case ExpressionKind::CallExpression:
|
||||
PrintExp(e->GetCallExpression().function);
|
||||
if (e->GetCallExpression().argument->tag() ==
|
||||
|
||||
Reference in New Issue
Block a user