ROSE 0.11.145.147
YamlGenerator.h
1#ifndef Rosebud_YamlGenerator_H
2#define Rosebud_YamlGenerator_H
3#include <Rosebud/Generator.h>
4
5#include <Sawyer/Yaml.h>
6
7namespace Rosebud {
8
10class YamlGenerator: public Generator {
11public:
12 using Ptr = std::shared_ptr<YamlGenerator>;
13
14private:
15 int indentationAmount = 2;
16
17protected:
18 YamlGenerator() {}
19
20public:
21 static Ptr instance();
22 virtual std::string name() const override;
23 virtual std::string purpose() const override;
25 virtual void generate(const Ast::ProjectPtr&) override;
26private:
27 void genLocation(Sawyer::Yaml::Node&, const Ast::NodePtr&, const Token&);
28 void genLocation(Sawyer::Yaml::Node&, const Ast::NodePtr&, const std::vector<Token>&);
29 void genClass(Sawyer::Yaml::Node&, const Ast::ClassPtr&, const Hierarchy&);
30 void genDefinition(Sawyer::Yaml::Node&, const Ast::DefinitionPtr&);
31 void genCppStack(Sawyer::Yaml::Node&, const Ast::CppStackPtr&);
32 void genProperty(Sawyer::Yaml::Node&, const Ast::PropertyPtr&);
33 void genAttribute(Sawyer::Yaml::Node&, const Ast::AttributePtr&);
34};
35
36} // namespace
37#endif
Base class for backend code generators.
Definition Generator.h:10
Generator that produces a YAML description of the input.
virtual std::string name() const override
Property: Every generator should have a unique name.
virtual void adjustParser(Sawyer::CommandLine::Parser &) override
Add command-line switches and documentation to a parser.
virtual void generate(const Ast::ProjectPtr &) override
Generate code.
virtual std::string purpose() const override
Property: Single-line description for documentation.
The parser for a program command line.
Graph containing user-defined vertices and edges.
Definition Graph.h:634
std::shared_ptr< Class > ClassPtr
Shared-ownership pointer to a Class.
std::shared_ptr< Property > PropertyPtr
Shared-ownership pointer to a Property.
std::shared_ptr< Node > NodePtr
Shared-ownership pointer to a Node.
std::shared_ptr< Definition > DefinitionPtr
Shared-ownership pointer to a Definition.
std::shared_ptr< Project > ProjectPtr
Shared-ownership pointer to a Project.
std::shared_ptr< CppStack > CppStackPtr
Shared-ownership pointer to a CppStack.
std::shared_ptr< Attribute > AttributePtr
Shared-ownership pointer to a Attribute.
Rosebud is a tool to generate abstract syntax trees.
Definition Ast.h:14