Improve the tok constructors

This commit is contained in:
Username404 2021-12-27 21:46:25 +01:00
parent 856e715e29
commit 32baddc0b2
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 3 additions and 3 deletions

View File

@ -19,9 +19,9 @@ struct tok {
};
const type toktype;
const std::string toktext;
const unsigned long line = 0;
tok(type Type, std::string_view Text, decltype(line) line): toktype(Type), toktext(Text), line(line) {}
explicit tok(type Type, decltype(line) line): tok(Type, std::string(1, Type), line) {};
const unsigned long 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) {};
friend std::ostream& operator<<(std::ostream& output, const tok& it) { return output << it.toktext; }
};
std::vector<tok> lex(const std::string& in);