More work on stringification of the parse tree.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
08a0859539
commit
cf09f9348c
|
@ -68,10 +68,23 @@ namespace MalachScript::Parser {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case ParsedStatementKind::TypeDef: break;
|
||||
case ParsedStatementKind::Namespace: break;
|
||||
case ParsedStatementKind::Type: break;
|
||||
case ParsedStatementKind::ParamList: break;
|
||||
case ParsedStatementKind::TypeDef: {
|
||||
const auto* td = static_cast<const ParsedTypeDefStatement*>(statement);
|
||||
stream << " from: " << td->GetDefineFrom() << " --> " << td->GetDefineTo();
|
||||
break;
|
||||
}
|
||||
case ParsedStatementKind::Namespace: {
|
||||
stream << std::endl;
|
||||
auto& script = static_cast<const ParsedNamespaceStatement*>(statement)->GetScript();
|
||||
Stringify(script.get(), stream, prefix + (isLast ? " " : "│ "), true);
|
||||
break;
|
||||
}
|
||||
case ParsedStatementKind::Type: {
|
||||
throw std::logic_error("Type statements should use StringifyType");
|
||||
}
|
||||
case ParsedStatementKind::ParamList: {
|
||||
throw std::logic_error("ParamList statements should use StringifyParamList");
|
||||
}
|
||||
case ParsedStatementKind::Func: {
|
||||
const auto* func = static_cast<const ParsedFuncStatement*>(statement);
|
||||
stream << " " << func->GetIdentifier();
|
||||
|
@ -82,7 +95,38 @@ namespace MalachScript::Parser {
|
|||
Stringify(func->GetStatBlock().get(), stream, prefix + (isLast ? " " : "│ "), true);
|
||||
break;
|
||||
}
|
||||
case ParsedStatementKind::VirtProp: break;
|
||||
case ParsedStatementKind::VirtProp: {
|
||||
const auto* virtprop = static_cast<const ParsedVirtPropStatement*>(statement);
|
||||
stream << " " << virtprop->GetIdentifier() << " : ";
|
||||
StringifyType(dynamic_cast<const ParsedTypeStatement*>(virtprop->GetReturnType().get()), stream);
|
||||
if (virtprop->HasGet() || virtprop->HasSet()) {
|
||||
stream << std::endl;
|
||||
}
|
||||
if (virtprop->HasGet()) {
|
||||
auto& stat = virtprop->GetGetStatement();
|
||||
auto propPrefix = prefix + " ";
|
||||
stream << propPrefix;
|
||||
stream << (virtprop->HasSet() ? "├──" : "└──") << "Get";
|
||||
stream << std::endl;
|
||||
|
||||
if (stat != nullptr) {
|
||||
Stringify(stat.get(), stream, propPrefix + (virtprop->HasSet() ? "│ " : " "), true);
|
||||
}
|
||||
}
|
||||
if (virtprop->HasSet()) {
|
||||
auto& stat = virtprop->GetSetStatement();
|
||||
auto propPrefix = prefix + " ";
|
||||
stream << propPrefix;
|
||||
stream << (virtprop->HasSet() ? "└──" : "├──") << "Set";
|
||||
stream << std::endl;
|
||||
|
||||
if (stat != nullptr) {
|
||||
Stringify(stat.get(), stream, propPrefix + " ", true);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ParsedStatementKind::StatBlock: {
|
||||
stream << std::endl;
|
||||
auto& stats = static_cast<const ParsedStatBlockStatement*>(statement)->GetStatements();
|
||||
|
|
Loading…
Reference in New Issue