ScummVM API documentation
codewritervisitor.h
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5  */
6 
7 #ifndef LINGODEC_CODEWRITERVISITOR_H
8 #define LINGODEC_CODEWRITERVISITOR_H
9 
10 #include "./ast.h"
11 
12 namespace LingoDec {
13 
15 public:
16  CodeWriterVisitor(bool dotSyntax, bool sum, const Common::String &lineEnding = "\n", const Common::String &indentation = " ")
17  : _dot(dotSyntax), _sum(sum), _lineEnding(lineEnding), _indentation(indentation) {}
18  virtual ~CodeWriterVisitor() {}
19  virtual void visit(const LingoDec::HandlerNode& node) override;
20  virtual void visit(const LingoDec::ErrorNode& node) override;
21  virtual void visit(const LingoDec::CommentNode& node) override;
22  virtual void visit(const LingoDec::NewObjNode& node) override;
23  virtual void visit(const LingoDec::LiteralNode& node) override;
24  virtual void visit(const LingoDec::IfStmtNode& node) override;
25  virtual void visit(const LingoDec::EndCaseNode& node) override;
26  virtual void visit(const LingoDec::ObjCallNode& node) override;
27  virtual void visit(const LingoDec::PutStmtNode& node) override;
28  virtual void visit(const LingoDec::TheExprNode& node) override;
29  virtual void visit(const LingoDec::BinaryOpNode& node) override;
30  virtual void visit(const LingoDec::CaseStmtNode& node) override;
31  virtual void visit(const LingoDec::ExitStmtNode& node) override;
32  virtual void visit(const LingoDec::TellStmtNode& node) override;
33  virtual void visit(const LingoDec::WhenStmtNode& node) override;
34  virtual void visit(const LingoDec::CaseLabelNode& node) override;
35  virtual void visit(const LingoDec::ChunkExprNode& node) override;
36  virtual void visit(const LingoDec::InverseOpNode& node) override;
37  virtual void visit(const LingoDec::ObjCallV4Node& node) override;
38  virtual void visit(const LingoDec::OtherwiseNode& node) override;
39  virtual void visit(const LingoDec::MemberExprNode& node) override;
40  virtual void visit(const LingoDec::ObjPropExprNode& node) override;
41  virtual void visit(const LingoDec::PlayCmdStmtNode& node) override;
42  virtual void visit(const LingoDec::ThePropExprNode& node) override;
43  virtual void visit(const LingoDec::MenuPropExprNode& node) override;
44  virtual void visit(const LingoDec::SoundCmdStmtNode& node) override;
45  virtual void visit(const LingoDec::SoundPropExprNode& node) override;
46  virtual void visit(const LingoDec::AssignmentStmtNode& node) override;
47  virtual void visit(const LingoDec::ExitRepeatStmtNode& node) override;
48  virtual void visit(const LingoDec::NextRepeatStmtNode& node) override;
49  virtual void visit(const LingoDec::ObjBracketExprNode& node) override;
50  virtual void visit(const LingoDec::SpritePropExprNode& node) override;
51  virtual void visit(const LingoDec::ChunkDeleteStmtNode& node) override;
52  virtual void visit(const LingoDec::ChunkHiliteStmtNode& node) override;
53  virtual void visit(const LingoDec::RepeatWhileStmtNode& node) override;
54  virtual void visit(const LingoDec::MenuItemPropExprNode& node) override;
55  virtual void visit(const LingoDec::ObjPropIndexExprNode& node) override;
56  virtual void visit(const LingoDec::RepeatWithInStmtNode& node) override;
57  virtual void visit(const LingoDec::RepeatWithToStmtNode& node) override;
58  virtual void visit(const LingoDec::SpriteWithinExprNode& node) override;
59  virtual void visit(const LingoDec::LastStringChunkExprNode& node) override;
60  virtual void visit(const LingoDec::SpriteIntersectsExprNode& node) override;
61  virtual void visit(const LingoDec::StringChunkCountExprNode& node) override;
62  virtual void visit(const LingoDec::VarNode& node) override;
63  virtual void visit(const LingoDec::CallNode& node) override;
64  virtual void visit(const LingoDec::BlockNode& node) override;
65  virtual void visit(const LingoDec::NotOpNode& node) override;
66 
67  size_t lineWidth() const { return _lineWidth; }
68  void indent();
69  void unindent();
70  void writeIndentation();
71  void write(char c);
72  void write(const Common::String& s);
73  void writeLine();
74  void writeLine(const Common::String& s);
75  void write(LingoDec::Datum& datum);
76 
77 public:
78  Common::String _str;
79 
80 private:
81  bool _dot = false;
82  bool _sum = false;
83  Common::String _lineEnding;
84  Common::String _indentation = " ";
85  bool _indentWritten = false;
86  int _indent = 0;
87  size_t _lineWidth = 0;
88 };
89 
90 } // namespace LingoDec
91 
92 #endif // LINGODEC_CODEWRITERVISITOR_H
Definition: ast.h:145
Definition: ast.h:659
Definition: ast.h:477
Definition: ast.h:180
Definition: ast.h:458
Definition: str.h:59
Definition: ast.h:381
Definition: ast.h:506
Definition: ast.h:254
Definition: ast.h:577
Definition: ast.h:399
Definition: ast.h:539
Definition: ast.h:26
Definition: ast.h:173
Definition: ast.h:773
Definition: ast.h:115
Definition: ast.h:222
Definition: ast.h:328
Definition: cast.h:33
Definition: ast.h:687
Definition: ast.h:673
Definition: ast.h:702
Definition: ast.h:749
Definition: ast.h:614
Definition: ast.h:204
Definition: ast.h:756
Definition: codewritervisitor.h:14
Definition: ast.h:365
Definition: ast.h:784
Definition: ast.h:421
Definition: ast.h:132
Definition: ast.h:346
Definition: ast.h:192
Definition: ast.h:518
Definition: ast.h:282
Definition: ast.h:628
Definition: ast.h:242
Definition: ast.h:318
Definition: ast.h:558
Definition: ast.h:645
Definition: ast.h:159
Definition: ast.h:298
Definition: ast.h:439
Definition: ast.h:742
Definition: ast.h:451
Definition: ast.h:123
Definition: ast.h:719
Definition: ast.h:792
Definition: ast.h:492