Simplify parsing of functions/calls/classes and remove the Class.body variable
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
5a96757942
commit
e9d7c27d4f
@ -125,8 +125,7 @@ namespace StandardComponents {
|
|||||||
ParseTree parameters;
|
ParseTree parameters;
|
||||||
using NamedIdentifier::NamedIdentifier;
|
using NamedIdentifier::NamedIdentifier;
|
||||||
};
|
};
|
||||||
struct Class: NamedIdentifier {
|
struct Class: NamedIdentifier, ParseTree {
|
||||||
ParseTree body;
|
|
||||||
using NamedIdentifier::NamedIdentifier;
|
using NamedIdentifier::NamedIdentifier;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -119,19 +119,12 @@ namespace Parser {
|
|||||||
}
|
}
|
||||||
if (not parseTree.empty()) {
|
if (not parseTree.empty()) {
|
||||||
try {
|
try {
|
||||||
const component_ptr& previous = parseTree.at(parseTree.size() - 1);
|
auto& previous = dynamic_cast<ParseTree&>(*parseTree.at(parseTree.size() - 1));
|
||||||
if (current.toktype == LPAR) {
|
if (current.toktype != LPAR or previous.getId() == typeid(Call)) {
|
||||||
dynamic_cast<Call&>(*previous).ParseTree::operator=(parse(subTokens));
|
previous = parse(subTokens);
|
||||||
} else if (current.toktype == LBRACE) {
|
i = distance(lexed.begin(), closingCharacter);
|
||||||
const type_info& previous_id = previous->getId();
|
break;
|
||||||
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&) {}
|
} catch (const out_of_range&) {} catch (const bad_cast&) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user