mirror of
https://github.com/lisk77/lambda.git
synced 2025-10-24 02:08:49 +00:00
27 lines
833 B
C++
27 lines
833 B
C++
#include <string>
|
|
#include <stdio.h>
|
|
|
|
#include "token.hpp"
|
|
|
|
std::string display_tokentype(TokenType type) {
|
|
switch (type) {
|
|
case ERROR : return "ERROR";
|
|
case EOL : return "EOL";
|
|
case EOC : return "EOC";
|
|
case LAMBDA : return "LAMBDA";
|
|
case DOT : return "DOT";
|
|
case LPAREN : return "LPAREN";
|
|
case RPAREN : return "RPAREN";
|
|
case EQUALS : return "EQUALS";
|
|
case VARIABLE : return "VARIABLE";
|
|
default : return "";
|
|
}
|
|
}
|
|
|
|
void print_lexeme(Token self) {
|
|
printf("Lexeme: '%.*s'\n", (int)(self.end-self.start), self.lexeme);
|
|
}
|
|
|
|
void print_token(Token self) {
|
|
printf("[%s] %.*s %li..%li\n", display_tokentype(self.type), (int)(self.end-self.start), self.lexeme, self.start, self.end);
|
|
}
|