diff --git a/src/lox.cpp b/src/lox.cpp index 8e0c7ab..797542f 100644 --- a/src/lox.cpp +++ b/src/lox.cpp @@ -59,7 +59,7 @@ ScanResult run(std::string source) { void print_tokens(std::list *list) { for (std::list::iterator token = list->begin(); token != list->end(); ++token) { - std::cout << token->to_string() << "(" << token->get_literal() << "), "; + std::cout << token->to_string() << "(" << token->literal << "), "; } std::cout << "\n"; diff --git a/src/tokens.cpp b/src/tokens.cpp index 5546f1e..8703239 100644 --- a/src/tokens.cpp +++ b/src/tokens.cpp @@ -15,11 +15,5 @@ std::string Token::to_string() { "NIL", "OR", "PRINT", "RETURN", "SUPER", "THIS", "TRUE", "VAR", "WHILE"}; - return tokens[(int)tokentype]; // TODO shift the enum int values + return tokens[(int)tokentype]; } - -std::string Token::get_lexeme() { return lexeme; } - -std::string Token::get_literal() { return literal; } - -int Token::get_line() { return line; } diff --git a/src/tokens.hpp b/src/tokens.hpp index a7c27b6..b2df1b3 100644 --- a/src/tokens.hpp +++ b/src/tokens.hpp @@ -3,12 +3,10 @@ #include class Token { -private: +public: std::string lexeme; std::string literal; int line; - -public: enum Type { END_OF_FILE = 0, LEFT_PAREN = 1, @@ -51,9 +49,6 @@ public: WHILE = 38, } tokentype; - std::string get_lexeme(); - std::string get_literal(); - int get_line(); std::string to_string(); Token(Token::Type _tokentype, std::string _lexeme, std::string _literal,