SHARE
TWEET

Untitled

a guest Dec 6th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. class FormatVisitor: public BaseVisitor {
  4. public:
  5.     void Visit(const BaseNode* node) override {
  6.         node->Visit(this);
  7.     }
  8.  
  9.     void Visit(const ClassDeclarationNode* node) override {
  10.         node->Visit(this);
  11.     }
  12.  
  13.     void Visit(const VarDeclarationNode* node) override {
  14.         node->Visit(this);
  15.     }
  16.     void Visit(const MethodDeclarationNode* node) override {
  17.         node->Visit(this);
  18.     }
  19.  
  20.     const std::vector<std::string>& GetFormattedCode() const {
  21.         std::vector<std::string> formatted = {
  22.                 "class MyClass {",
  23.                 "  public:",
  24.                 "    void Print();",
  25.                 "    void SetNum(int n);",
  26.                 "",
  27.                 "  protected:",
  28.                 "    OtherClass SomeMethod(int a, char b, MyClass c);",
  29.                 "    int x_;",
  30.                 "",
  31.                 "  private:",
  32.                 "    void SetNumImpl(int num);",
  33.                 "    class Iterator {",
  34.                 "      public:",
  35.                 "        void Next();",
  36.                 "        bool Stopped();",
  37.                 "        int* Dereference();",
  38.                 "    };",
  39.                 "};",
  40.         };
  41.     }
  42. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top