#include "SyntaxBase.h" #include using namespace Parse; using namespace Lex; using namespace Syntax; using namespace Parse::Result; namespace Parse { class Unknown : public DesNode { public: explicit Unknown(DocCore *ins) : doc_store(ins) {} // 通过 DesNode 继承 virtual int depth() const override { return 0; } virtual DocCore * document() const override { return doc_store; } virtual int typeValue() const override { return NODE_UNKNOWNHOST; } virtual DesNode * parent() const override { return nullptr; } virtual void appendChild(DesNode *) override { } virtual QList children() const override { return QList(); } virtual bool check(QList&) const override { return true; } virtual QString toString() const override { return QString(); } private: DocCore *const doc_store; }; } Words::Words(Result::DesNode *host, DocCore *doc, const QString & value, int row, int col) : value_store(value), row_store(row), col_store(col), desnode_store(host), docpresent_store(doc) { } int Words::row() const { return row_store; } int Words::column() const { return col_store; } int Words::length() const { return value_store.length(); } DesNode * Words::host() const { return desnode_store; } DocCore * Words::doc() const { return docpresent_store; } QString Words::toString() const { return value_store; } DocCore::DocCore(ProjectCore * core, const QString & path) : unknown_host(new Unknown(this)), core_store(core), file_path_store(path) { } DesNode * DocCore::unknowns() const { return unknown_host; } ProjectCore * DocCore::project() const { return core_store; } void DocCore::rename(const QString & new_name) { file_path_store = new_name; } QString DocCore::filePath() const { return file_path_store; } QString DocCore::fileName() const { return QFileInfo(file_path_store).fileName(); } void DocCore::clear() { nodes_store.clear(); } int DocCore::append(Words * ins) { nodes_store << ins; return 0; } Words * DocCore::getWords(int row, int col) const { for (auto it : nodes_store) if (it->row() == row && it->column() <= col && it->column() + it->length() >= col) return it; return nullptr; }