-
Notifications
You must be signed in to change notification settings - Fork 3
/
language_parser.h
35 lines (28 loc) · 1016 Bytes
/
language_parser.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
/**
Compiler Phase 1: LEXGEN
language_parser.h
Purpose: Takes in a file of lexical rules (language definition) and parses into REs and input symbols.
@author Amr Elzawawy
@version 1.0
@date 25/3/2020
*/
#ifndef LEXGEN_LANGUAGE_PARSER_H
#define LEXGEN_LANGUAGE_PARSER_H
#include <string>
#include <vector>
#include <unordered_set>
#include "regular_expression.h"
class LanguageParser {
public:
void parseFile(std::string rules_file_path);
const std::unordered_set<std::string>& getInput_table() const;
const std::vector<RegularExpression>& getExpressions() const;
private:
std::unordered_set<std::string> input_table_;
std::vector<RegularExpression> expressions_;
std::vector<std::pair<std::string,std::string>> definitions_;
void keywordAndPunctuationHandler(std::string rule);
void regularExpressionHandler(std::string rule);
void updateExpressionsAndInputTable(std::string regex_name,std::string regex_value);
};
#endif //LEXGEN_LANGUAGE_PARSER_H