mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 15:41:04 +01:00
[parse] Implement initial parsing support for Lambda expressions (#6583)
This adds the necessary parser infrastructure to recognize and parse lambda expressions in Carbon. Key changes: - Added and Parse Node Kinds. - Updated to use to accommodate the growing number of node kinds. - Implemented parser states and handlers for lambda syntax ( or ). - Added structure to . - Added diagnostics for missing lambda bodies. - Added a stub in phase to defer semantic analysis using . - Added parser tests for lambdas.
This commit is contained in:
@@ -470,6 +470,19 @@ auto Context::AddFunctionDefinition(Lex::TokenIndex token, bool has_error)
|
||||
}
|
||||
}
|
||||
|
||||
auto Context::AddFunctionTerseDefinition(Lex::TokenIndex token, bool has_error)
|
||||
-> void {
|
||||
auto definition_id =
|
||||
AddNode<NodeKind::FunctionTerseDefinition>(token, has_error);
|
||||
if (ParsingInDeferredDefinitionScope(*this)) {
|
||||
auto definition_index = deferred_definition_stack_.pop_back_val();
|
||||
auto& definition = tree_->deferred_definitions_.Get(definition_index);
|
||||
definition.definition_id = definition_id;
|
||||
definition.next_definition_index =
|
||||
DeferredDefinitionIndex(tree_->deferred_definitions().size());
|
||||
}
|
||||
}
|
||||
|
||||
auto Context::PrintForStackDump(llvm::raw_ostream& output) const -> void {
|
||||
output << "Parser stack:\n";
|
||||
for (auto [i, entry] : llvm::enumerate(state_stack_)) {
|
||||
|
||||
Reference in New Issue
Block a user