Rework identifier handling, adds typedef statement.

This commit is contained in:
2020-10-08 19:53:02 +02:00
parent e99b1af78d
commit 2fb1b68ead
9 changed files with 295 additions and 119 deletions

View File

@@ -21,18 +21,21 @@ namespace MalachScript::Parser {
}
bool ParseClass(const ParsedStatement*& out);
bool ParseTypeDef(const ParsedStatement*& out);
bool ParseVirtProp(const ParsedStatement*& out);
bool ParseFunc(const ParsedStatement*& out);
bool ParseVar(const ParsedStatement*& out);
bool ParseFuncDef(const ParsedStatement*& out);
std::u8string_view ParseIdentifier(const LexToken* token, bool& logError) {
bool ParsePrimType(Identifier& out);
bool ParseIdentifier(Identifier& out, const LexToken* token, bool& logError) {
if (logError && token->GetKind() != LexTokenKind::Identifier) {
LogError(Diagnostics::DiagnosticType::UnexpectedToken, token->GetSpan());
logError = false;
return std::u8string_view();
return false;
}
return reinterpret_cast<const IdentifierToken*>(token)->GetValue();
out = reinterpret_cast<const IdentifierToken*>(token)->GetValue();
return true;
}
};
}