Fixed parsing of types.
This commit is contained in:
@@ -23,9 +23,8 @@ ast::Type parseType(Context &context, ast::Domain &domain)
|
||||
|
||||
if (tokenizer.testAndReturn<char>('('))
|
||||
{
|
||||
// TODO: put into Type parsing unit
|
||||
// TODO: refactor
|
||||
auto p =
|
||||
auto parsePrimitiveTypeWrapper =
|
||||
[](auto &context, auto &astContext, auto &) -> std::experimental::optional<ast::PrimitiveTypePointer>
|
||||
{
|
||||
return parsePrimitiveType(context, *astContext.domain);
|
||||
@@ -35,7 +34,7 @@ ast::Type parseType(Context &context, ast::Domain &domain)
|
||||
ASTContext astContext(domain);
|
||||
VariableStack variableStack;
|
||||
|
||||
auto eitherType = parseEither<ast::PrimitiveTypePointer>(context, astContext, variableStack, p);
|
||||
auto eitherType = parseEither<ast::PrimitiveTypePointer>(context, astContext, variableStack, parsePrimitiveTypeWrapper);
|
||||
|
||||
if (!eitherType)
|
||||
throw ParserException(tokenizer.location(), "expected primitive type or “either” expression");
|
||||
|
@@ -49,13 +49,12 @@ ast::VariableDeclarations parseVariableDeclarations(Context &context, ast::Domai
|
||||
continue;
|
||||
|
||||
auto parentType = parseType(context, domain);
|
||||
parentType = ast::deepCopy(parentType);
|
||||
|
||||
for (size_t i = inheritanceIndex; i < variableDeclarations.size(); i++)
|
||||
variableDeclarations[i]->type = ast::deepCopy(parentType);
|
||||
|
||||
// All types up to now are labeled with their parent types
|
||||
inheritanceIndex = variableDeclarations.size() + 1;
|
||||
inheritanceIndex = variableDeclarations.size();
|
||||
|
||||
tokenizer.skipWhiteSpace();
|
||||
}
|
||||
|
Reference in New Issue
Block a user