-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParser.hpp
45 lines (35 loc) · 1.66 KB
/
Parser.hpp
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
#ifndef PARSER_HPP
#define PARSER_HPP
#include "StructureChart.hpp"
#include "ClassChart.hpp"
struct Result
{
ClassChart classChart;
std::vector<std::unique_ptr<StructureChart>> structureCharts;
};
class Parser
{
public:
Parser (const char* begin, const char* end);
const Result& getResult();
private:
void parseStructures(const char* begin, const char* end);
BlockSequence parseFunctionBody(const char*& begin, const char* end);
static void skipWhitespaces(const char*& c, const char* end);
static void skipWhitespacesBackwards(const char*& c, const char* begin);
static bool match(const char*& begin, const char* end, const char* literal);
static bool matchWithFollowing(const char*& begin, const char* end, const char* literal, const char following);
static bool following(const char* begin, const char* end, const char* literal); // like match but without jumping to the last position of tmp
static void expect(const char*& begin, const char* end, const char* literal);
std::string getCondition (const char*& begin, const char* end);
std::string cleanSyntax (const char* begin, const char* end);
void skipBody(const char*& begin, const char* end, int pDepth);
void skipIf(const char*& begin, const char* end);
Result result;
std::map<std::string, Class*> classMap;
void skipName(const char*& begin, const char* end);
void parseClass(const char*& begin, const char* end);
Operation parseOperation(const char* begin, const char* end, Visibility visibility, bool& skip, std::string className);
void parseTypeAndName(const char* begin, const char* end, std::string& name, std::string& type, bool argumentMode = false);
};
#endif // PARSER_HPP