ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

abstractsyntaxtree.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef STARK_TOOLS_ABSTRACT_SYNTAX_TREE_H
00024 #define STARK_TOOLS_ABSTRACT_SYNTAX_TREE_H
00025 
00026 #include "common/array.h"
00027 
00028 #include "engines/stark/tools/command.h"
00029 
00030 namespace Stark {
00031 namespace Tools {
00032 
00033 struct ASTCommand;
00034 
00040 struct ASTNode {
00041     ASTNode(ASTNode *parent);
00042     virtual ~ASTNode();
00043 
00045     virtual void print(uint depth, DefinitionRegistry *definitions) = 0;
00046 
00048     virtual Common::Array<const ASTCommand *> listCommands(uint16 index) const = 0;
00049 
00051     void findSuccessors(ASTNode **follower, ASTNode **trueBranch, ASTNode **falseBranch) const;
00052     virtual void findSuccessorsIntern(const ASTNode *node, ASTNode **follower, ASTNode **trueBranch, ASTNode **falseBranch) const = 0;
00053 
00055     virtual const ASTCommand *getFirstCommand() const = 0;
00056 
00057 protected:
00058     void printWithDepth(uint depth, const Common::String &string) const;
00059 
00060     ASTNode *_parent;
00061 };
00062 
00068 struct ASTCommand : public ASTNode, public Command {
00069     ASTCommand(ASTNode *parent, Command *command, DefinitionRegistry *definitions);
00070 
00071     // ASTNode API
00072     void print(uint depth, DefinitionRegistry *definitions) override;
00073     Common::Array<const ASTCommand *> listCommands(uint16 index) const override;
00074     void findSuccessorsIntern(const ASTNode *node, ASTNode **follower, ASTNode **trueBranch, ASTNode **falseBranch) const override;
00075     const ASTCommand *getFirstCommand() const override;
00076 
00078     Common::String callString(DefinitionRegistry *definitions);
00079 };
00080 
00086 struct ASTBlock : public ASTNode {
00087     ASTBlock(ASTNode *parent);
00088     ~ASTBlock() override;
00089 
00090     // ASTNode API
00091     void print(uint depth, DefinitionRegistry *definitions) override;
00092     Common::Array<const ASTCommand *> listCommands(uint16 index) const override;
00093     void findSuccessorsIntern(const ASTNode *node, ASTNode **follower, ASTNode **trueBranch, ASTNode **falseBranch) const override;
00094     const ASTCommand *getFirstCommand() const override;
00095 
00097     void addNode(ASTNode *node);
00098 
00099 private:
00100     Common::Array<ASTNode *> _children;
00101 };
00102 
00108 struct ASTCondition : public ASTNode {
00109     ASTCondition(ASTNode *parent);
00110     ~ASTCondition() override;
00111 
00112     // ASTNode API
00113     void print(uint depth, DefinitionRegistry *definitions) override;
00114     Common::Array<const ASTCommand *> listCommands(uint16 index) const override;
00115     void findSuccessorsIntern(const ASTNode *node, ASTNode **follower, ASTNode **trueBranch, ASTNode **falseBranch) const override;
00116     const ASTCommand *getFirstCommand() const override;
00117 
00118     ASTCommand *condition;
00119     bool invertedCondition;
00120     ASTBlock *thenBlock;
00121     ASTBlock *elseBlock;
00122 };
00123 
00129 struct ASTLoop : public ASTNode {
00130     ASTLoop(ASTNode *parent);
00131     ~ASTLoop() override;
00132 
00133     // ASTNode API
00134     void print(uint depth, DefinitionRegistry *definitions) override;
00135     Common::Array<const ASTCommand *> listCommands(uint16 index) const override;
00136     void findSuccessorsIntern(const ASTNode *node, ASTNode **follower, ASTNode **trueBranch, ASTNode **falseBranch) const override;
00137     const ASTCommand *getFirstCommand() const override;
00138 
00139     ASTCommand *condition;
00140     bool invertedCondition;
00141     ASTBlock *loopBlock;
00142 };
00143 
00144 } // End of namespace Tools
00145 } // End of namespace Stark
00146 
00147 #endif // STARK_TOOLS_ABSTRACT_SYNTAX_TREE_H


Generated on Sat Nov 30 2019 05:00:30 for ResidualVM by doxygen 1.7.1
curved edge   curved edge