1
2
3
4
5
6 #ifndef SNG2HTML_SNG2HTML_GRAMMAR_HTML_GENERATOR_INCLUDED
7 #define SNG2HTML_SNG2HTML_GRAMMAR_HTML_GENERATOR_INCLUDED
8 #include <sng2html/sng2html/Visitor.hpp>
9 #include <sng2html/sng2html/Grammar.hpp>
10 #include <sng2html/sng2html/LexerFile.hpp>
11 #include <sngxml/dom/Element.hpp>
12 #include <unordered_map>
13
14 namespace sng2html { namespace sng2html {
15
16 class GrammarHtmlGeneratorVisitor : public Visitor
17 {
18 public:
19 GrammarHtmlGeneratorVisitor(bool verbose_, std::std::unordered_map<GrammarParser*, Grammar*>&parserGrammarMap_, std::std::unordered_map<RuleParser*, Rule*>&parserRuleMap_,
20 std::std::unordered_map<LexerFile*, Grammar*>&lexerGrammarMap_, std::std::unordered_map<Expression*, Rule*>&lexerRuleMap_,
21 std::std::unordered_map<std::u32string, LexerFile*>&lexerMap_, conststd::u32string&styleFilePath_);
22 void Visit(Char& symbol) override;
23 void Visit(Any& symbol) override;
24 void Visit(Range& symbol) override;
25 void Visit(Class& symbol) override;
26 void Visit(Alt& alt) override;
27 void Visit(Cat& cat) override;
28 void Visit(Kleene& kleene) override;
29 void Visit(Pos& pos) override;
30 void Visit(Opt& opt) override;
31 void Visit(ParenExpr& parenExpr) override;
32 void Visit(SymbolExpr& symbolExpr) override;
33 void Visit(RefExpr& refExpr) override;
34 void Visit(EmptyParser& parser) override;
35 void Visit(TokenParser& parser) override;
36 void Visit(CharParser& parser) override;
37 void Visit(StringParser& parser) override;
38 void Visit(CharSetParser& parser) override;
39 void Visit(OptionalParser& parser) override;
40 void Visit(KleeneParser& parser) override;
41 void Visit(PositiveParser& parser) override;
42 void Visit(ExpectationParser& parser) override;
43 void Visit(GroupingParser& parser) override;
44 void Visit(SequenceParser& parser) override;
45 void Visit(AlternativeParser& parser) override;
46 void Visit(DifferenceParser& parser) override;
47 void Visit(ListParser& parser) override;
48 void Visit(ActionParser& parser) override;
49 void Visit(NonterminalParser& parser) override;
50 void Visit(RuleParser& parser) override;
51 void Visit(GrammarParser& parser) override;
52 void Visit(ParserFile& parserFile) override;
53 void Visit(Domain& domain) override;
54 void Visit(LexerFile& lexerFile) override;
55 Grammar* GetGrammar(GrammarParser* parser) const;
56 Rule* GetRule(RuleParser* parser) const;
57 private:
58 bool verbose;
59 std::std::unordered_map<GrammarParser*, Grammar*>&parserGrammarMap;
60 std::std::unordered_map<RuleParser*, Rule*>&parserRuleMap;
61 std::std::unordered_map<LexerFile*, Grammar*>&lexerGrammarMap;
62 std::std::unordered_map<Expression*, Rule*>&lexerRuleMap;
63 std::std::unordered_map<std::u32string, LexerFile*>&lexerMap;
64 LexerFile* lexerFile;
65 std::u32string styleFilePath;
66 sngxml::dom::Element* ruleTable;
67 sngxml::dom::Element* ruleBodyElement;
68 GrammarParser* currentGrammar;
69 };
70
71 } }
72
73 #endif // SNG2HTML_SNG2HTML_GRAMMAR_HTML_GENERATOR_INCLUDED