-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreprocessor.h
More file actions
28 lines (21 loc) · 875 Bytes
/
Preprocessor.h
File metadata and controls
28 lines (21 loc) · 875 Bytes
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
#ifndef PREPROCESSOR_H
#define PREPROCESSOR_H
#include <string>
#include <unordered_set>
class Preprocessor {
public:
Preprocessor();
std::string preprocess(const std::string &code);
static const std::unordered_set<std::string>& getReservedWords();
private:
std::string removeComments(const std::string &code);
std::string normalizeWhitespace(const std::string &code);
std::string normalizeCase(const std::string &code);
std::string removeStringLiterals(const std::string &code);
std::string removeNumberLiterals(const std::string &code);
std::string normalizeIdentifiers(const std::string &code);
bool isReservedWord(const std::string &word) const;
bool isNumeric(const std::string &word) const;
std::string replaceAll(std::string str, const std::string &from, const std::string &to) const;
};
#endif // PREPROCESSOR_H