mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-25 16:28:46 +00:00
highlighting improvements
This commit is contained in:
parent
195a26f9b7
commit
bf7fe1f821
9 changed files with 139 additions and 22 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "basic_printers.hpp"
|
||||
#include "statement_nodes.hpp"
|
||||
#include "tree_sitter_wrapper.hpp"
|
||||
|
||||
|
|
@ -19,12 +20,20 @@ public:
|
|||
|
||||
bool insert(const std::string &path, nodes::Statement &&statement);
|
||||
|
||||
bool insert(const std::string &path, const nodes::Statement &statement);
|
||||
// bool insert(const std::string &path, const nodes::Statement &statement);
|
||||
|
||||
nodes::CombineResult insert_combine(const std::string &path,
|
||||
nodes::Statement &&statement);
|
||||
|
||||
std::optional<nodes::Statement *> find(const std::string &path);
|
||||
|
||||
std::optional<const nodes::Statement *> find(const std::string &path) const;
|
||||
|
||||
void print(printers::Printer &printer) const;
|
||||
|
||||
// TODO
|
||||
void add_statement_children_to_tree();
|
||||
|
||||
private:
|
||||
struct Node {
|
||||
public:
|
||||
|
|
@ -76,6 +85,20 @@ private:
|
|||
return true;
|
||||
}
|
||||
|
||||
void print(const std::vector<Node> &nodes,
|
||||
printers::Printer &printer) const {
|
||||
printer.print("Node - has statement: ");
|
||||
printer.print(statement_.has_value() ? "true" : "false");
|
||||
printer.indent();
|
||||
for (auto &iter : children_) {
|
||||
printer.new_indent_line();
|
||||
printer.print(std::to_string(iter.first) + " -> ");
|
||||
nodes[iter.second].print(nodes, printer);
|
||||
}
|
||||
printer.deindent();
|
||||
printer.new_indent_line();
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<size_t, size_t> children_;
|
||||
std::optional<nodes::Statement> statement_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue