1 /**
2 This module defines the interfaces that work with statement and expression nodes. Interpreter and Compiler
3 implements all of these interfaces, although Interpreter will soon not implement these interfaces.
4 
5 ────────────────────────────────────────────────────────────────────────────────
6 
7 Copyright (C) 2021 pillager86.rf.gd
8 
9 This program is free software: you can redistribute it and/or modify it under 
10 the terms of the GNU General Public License as published by the Free Software 
11 Foundation, either version 3 of the License, or (at your option) any later 
12 version.
13 
14 This program is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
16 PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License along with 
19 this program.  If not, see <https://www.gnu.org/licenses/>.
20  */
21 module mildew.visitors;
22 
23 import std.variant;
24 
25 import mildew.nodes;
26 
27 package:
28 
29 interface IExpressionVisitor
30 {
31 	Variant visitLiteralNode(LiteralNode lnode);
32     Variant visitFunctionLiteralNode(FunctionLiteralNode flnode);
33     Variant visitLambdaNode(LambdaNode lnode);
34     Variant visitTemplateStringNode(TemplateStringNode tsnode);
35 	Variant visitArrayLiteralNode(ArrayLiteralNode alnode);
36 	Variant visitObjectLiteralNode(ObjectLiteralNode olnode);
37 	Variant visitClassLiteralNode(ClassLiteralNode clnode);
38 	Variant visitBinaryOpNode(BinaryOpNode bonode);
39 	Variant visitUnaryOpNode(UnaryOpNode uonode);
40 	Variant visitPostfixOpNode(PostfixOpNode ponode);
41 	Variant visitTerniaryOpNode(TerniaryOpNode tonode);
42 	Variant visitVarAccessNode(VarAccessNode vanode);
43 	Variant visitFunctionCallNode(FunctionCallNode fcnode);
44 	Variant visitArrayIndexNode(ArrayIndexNode ainode);
45 	Variant visitMemberAccessNode(MemberAccessNode manode);
46 	Variant visitNewExpressionNode(NewExpressionNode nenode);
47     Variant visitSuperNode(SuperNode snode);
48     Variant visitYieldNode(YieldNode ynode);
49 }
50 
51 interface IStatementVisitor 
52 {
53 	Variant visitVarDeclarationStatementNode(VarDeclarationStatementNode vdsnode);
54 	Variant visitBlockStatementNode(BlockStatementNode bsnode);
55 	Variant visitIfStatementNode(IfStatementNode isnode);
56 	Variant visitSwitchStatementNode(SwitchStatementNode ssnode);
57 	Variant visitWhileStatementNode(WhileStatementNode wsnode);
58 	Variant visitDoWhileStatementNode(DoWhileStatementNode dwsnode);
59 	Variant visitForStatementNode(ForStatementNode fsnode);
60 	Variant visitForOfStatementNode(ForOfStatementNode fosnode);
61 	Variant visitBreakStatementNode(BreakStatementNode bsnode);
62 	Variant visitContinueStatementNode(ContinueStatementNode csnode);
63 	Variant visitReturnStatementNode(ReturnStatementNode rsnode);
64 	Variant visitFunctionDeclarationStatementNode(FunctionDeclarationStatementNode fdsnode);
65 	Variant visitThrowStatementNode(ThrowStatementNode tsnode);
66 	Variant visitTryCatchBlockStatementNode(TryCatchBlockStatementNode tcbsnode);
67 	Variant visitDeleteStatementNode(DeleteStatementNode dsnode);
68 	Variant visitClassDeclarationStatementNode(ClassDeclarationStatementNode cdsnode);
69 	Variant visitExpressionStatementNode(ExpressionStatementNode esnode);
70 }
71 
72 interface INodeVisitor : IExpressionVisitor, IStatementVisitor {}