BenchGen
BenchGen is a tool for generating benchmarks to stress-test a computing system.
Loading...
Searching...
No Matches
lexer.h
Go to the documentation of this file.
1#ifndef LEXER_H
2#define LEXER_H
3
4#include <fstream>
5#include <iostream>
6#include <regex>
7#include <vector>
8
9#include "../shared/enums.h"
11
12using std::ifstream;
13
21class Lexer {
22 private:
23 std::vector<LexerRule> rules; // Vector holding the lexer rules
24
33 std::vector<std::string> readFile(std::string fileName);
34
44 std::vector<Token> tokenize(std::string input);
45
55 bool matchAnyRule(std::string input);
56
66 int matchToken(std::string input);
67
68 public:
72 Lexer();
73
80 void loadConfiguration();
81
90 std::vector<Token> getTokens(std::string fileName);
91
100 std::vector<ProductionRule> getProductionRules(std::string fileName);
101};
102
103#endif
The Lexer class is responsible for reading input, applying lexer rules, and generating tokens from th...
Definition lexer.h:21
Lexer()
Constructs a Lexer object and loads the configuration rules.
Definition lexer.cpp:6
std::vector< Token > getTokens(std::string fileName)
Gets the tokens from a given file.
Definition lexer.cpp:142
std::vector< ProductionRule > getProductionRules(std::string fileName)
Extracts production rules from a given file.
Definition lexer.cpp:152
void loadConfiguration()
Loads lexer configuration rules.
Definition lexer.cpp:85