1
2
3
4
5
6 #include <sng2html/sng2html/Domain.hpp>
7 #include <sng2html/sng2html/Visitor.hpp>
8 #include <soulng/util/Unicode.hpp>
9
10 namespace sng2html { namespace sng2html {
11
12 using namespace soulng::unicode;
13
14 void Domain::Accept(Visitor& visitor)
15 {
16 visitor.Visit(*this);
17 }
18
19 void Domain::AddParserFile(ParserFile* parserFile)
20 {
21 parserFiles.push_back(parserFile);
22 }
23
24 void Domain::AddParser(GrammarParser* parser)
25 {
26 auto it = parserMap.find(parser->Name());
27 if (it != parserMap.cend())
28 {
29 throw std::runtime_error("parser '" + ToUtf8(parser->Name()) + "' already exists");
30 }
31 parserMap[parser->Name()] = parser;
32 }
33
34 GrammarParser* Domain::GetParser(const std::u32string& parserName) const
35 {
36 auto it = parserMap.find(parserName);
37 if (it != parserMap.cend())
38 {
39 return it->second;
40 }
41 else
42 {
43 throw std::runtime_error("parser '" + ToUtf8(parserName) + "' not found");
44 }
45 }
46
47 } }