1 #ifndef Rosebud_YamlGenerator_H
2 #define Rosebud_YamlGenerator_H
3 #include <Rosebud/Generator.h>
5 #include <Sawyer/Yaml.h>
7 namespace Rosebud {
10 class YamlGenerator: public Generator {
11 public:
12  using Ptr = std::shared_ptr<YamlGenerator>;
14 private:
15  int indentationAmount = 2;
17 protected:
18  YamlGenerator() {}
20 public:
21  static Ptr instance();
22  virtual std::string name() const override;
23  virtual std::string purpose() const override;
24  virtual void adjustParser(Sawyer::CommandLine::Parser&) override;
25  virtual void generate(const Ast::ProjectPtr&) override;
26 private:
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 };
36 } // namespace
37 #endif
virtual void adjustParser(Sawyer::CommandLine::Parser &) override
Add command-line switches and documentation to a parser.
Graph containing user-defined vertices and edges.
Definition: Graph.h:625
std::shared_ptr< Project > ProjectPtr
Shared-ownership pointer to a Project.
Definition: ud/BasicTypes.h:55
Rosebud is a tool to generate code for ROSE.
Definition: Ast.h:14
std::shared_ptr< Definition > DefinitionPtr
Shared-ownership pointer to a Definition.
Definition: ud/BasicTypes.h:47
virtual std::string name() const override
Every generator should have a unique name.
Base class for backend code generators.
Definition: Generator.h:10
The parser for a program command line.
virtual std::string purpose() const override
Single-line description for documentation.
std::shared_ptr< Property > PropertyPtr
Shared-ownership pointer to a Property.
Definition: ud/BasicTypes.h:49
std::shared_ptr< Class > ClassPtr
Shared-ownership pointer to a Class.
Definition: ud/BasicTypes.h:51
std::shared_ptr< Attribute > AttributePtr
Shared-ownership pointer to a Attribute.
Definition: ud/BasicTypes.h:45
virtual void generate(const Ast::ProjectPtr &) override
Generate code.
std::shared_ptr< CppStack > CppStackPtr
Shared-ownership pointer to a CppStack.
Definition: ud/BasicTypes.h:43
std::shared_ptr< Node > NodePtr
Shared-ownership pointer to a Node.
Definition: ud/BasicTypes.h:37
Generator that produces a YAML description of the input.
Definition: YamlGenerator.h:10