Parse parameter list
This commit is contained in:
@ -516,18 +516,43 @@ namespace elna::source
|
||||
}
|
||||
auto definition_identifier = iterator.advance(token::type::identifier);
|
||||
|
||||
if (!definition_identifier.has_value() || !iterator.skip(token::type::semicolon))
|
||||
if (!definition_identifier.has_value() || !iterator.skip(token::type::left_paren))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
std::vector<std::unique_ptr<declaration>> declarations;
|
||||
while (!iterator.current(token::type::right_paren))
|
||||
{
|
||||
std::unique_ptr<declaration> parsed_declaration = parse_declaration();
|
||||
if (parsed_declaration == nullptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
declarations.push_back(std::move(parsed_declaration));
|
||||
|
||||
if (iterator->of() == token::type::comma)
|
||||
{
|
||||
++iterator;
|
||||
continue;
|
||||
}
|
||||
else if (iterator->of() != token::type::right_paren)
|
||||
{
|
||||
iterator.add_error(*iterator);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
iterator.skip(token::type::right_paren);
|
||||
auto definition_body = parse_block();
|
||||
|
||||
if (definition_body == nullptr || !iterator.skip(token::type::semicolon))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_unique<procedure_definition>(definition_identifier->get().identifier(),
|
||||
auto procedure = std::make_unique<procedure_definition>(definition_identifier->get().identifier(),
|
||||
std::move(definition_body));
|
||||
procedure->parameters() = std::move(declarations);
|
||||
|
||||
return procedure;
|
||||
}
|
||||
|
||||
std::unique_ptr<declaration> parser::parse_declaration()
|
||||
|
Reference in New Issue
Block a user