1 // =================================
 2 // Copyright (c) 2020 Seppo Laakko
 3 // Distributed under the MIT license
 4 // =================================
 5 
 6 #include <sng2html/sng2html/Grammar.hpp>
 7 
 8 namespace sng2html { namespace sng2html {
 9 
10 Rule::Rule(const std::u32string& name_, Expression* expression_) : kind(Kind::lexical), name(name_), expression(expression_), parser(nullptr)
11 {
12 }
13 
14 Rule::Rule(const std::u32string& name_, RuleParser* parser_) : kind(Kind::parser), name(name_), parser(parser_), expression(nullptr)
15 {
16 }
17 
18 Grammar::Grammar(const std::u32string& name_, const std::u32string& title_, const std::string& htmlFilePath_, LexerFile* lexerFile_) :
19     kind(Kind::lexical), name(name_), title(title_), htmlFilePath(htmlFilePath_), lexerFile(lexerFile_), parser(nullptr), htmlFileName(name + U".html")
20 {
21 }
22 
23 Grammar::Grammar(const std::u32string& name_, const std::u32string& title_, const std::string& htmlFilePath_, GrammarParser* parser_) :
24     kind(Kind::parser), name(name_), title(title_), htmlFilePath(htmlFilePath_), parser(parser_), lexerFile(nullptr), htmlFileName(name + U".html")
25 {
26 }
27 
28 void Grammar::AddRule(Rule* rule)
29 {
30     rules.push_back(std::unique_ptr<Rule>(rule));
31 }
32 
33 } } // namespace sng2html::sng2html