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
14
class
CodeWriterVisitor
:
public
LingoDec::NodeVisitor
{
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
LingoDec::BlockNode
Definition:
ast.h:145
LingoDec::SpritePropExprNode
Definition:
ast.h:659
LingoDec::TellStmtNode
Definition:
ast.h:477
LingoDec::InverseOpNode
Definition:
ast.h:180
LingoDec::CaseStmtNode
Definition:
ast.h:458
Common::String
Definition:
str.h:59
LingoDec::RepeatWithInStmtNode
Definition:
ast.h:381
LingoDec::PlayCmdStmtNode
Definition:
ast.h:506
LingoDec::ChunkDeleteStmtNode
Definition:
ast.h:254
LingoDec::TheExprNode
Definition:
ast.h:577
LingoDec::RepeatWithToStmtNode
Definition:
ast.h:399
LingoDec::ObjCallNode
Definition:
ast.h:539
LingoDec::Datum
Definition:
ast.h:26
LingoDec::ExitStmtNode
Definition:
ast.h:173
LingoDec::WhenStmtNode
Definition:
ast.h:773
LingoDec::ErrorNode
Definition:
ast.h:115
LingoDec::ChunkExprNode
Definition:
ast.h:222
LingoDec::SpriteIntersectsExprNode
Definition:
ast.h:266
LingoDec::AssignmentStmtNode
Definition:
ast.h:328
LingoDec
Definition:
cast.h:33
LingoDec::ObjPropExprNode
Definition:
ast.h:687
LingoDec::ThePropExprNode
Definition:
ast.h:673
LingoDec::ObjBracketExprNode
Definition:
ast.h:702
LingoDec::NextRepeatStmtNode
Definition:
ast.h:749
LingoDec::MenuPropExprNode
Definition:
ast.h:614
LingoDec::BinaryOpNode
Definition:
ast.h:204
LingoDec::PutStmtNode
Definition:
ast.h:756
LingoDec::CodeWriterVisitor
Definition:
codewritervisitor.h:14
LingoDec::RepeatWhileStmtNode
Definition:
ast.h:365
LingoDec::LastStringChunkExprNode
Definition:
ast.h:586
LingoDec::NewObjNode
Definition:
ast.h:784
LingoDec::CaseLabelNode
Definition:
ast.h:421
LingoDec::LiteralNode
Definition:
ast.h:132
LingoDec::IfStmtNode
Definition:
ast.h:346
LingoDec::NotOpNode
Definition:
ast.h:192
LingoDec::CallNode
Definition:
ast.h:518
LingoDec::SpriteWithinExprNode
Definition:
ast.h:282
LingoDec::MenuItemPropExprNode
Definition:
ast.h:628
LingoDec::ChunkHiliteStmtNode
Definition:
ast.h:242
LingoDec::VarNode
Definition:
ast.h:318
LingoDec::ObjCallV4Node
Definition:
ast.h:558
LingoDec::SoundPropExprNode
Definition:
ast.h:645
LingoDec::HandlerNode
Definition:
ast.h:159
LingoDec::MemberExprNode
Definition:
ast.h:298
LingoDec::OtherwiseNode
Definition:
ast.h:439
LingoDec::ExitRepeatStmtNode
Definition:
ast.h:742
LingoDec::StringChunkCountExprNode
Definition:
ast.h:600
LingoDec::EndCaseNode
Definition:
ast.h:451
LingoDec::CommentNode
Definition:
ast.h:123
LingoDec::ObjPropIndexExprNode
Definition:
ast.h:719
LingoDec::NodeVisitor
Definition:
ast.h:792
LingoDec::SoundCmdStmtNode
Definition:
ast.h:492
engines
director
lingo
lingodec
codewritervisitor.h
Generated on Sat Aug 31 2024 09:10:12 for ScummVM API documentation by
1.8.13