Added error on unfinished parsing
This commit is contained in:
parent
e0661f9f8f
commit
3289ae0148
@ -1 +1 @@
|
|||||||
2+2*6+
|
2 2 6+
|
||||||
|
@ -17,6 +17,10 @@ std::shared_ptr<ASTNode> Parser::parse()
|
|||||||
advance();
|
advance();
|
||||||
auto result = expr();
|
auto result = expr();
|
||||||
if (result.is_error()) result.ethrow();
|
if (result.is_error()) result.ethrow();
|
||||||
|
if (current_token->tk_type != TT_EOF)
|
||||||
|
{
|
||||||
|
Err<ExprNode>("expected *, /, + or -",current_token).ethrow();
|
||||||
|
}
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,10 @@ template<typename T> class Result
|
|||||||
{
|
{
|
||||||
Error::throw_error(m_token->loc, m_token->line(), m_error);
|
Error::throw_error(m_token->loc, m_token->line(), m_error);
|
||||||
}
|
}
|
||||||
|
Token* token()
|
||||||
|
{
|
||||||
|
return m_token;
|
||||||
|
}
|
||||||
std::shared_ptr<T> get()
|
std::shared_ptr<T> get()
|
||||||
{
|
{
|
||||||
return m_result;
|
return m_result;
|
||||||
|
Loading…
Reference in New Issue
Block a user