Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

statement.h

Go to the documentation of this file.
00001 // statement.h
00002 //
00003 // Copyright (C) 2002, Chris Laurel <claurel@shatters.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 #ifndef CELSCRIPT_STATEMENT_H_
00011 #define CELSCRIPT_STATEMENT_H_
00012 
00013 #include <celscript/celx.h>
00014 #include <vector>
00015 #include <celscript/expression.h>
00016 #include <celscript/execution.h>
00017 
00018 
00019 namespace celx 
00020 {
00021 
00022 class Statement
00023 {
00024  public:
00025     Statement();
00026     virtual ~Statement();
00027 
00028     enum Control
00029     {
00030         ControlAdvance,
00031         ControlReturn,
00032         ControlBreak,
00033         ControlContinue,
00034     };
00035 
00036     virtual Control execute(ExecutionContext&) { return ControlAdvance; };
00037 };
00038 
00039 
00040 class EmptyStatement : public Statement
00041 {
00042 };
00043 
00044 
00045 class ExpressionStatement : public Statement
00046 {
00047  public:
00048     ExpressionStatement(Expression*);
00049     virtual ~ExpressionStatement();
00050 
00051     virtual Control execute(ExecutionContext&);
00052 
00053  private:
00054     Expression* expr;
00055 };
00056 
00057 
00058 class IfStatement : public Statement
00059 {
00060  public:
00061     IfStatement(Expression*, Statement*, Statement*);
00062     virtual ~IfStatement();
00063 
00064     virtual Control execute(ExecutionContext&);
00065 
00066  private:
00067     Expression* condition;
00068     Statement* ifClause;
00069     Statement* elseClause;
00070 };
00071 
00072 
00073 class VarStatement : public Statement
00074 {
00075  public:
00076     VarStatement(const std::string&, Expression*);
00077     virtual ~VarStatement();
00078 
00079     virtual Control execute(ExecutionContext&);
00080 
00081  private:
00082     std::string name;
00083     Expression* initializer;
00084 };
00085 
00086 
00087 class CompoundStatement : public Statement
00088 {
00089  public:
00090     CompoundStatement();
00091     virtual ~CompoundStatement();
00092 
00093     virtual Control execute(ExecutionContext&);
00094 
00095     void addStatement(Statement*);
00096 
00097  private:
00098     std::vector<Statement*> statements;
00099 };
00100 
00101 
00102 class ReturnStatement : public Statement
00103 {
00104  public:
00105     ReturnStatement(Expression*);
00106     virtual ~ReturnStatement();
00107 
00108     virtual Control execute(ExecutionContext&);
00109 
00110  private:
00111     Expression* expr;
00112 };
00113 
00114 
00115 class WhileStatement : public Statement
00116 {
00117  public:
00118     WhileStatement(Expression*, Statement*);
00119     virtual ~WhileStatement();
00120 
00121     virtual Control execute(ExecutionContext&);
00122 
00123  private:
00124     Expression* condition;
00125     Statement* body;
00126 };
00127 
00128 } // namespace celx
00129 
00130 #endif // CELSCRIPT_STATEMENT_H_

Generated on Sat Jan 14 22:30:32 2006 for Celestia by  doxygen 1.4.1