Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81352 / ts2html / token.cpp
diff options
context:
space:
mode:
1 files changed, 32 insertions, 0 deletions
-rw-r--r--homework/81352/ts2html/token.cpp32
diff --git a/homework/81352/ts2html/token.cpp b/homework/81352/ts2html/token.cpp
new file mode 100644
index 0000000..97bdcdd
--- /dev/null
+++ b/homework/81352/ts2html/token.cpp
@@ -0,0 +1,32 @@
+#include "token.h"
+
+Token::Token(std::string text, TokenType type): text(text), type(type) {}
+
+std::string Token::getTypeName() {
+ switch(this->type) {
+ case KEYWORD: return "keyword";
+ case IDENTIFIER: return "identifier";
+ case NUMBER: return "number";
+ case OPERATOR: return "operator";
+ case STRING: return "string";
+ case OTHER: return "other";
+ case SEMICOLON: return "semicolon";
+ case LEFT_BLOCK_BRACKET:
+ case RIGHT_BLOCK_BRACKET:
+ case LEFT_BRACKET:
+ case RIGHT_BRACKET: return "bracket";
+ case NEWLINE:
+ case WHITESPACE: return "whitespace";
+ case DECORATOR: return "decorator";
+ case COMMENT: return "comment";
+ case UNRECOGNIZED: return "unrecognized";
+ }
+ return "";
+}
+std::string Token::getTextValue() {
+ return this->text;
+}
+
+TokenType Token::getTokenType() {
+ return this->type;
+}