2023-08-11 15:06:51 +00:00
|
|
|
#include "token_impls.h"
|
2023-03-25 02:10:32 +00:00
|
|
|
|
|
|
|
|
using namespace Lex;
|
|
|
|
|
|
|
|
|
|
TokenWord::TokenWord(const QString &file_path) { filepath_val = file_path; }
|
|
|
|
|
|
|
|
|
|
QString TokenWord::content() const { return content_val; }
|
|
|
|
|
|
|
|
|
|
QString TokenWord::filePath() const { return filepath_val; }
|
|
|
|
|
|
|
|
|
|
int TokenWord::row() const { return row_val; }
|
|
|
|
|
|
|
|
|
|
int TokenWord::column() const { return column_val; }
|
|
|
|
|
|
|
|
|
|
// WordBase &TokenWord::operator=(const WordBase &other) {
|
|
|
|
|
// this->content_val = other.content();
|
|
|
|
|
// this->filepath_val = other.filePath();
|
|
|
|
|
// this->row_val = other.row();
|
|
|
|
|
// this->column_val = other.column();
|
|
|
|
|
|
|
|
|
|
// return *this;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
void TokenWord::reset(const QString &word, int row, int col) {
|
|
|
|
|
content_val = word;
|
|
|
|
|
row_val = row;
|
|
|
|
|
column_val = col;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:06:51 +00:00
|
|
|
TokenResult::TokenResult(TokenDef *def, const WordBase &word, int length) : def_store(def), remains_store(nullptr) {
|
2023-03-25 02:10:32 +00:00
|
|
|
TokenWord *inst = nullptr;
|
2023-08-11 15:06:51 +00:00
|
|
|
if (word.content().length() != length) {
|
|
|
|
|
inst = new TokenWord(word.filePath());
|
|
|
|
|
inst->reset(word.content().mid(length), word.row(), word.column() + length);
|
2023-03-25 02:10:32 +00:00
|
|
|
}
|
|
|
|
|
remains_store = inst;
|
2023-08-11 15:06:51 +00:00
|
|
|
content_store = word.content().mid(0, length);
|
|
|
|
|
filepath_store = word.filePath();
|
|
|
|
|
row_store = word.row();
|
|
|
|
|
col_store = word.column();
|
2023-03-25 02:10:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TokenDef *TokenResult::def() const { return def_store; }
|
|
|
|
|
|
|
|
|
|
WordBase *TokenResult::remains() const { return remains_store; }
|
|
|
|
|
|
|
|
|
|
QString TokenResult::content() const { return content_store; }
|
|
|
|
|
|
|
|
|
|
QString TokenResult::filePath() const { return filepath_store; }
|
|
|
|
|
|
|
|
|
|
int TokenResult::row() const { return row_store; }
|
|
|
|
|
|
|
|
|
|
int TokenResult::column() const { return col_store; }
|