✨ sync tree-sitter grammar and AST
This commit is contained in:
@@ -155,6 +155,8 @@ export namespace lsp::language::ast::debug
|
||||
void VisitRepeatStatement(RepeatStatement& node) override;
|
||||
void VisitCaseStatement(CaseStatement& node) override;
|
||||
void VisitTryStatement(TryStatement& node) override;
|
||||
void VisitLabelStatement(LabelStatement& node) override;
|
||||
void VisitGotoStatement(GotoStatement& node) override;
|
||||
void VisitBreakStatement(BreakStatement&) override;
|
||||
void VisitContinueStatement(ContinueStatement&) override;
|
||||
void VisitReturnStatement(ReturnStatement& node) override;
|
||||
@@ -2512,19 +2514,65 @@ export namespace lsp::language::ast::debug
|
||||
IncreaseIndent();
|
||||
std::vector<std::function<void(bool)>> children;
|
||||
if (node.try_body)
|
||||
{
|
||||
children.push_back([&](bool is_last) { PrintStatement(node.try_body.get(), "Try", is_last && !node.except_body); });
|
||||
}
|
||||
|
||||
children.push_back([&](bool is_last) { PrintStatement(node.try_body.get(), "Try", is_last); });
|
||||
if (node.except_body)
|
||||
{
|
||||
children.push_back([&](bool is_last) { PrintStatement(node.except_body.get(), "Except", is_last); });
|
||||
}
|
||||
if (node.finally_body)
|
||||
children.push_back([&](bool is_last) { PrintStatement(node.finally_body.get(), "Finally", is_last); });
|
||||
|
||||
EmitChildren(std::move(children));
|
||||
DecreaseIndent();
|
||||
}
|
||||
|
||||
void DebugPrinter::VisitLabelStatement(LabelStatement& node)
|
||||
{
|
||||
PrintIndent();
|
||||
PrintColored("LabelStatement", Color::BrightCyan);
|
||||
|
||||
if (options_.show_location)
|
||||
{
|
||||
os_ << " ";
|
||||
PrintLocation(node.span);
|
||||
}
|
||||
os_ << "\n";
|
||||
|
||||
if (node.labels.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IncreaseIndent();
|
||||
is_last_child_stack_.push_back(true);
|
||||
for (size_t i = 0; i < node.labels.size(); ++i)
|
||||
{
|
||||
const auto& label = node.labels[i];
|
||||
PrintIndent(i == node.labels.size() - 1);
|
||||
PrintColored("\"" + label.name + "\"", Color::Green);
|
||||
if (options_.show_location)
|
||||
{
|
||||
os_ << " ";
|
||||
PrintLocation(label.location);
|
||||
}
|
||||
os_ << "\n";
|
||||
}
|
||||
is_last_child_stack_.pop_back();
|
||||
DecreaseIndent();
|
||||
}
|
||||
|
||||
void DebugPrinter::VisitGotoStatement(GotoStatement& node)
|
||||
{
|
||||
PrintIndent();
|
||||
PrintColored("GotoStatement: ", Color::BrightCyan);
|
||||
PrintColored("\"" + node.label + "\"", Color::Green);
|
||||
|
||||
if (options_.show_location)
|
||||
{
|
||||
os_ << " ";
|
||||
PrintLocation(node.location);
|
||||
}
|
||||
os_ << "\n";
|
||||
}
|
||||
|
||||
void DebugPrinter::VisitBreakStatement(BreakStatement& node)
|
||||
{
|
||||
PrintIndent();
|
||||
@@ -2960,7 +3008,9 @@ export namespace lsp::language::ast::debug
|
||||
}
|
||||
os_ << "\n";
|
||||
|
||||
// TSLXBlock 的具体内容未定义,暂时只打印节点名称
|
||||
IncreaseIndent();
|
||||
PrintStatements(node.statements);
|
||||
DecreaseIndent();
|
||||
}
|
||||
|
||||
// ===== 便捷函数实现 =====
|
||||
|
||||
Reference in New Issue
Block a user