Better if/else syntax errors
This commit is contained in:
parent
252e8ad829
commit
9b0c3900f8
@ -122,6 +122,8 @@ ParseReturn parse_instruction(vector<Token> tokens) {
|
||||
if (tokens.back().type != TokenType::Semicolon)
|
||||
throw ParseException();
|
||||
|
||||
tokens.pop_back();
|
||||
|
||||
return {
|
||||
.node=ret.node,
|
||||
.tokens=tokens
|
||||
@ -135,6 +137,8 @@ ParseReturn parse_instruction(vector<Token> tokens) {
|
||||
if (tokens.size() < 1 || tokens.back().type != TokenType::Semicolon)
|
||||
throw ParseException();
|
||||
|
||||
tokens.pop_back();
|
||||
|
||||
return {
|
||||
.node=ret.node,
|
||||
.tokens=tokens
|
||||
@ -187,7 +191,14 @@ ParseReturn parse_statement(vector<Token> tokens) {
|
||||
tokens = ret.tokens;
|
||||
Node expr = ret.node;
|
||||
|
||||
ret = parse_instruction(tokens); // Instruction1
|
||||
try {
|
||||
ret = parse_instruction(tokens); // Instruction1
|
||||
} catch (const ParseException& pex) {
|
||||
throw SyntaxError(
|
||||
"Invalid Syntax",
|
||||
pos=tokens.back().pos
|
||||
);
|
||||
}
|
||||
|
||||
if (holds_alternative<InnerNode>(ret.node) &&
|
||||
( get<InnerNode>(ret.node).type == NodeType::AssignedDeclaration ||
|
||||
|
Loading…
Reference in New Issue
Block a user