mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 09:24:58 +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
@@ -5,6 +5,7 @@
|
||||
#ifndef EXECUTABLE_SEMANTICS_AST_EXPRESSION_H_
|
||||
#define EXECUTABLE_SEMANTICS_AST_EXPRESSION_H_
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
@@ -74,7 +75,8 @@ struct IndexExpression {
|
||||
|
||||
struct BindingExpression {
|
||||
static constexpr ExpressionKind Kind = ExpressionKind::BindingExpression;
|
||||
std::string name;
|
||||
// nullopt represents the `_` placeholder.
|
||||
std::optional<std::string> name;
|
||||
const Expression* type;
|
||||
};
|
||||
|
||||
@@ -136,7 +138,8 @@ struct TypeTypeLiteral {
|
||||
struct Expression {
|
||||
static auto MakeIdentifierExpression(int line_num, std::string var)
|
||||
-> const Expression*;
|
||||
static auto MakeBindingExpression(int line_num, std::string var,
|
||||
static auto MakeBindingExpression(int line_num,
|
||||
std::optional<std::string> var,
|
||||
const Expression* type)
|
||||
-> const Expression*;
|
||||
static auto MakeIntLiteral(int line_num, int i) -> const Expression*;
|
||||
|
||||
Reference in New Issue
Block a user