feat: initial commit

This commit is contained in:
lisk77 2025-06-30 19:43:09 +02:00
commit 0dd91da74f
17 changed files with 683 additions and 0 deletions

27
src/token.cpp Normal file
View 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);
}