Always throw an error when an unexpected expression is found in Parser.hpp
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
453025b18c
commit
5a96757942
|
@ -117,23 +117,23 @@ namespace Parser {
|
|||
}
|
||||
}
|
||||
}
|
||||
const component_ptr& previous = parseTree.at(parseTree.size() - 1);
|
||||
if (current.toktype == LPAR) {
|
||||
if (not parseTree.empty()) {
|
||||
try {
|
||||
dynamic_cast<Call&>(*previous).ParseTree::operator=(parse(subTokens));
|
||||
} catch (const bad_cast&) {
|
||||
parsingError(current, "Unexpected parenthesis");
|
||||
}
|
||||
} else if (current.toktype == LBRACE) {
|
||||
const type_info& previous_id = previous->getId();
|
||||
if (previous_id == typeid(Function)) {
|
||||
dynamic_cast<Function&>(*previous).ParseTree::operator=(parse(subTokens));
|
||||
} else if (previous_id == typeid(Class)) {
|
||||
dynamic_cast<Class&>(*previous).body = parse(subTokens);
|
||||
}
|
||||
} else parseTree << parse(subTokens);
|
||||
i = distance(lexed.begin(), closingCharacter);
|
||||
break;
|
||||
const component_ptr& previous = parseTree.at(parseTree.size() - 1);
|
||||
if (current.toktype == LPAR) {
|
||||
dynamic_cast<Call&>(*previous).ParseTree::operator=(parse(subTokens));
|
||||
} else if (current.toktype == LBRACE) {
|
||||
const type_info& previous_id = previous->getId();
|
||||
if (previous_id == typeid(Function)) {
|
||||
dynamic_cast<Function&>(*previous).ParseTree::operator=(parse(subTokens));
|
||||
} else if (previous_id == typeid(Class)) {
|
||||
dynamic_cast<Class&>(*previous).body = parse(subTokens);
|
||||
}
|
||||
} else parseTree << parse(subTokens);
|
||||
i = distance(lexed.begin(), closingCharacter);
|
||||
break;
|
||||
} catch (const out_of_range&) {} catch (const bad_cast&) {}
|
||||
}
|
||||
}
|
||||
default: parsingError(current, " \u27F5 Unexpected character", true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue