134 lines
2.2 KiB
C++
134 lines
2.2 KiB
C++
#include "SyntaxBase.h"
|
|
#include <QFileInfo>
|
|
|
|
using namespace Parse;
|
|
using namespace Lex;
|
|
|
|
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 * ins) override
|
|
{
|
|
}
|
|
virtual QList<DesNode*> children() const override
|
|
{
|
|
return QList<DesNode*>();
|
|
}
|
|
virtual bool check(QList<QString>& reasons) const override
|
|
{
|
|
return true;
|
|
}
|
|
virtual QString toString() const override
|
|
{
|
|
return QString();
|
|
}
|
|
private:
|
|
DocCore *const doc_store;
|
|
};
|
|
|
|
Parse::Words::Words(DesNode* host, DocCore *doc, const QString & value, int row, int col)
|
|
: value_store(value), row_store(row), col_store(col)
|
|
{
|
|
}
|
|
|
|
int Parse::Words::row() const
|
|
{
|
|
return row_store;
|
|
}
|
|
|
|
int Parse::Words::column() const
|
|
{
|
|
return col_store;
|
|
}
|
|
|
|
int Parse::Words::length() const
|
|
{
|
|
return value_store.length();
|
|
}
|
|
|
|
DesNode * Parse::Words::host() const
|
|
{
|
|
return desnode_store;
|
|
}
|
|
|
|
DocCore * Parse::Words::doc() const
|
|
{
|
|
return docpresent_store;
|
|
}
|
|
|
|
QString Parse::Words::toString() const
|
|
{
|
|
return value_store;
|
|
}
|
|
|
|
Parse::DocCore::DocCore(ProjectCore * core, const QString & path)
|
|
: core_store(core), file_path_store(path), unknown_host(new Unknown(this))
|
|
{
|
|
}
|
|
|
|
DesNode * Parse::DocCore::unknowns() const
|
|
{
|
|
return unknown_host;
|
|
}
|
|
|
|
ProjectCore * Parse::DocCore::project() const
|
|
{
|
|
return core_store;
|
|
}
|
|
|
|
void Parse::DocCore::rename(const QString & new_name)
|
|
{
|
|
file_path_store = new_name;
|
|
}
|
|
|
|
QString Parse::DocCore::filePath() const
|
|
{
|
|
return file_path_store;
|
|
}
|
|
|
|
QString Parse::DocCore::fileName() const
|
|
{
|
|
return QFileInfo(file_path_store).fileName();
|
|
}
|
|
|
|
void Parse::DocCore::clear()
|
|
{
|
|
nodes_store.clear();
|
|
}
|
|
|
|
int Parse::DocCore::append(Words * ins)
|
|
{
|
|
nodes_store << ins;
|
|
|
|
return 0;
|
|
}
|
|
|
|
Words * Parse::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;
|
|
}
|