1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#pragma once
#include "token.h"
#include <iostream>
#include <vector>
#include <string>
class Lexer {
public:
enum TokenEnum {
TokenType_EOF,
TokenType_NEWLINE,
TokenType_STRING,
TokenType_NUMBER,
TokenType_IDENTIFIER,
TokenType_PRINT,
TokenType_PLUS,
TokenType_MINUS,
TokenType_ASTERISK,
TokenType_SLASH
};
std::vector<std::string> TokenTypes = {
"EOF",
"NEWLINE",
"STRING",
"NUMBER",
"IDENTIFIER",
"PRINT",
"PLUS",
"MINUS",
"ASTERISK",
"SLASH"
};
std::string source;
char currentCharacter;
int currentPosition;
std::vector<std::string> temp;
std::string value;
std::string keyword;
Lexer(std::string input);
void nextCharacter();
char peek();
void skipWhitespace();
Token getToken();
std::string checkIfKeyword(std::string tokenKind);
};
| |