mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-16 09:58:10 +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
@@ -23,8 +23,8 @@ static auto BuildFunctionDeclaration(Context& context)
|
||||
auto return_type_id = SemIR::TypeId::Invalid;
|
||||
auto return_slot_id = SemIR::NodeId::Invalid;
|
||||
if (context.parse_tree().node_kind(context.node_stack().PeekParseNode()) ==
|
||||
ParseNodeKind::ReturnType) {
|
||||
return_slot_id = context.node_stack().Pop<ParseNodeKind::ReturnType>();
|
||||
Parse::NodeKind::ReturnType) {
|
||||
return_slot_id = context.node_stack().Pop<Parse::NodeKind::ReturnType>();
|
||||
return_type_id = context.semantics_ir().GetNode(return_slot_id).type_id();
|
||||
|
||||
// The function only has a return slot if it uses in-place initialization.
|
||||
@@ -36,10 +36,11 @@ static auto BuildFunctionDeclaration(Context& context)
|
||||
}
|
||||
|
||||
SemIR::NodeBlockId param_refs_id =
|
||||
context.node_stack().Pop<ParseNodeKind::ParameterList>();
|
||||
context.node_stack().Pop<Parse::NodeKind::ParameterList>();
|
||||
auto name_context = context.declaration_name_stack().Pop();
|
||||
auto fn_node = context.node_stack()
|
||||
.PopForSoloParseNode<ParseNodeKind::FunctionIntroducer>();
|
||||
auto fn_node =
|
||||
context.node_stack()
|
||||
.PopForSoloParseNode<Parse::NodeKind::FunctionIntroducer>();
|
||||
|
||||
// TODO: Support out-of-line definitions, which will have a resolved
|
||||
// name_context. Right now, those become errors in AddNameToLookup.
|
||||
@@ -60,16 +61,16 @@ static auto BuildFunctionDeclaration(Context& context)
|
||||
return {function_id, decl_id};
|
||||
}
|
||||
|
||||
auto HandleFunctionDeclaration(Context& context, ParseTree::Node /*parse_node*/)
|
||||
auto HandleFunctionDeclaration(Context& context, Parse::Node /*parse_node*/)
|
||||
-> bool {
|
||||
BuildFunctionDeclaration(context);
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleFunctionDefinition(Context& context, ParseTree::Node parse_node)
|
||||
auto HandleFunctionDefinition(Context& context, Parse::Node parse_node)
|
||||
-> bool {
|
||||
SemIR::FunctionId function_id =
|
||||
context.node_stack().Pop<ParseNodeKind::FunctionDefinitionStart>();
|
||||
context.node_stack().Pop<Parse::NodeKind::FunctionDefinitionStart>();
|
||||
|
||||
// If the `}` of the function is reachable, reject if we need a return value
|
||||
// and otherwise add an implicit `return;`.
|
||||
@@ -92,7 +93,7 @@ auto HandleFunctionDefinition(Context& context, ParseTree::Node parse_node)
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleFunctionDefinitionStart(Context& context, ParseTree::Node parse_node)
|
||||
auto HandleFunctionDefinitionStart(Context& context, Parse::Node parse_node)
|
||||
-> bool {
|
||||
// Process the declaration portion of the function.
|
||||
auto [function_id, decl_id] = BuildFunctionDeclaration(context);
|
||||
@@ -116,7 +117,7 @@ auto HandleFunctionDefinitionStart(Context& context, ParseTree::Node parse_node)
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleFunctionIntroducer(Context& context, ParseTree::Node parse_node)
|
||||
auto HandleFunctionIntroducer(Context& context, Parse::Node parse_node)
|
||||
-> bool {
|
||||
// Create a node block to hold the nodes created as part of the function
|
||||
// signature, such as parameter and return types.
|
||||
@@ -128,7 +129,7 @@ auto HandleFunctionIntroducer(Context& context, ParseTree::Node parse_node)
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleReturnType(Context& context, ParseTree::Node parse_node) -> bool {
|
||||
auto HandleReturnType(Context& context, Parse::Node parse_node) -> bool {
|
||||
// Propagate the type expression.
|
||||
auto [type_parse_node, type_node_id] =
|
||||
context.node_stack().PopExpressionWithParseNode();
|
||||
|
||||
Reference in new issue
Block a user