mirror of
https://github.com/lisk77/lambda.git
synced 2025-10-24 18:28:49 +00:00
feat: initial commit
This commit is contained in:
commit
0dd91da74f
17 changed files with 683 additions and 0 deletions
27
src/token.cpp
Normal file
27
src/token.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue