Add a "=" operator and a default constructor to tok
This commit is contained in:
parent
379a230765
commit
de5184056c
|
@ -19,6 +19,15 @@ struct tok {
|
||||||
const type toktype;
|
const type toktype;
|
||||||
const std::string toktext;
|
const std::string toktext;
|
||||||
const unsigned long line;
|
const unsigned long line;
|
||||||
|
tok& operator=(const tok& other) {
|
||||||
|
if (this != &other) {
|
||||||
|
const_cast<type&>(toktype) = other.toktype;
|
||||||
|
const_cast<std::string&>(toktext) = other.toktext;
|
||||||
|
const_cast<unsigned long&>(line) = other.line;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
tok(): toktype(UNEXPECTED), toktext(), line(0) {};
|
||||||
tok(const type& Type, std::string_view Text, const decltype(line)& line = 0): toktype(Type), toktext(Text), line(line) {}
|
tok(const type& Type, std::string_view Text, const decltype(line)& line = 0): toktype(Type), toktext(Text), line(line) {}
|
||||||
explicit tok(const type& Type, const decltype(line)& line = 0): tok(Type, std::string(1, Type), line) {};
|
explicit tok(const type& Type, const decltype(line)& line = 0): tok(Type, std::string(1, Type), line) {};
|
||||||
friend std::ostream& operator<<(std::ostream& output, const tok& it) { return output << it.toktext; }
|
friend std::ostream& operator<<(std::ostream& output, const tok& it) { return output << it.toktext; }
|
||||||
|
|
Loading…
Reference in New Issue