mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-26 05:11:16 +00:00
Set up a 'Parse' namespace. (#3161)
Continuing on #3070. I moved ParseTree::Node to just Parse::Node, versus Parse::Tree::Node. Other name changes are just removing "Parse" or "Parser" prefixes. In EnumBase, I'm directly defining operator<< because the ostream.h approach just isn't working, not for either of Parse::State nor Parse::NodeKind. Errors look like: ```toolchain/parser/parser_context.cpp:449:34: error: invalid operands to binary expression ('llvm::raw_ostream' and 'const Carbon::Parse::State') output << "\t" << i << ".\t" << entry.state; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~ ``` The expected template in `Carbon::` is not in the error list; I only see the: ``` ./common/ostream.h:112:6: note: candidate template ignored: requirement 'std::is_base_of_v<std::ostream, llvm::raw_ostream>' was not satisfied [with S = llvm::raw_ostream, T = Carbon::Parse::State] auto operator<<(S& standard_out, const T& value) -> S& { ^ ``` I'm still prodding at this, but not seeing an obvious fix. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
1 parent
64687aa7d1
commit
7157445f97
75 files changed
+1181
-1277
No files matched your search
@@ -6,47 +6,44 @@
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
auto HandleStructComma(Context& context, ParseTree::Node /*parse_node*/)
|
||||
-> bool {
|
||||
auto HandleStructComma(Context& context, Parse::Node /*parse_node*/) -> bool {
|
||||
context.ParamOrArgComma(
|
||||
/*for_args=*/context.parse_tree().node_kind(
|
||||
context.node_stack().PeekParseNode()) !=
|
||||
ParseNodeKind::StructFieldType);
|
||||
Parse::NodeKind::StructFieldType);
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleStructFieldDesignator(Context& context,
|
||||
ParseTree::Node /*parse_node*/) -> bool {
|
||||
auto HandleStructFieldDesignator(Context& context, Parse::Node /*parse_node*/)
|
||||
-> bool {
|
||||
// This leaves the designated name on top because the `.` isn't interesting.
|
||||
CARBON_CHECK(
|
||||
context.parse_tree().node_kind(context.node_stack().PeekParseNode()) ==
|
||||
ParseNodeKind::Name);
|
||||
Parse::NodeKind::Name);
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleStructFieldType(Context& context, ParseTree::Node parse_node)
|
||||
-> bool {
|
||||
auto HandleStructFieldType(Context& context, Parse::Node parse_node) -> bool {
|
||||
auto [type_node, type_id] = context.node_stack().PopExpressionWithParseNode();
|
||||
SemIR::TypeId cast_type_id = context.ExpressionAsType(type_node, type_id);
|
||||
|
||||
auto [name_node, name_id] =
|
||||
context.node_stack().PopWithParseNode<ParseNodeKind::Name>();
|
||||
context.node_stack().PopWithParseNode<Parse::NodeKind::Name>();
|
||||
|
||||
context.AddNodeAndPush(parse_node, SemIR::Node::StructTypeField::Make(
|
||||
name_node, name_id, cast_type_id));
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleStructFieldUnknown(Context& context, ParseTree::Node parse_node)
|
||||
auto HandleStructFieldUnknown(Context& context, Parse::Node parse_node)
|
||||
-> bool {
|
||||
return context.TODO(parse_node, "HandleStructFieldUnknown");
|
||||
}
|
||||
|
||||
auto HandleStructFieldValue(Context& context, ParseTree::Node parse_node)
|
||||
-> bool {
|
||||
auto HandleStructFieldValue(Context& context, Parse::Node parse_node) -> bool {
|
||||
auto [value_parse_node, value_node_id] =
|
||||
context.node_stack().PopExpressionWithParseNode();
|
||||
SemIR::StringId name_id = context.node_stack().Pop<ParseNodeKind::Name>();
|
||||
SemIR::StringId name_id = context.node_stack().Pop<Parse::NodeKind::Name>();
|
||||
|
||||
// Convert the operand to a value.
|
||||
// TODO: We need to decide how struct literals interact with expression
|
||||
@@ -66,14 +63,15 @@ auto HandleStructFieldValue(Context& context, ParseTree::Node parse_node)
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleStructLiteral(Context& context, ParseTree::Node parse_node) -> bool {
|
||||
auto HandleStructLiteral(Context& context, Parse::Node parse_node) -> bool {
|
||||
auto refs_id = context.ParamOrArgEnd(
|
||||
/*for_args=*/true, ParseNodeKind::StructLiteralOrStructTypeLiteralStart);
|
||||
/*for_args=*/true,
|
||||
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart);
|
||||
|
||||
context.PopScope();
|
||||
context.node_stack()
|
||||
.PopAndDiscardSoloParseNode<
|
||||
ParseNodeKind::StructLiteralOrStructTypeLiteralStart>();
|
||||
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart>();
|
||||
auto type_block_id = context.args_type_info_stack().Pop();
|
||||
|
||||
auto type_id = context.CanonicalizeStructType(parse_node, type_block_id);
|
||||
@@ -85,7 +83,7 @@ auto HandleStructLiteral(Context& context, ParseTree::Node parse_node) -> bool {
|
||||
}
|
||||
|
||||
auto HandleStructLiteralOrStructTypeLiteralStart(Context& context,
|
||||
ParseTree::Node parse_node)
|
||||
Parse::Node parse_node)
|
||||
-> bool {
|
||||
context.PushScope();
|
||||
context.node_stack().Push(parse_node);
|
||||
@@ -97,15 +95,15 @@ auto HandleStructLiteralOrStructTypeLiteralStart(Context& context,
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleStructTypeLiteral(Context& context, ParseTree::Node parse_node)
|
||||
-> bool {
|
||||
auto HandleStructTypeLiteral(Context& context, Parse::Node parse_node) -> bool {
|
||||
auto refs_id = context.ParamOrArgEnd(
|
||||
/*for_args=*/false, ParseNodeKind::StructLiteralOrStructTypeLiteralStart);
|
||||
/*for_args=*/false,
|
||||
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart);
|
||||
|
||||
context.PopScope();
|
||||
context.node_stack()
|
||||
.PopAndDiscardSoloParseNode<
|
||||
ParseNodeKind::StructLiteralOrStructTypeLiteralStart>();
|
||||
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart>();
|
||||
// This is only used for value literals.
|
||||
context.args_type_info_stack().Pop();
|
||||
|
||||
|
||||
Reference in new issue
Block a user