-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lexer.h
58 lines (46 loc) · 1.17 KB
/
Lexer.h
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
58
//
// Created by nisal on 7/19/2023.
//
#ifndef RPAL_FINAL_LEXER_H
#define RPAL_FINAL_LEXER_H
#include <string>
#include <sstream>
#include <iostream>
//#include <unordered_set>
#include "Token.h"
#include <unordered_set>
#include <utility>
//#include <sstream>
//#include <iostream>
/**
* @brief The Lexer class tokenizes the input string.
*/
class Lexer
{
public:
/**
* @brief Constructs a Lexer object with the given input string.
* @param input The input string to tokenize.
*/
[[maybe_unused]] explicit Lexer(std::string input) : input(std::move(input)), currentPosition(0) {}
/**
* @brief Retrieves the next token from the input string.
* @return The next token.
*/
Token getNextToken();
private:
/**
* @brief Skips whitespace characters in the input string.
*/
void skipWhitespace();
/**
* @brief Checks if the given character is an operator symbol.
* @param c The character to check.
* @return True if the character is an operator symbol, false otherwise.
*/
static bool isOperatorSymbol(char c);
private:
std::string input;
size_t currentPosition;
};
#endif //RPAL_FINAL_LEXER_H