-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGrammarParser.mpp
More file actions
41 lines (34 loc) · 880 Bytes
/
GrammarParser.mpp
File metadata and controls
41 lines (34 loc) · 880 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
29
30
31
32
33
34
35
36
37
38
39
40
41
export module CppUtils.Language.GrammarParser;
import std;
import CppUtils.Language.ASTParser;
import CppUtils.Logger;
import CppUtils.String;
export namespace CppUtils::Language
{
struct GrammarParser: public ASTParser
{
GrammarParser()
{
using namespace std::literals;
constexpr auto source = R"(
lowLevelGrammarParser {
enter { call{enter} }
leave { call{leave} }
delete { call{delete} }
readChar { call{readChar} }
stepCursorForward { call{stepCursorForward} }
}
return { call{leave} }
temp {
return
}
call{enter}
call{={run}}
declarations
)"sv;
auto cursor = CppUtils::String::Cursor{source};
if (auto result = operator()(cursor); not result)
Logger<"CppUtils">::print<"error">("Error: {}\nPosition: {}\nChar: '{}'", result.error(), cursor.position, cursor.getCurrent());
}
};
}