less java
This commit is contained in:
parent
2a6c809031
commit
89968525df
3 changed files with 3 additions and 14 deletions
|
|
@ -59,7 +59,7 @@ ScanResult run(std::string source) {
|
|||
void print_tokens(std::list<Token> *list) {
|
||||
for (std::list<Token>::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";
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -3,12 +3,10 @@
|
|||
#include <string>
|
||||
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue