1
2
3
4
5
6 #ifndef SNG2HTML_SNG2HTML_GRAMMAR_INCLUDED
7 #define SNG2HTML_SNG2HTML_GRAMMAR_INCLUDED
8 #include <sng2html/sng2html/Parser.hpp>
9 #include <sng2html/sng2html/LexerFile.hpp>
10
11 namespace sng2html { namespace sng2html {
12
13 class Rule
14 {
15 public:
16 enum class Kind
17 {
18 lexical, parser
19 };
20 Rule(const std::u32string& name_, Expression* expression_);
21 Rule(const std::u32string& name_, RuleParser* parser_);
22 const std::u32string& Name() const { return name; }
23 Expression* GetExpression() const { return expression; }
24 RuleParser* Parser() const { return parser; }
25 private:
26 Kind kind;
27 std::u32string name;
28 Expression* expression;
29 RuleParser* parser;
30 };
31
32 class Grammar
33 {
34 public:
35 enum class Kind
36 {
37 lexical, parser
38 };
39 Grammar(const std::u32string& name_, const std::u32string& title_, const std::string& htmlFilePath_, LexerFile* lexerFile_);
40 Grammar(const std::u32string& name_, const std::u32string& title_, const std::string& htmlFilePath_, GrammarParser* parser_);
41 Kind GetKind() const { return kind; }
42 const std::u32string& Name() const { return name; }
43 const std::u32string& Title() const { return title; }
44 const std::string& HtmlFilePath() const { return htmlFilePath; }
45 GrammarParser* Parser() const { return parser; }
46 const std::u32string& HtmlFileName() const { return htmlFileName; }
47 void AddRule(Rule* rule);
48 const std::std::vector<std::std::unique_ptr<Rule>>&Rules() const{returnrules;}
49 private:
50 Kind kind;
51 std::u32string name;
52 std::u32string title;
53 std::string htmlFilePath;
54 LexerFile* lexerFile;
55 GrammarParser* parser;
56 std::u32string htmlFileName;
57 std::string htmfFilePath;
58 std::vector<std::std::unique_ptr<Rule>>rules;
59 };
60
61 } }
62
63 #endif // SNG2HTML_SNG2HTML_GRAMMAR_INCLUDED