00001 // scriptparse.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_SCRIPTPARSER_H_ 00011 #define _CELSCRIPT_SCRIPTPARSER_H_ 00012 00013 #include <celscript/celx.h> 00014 #include <string> 00015 #include <vector> 00016 #include <celscript/scanner.h> 00017 #include <celscript/expression.h> 00018 #include <celscript/statement.h> 00019 00020 namespace celx 00021 { 00022 00023 class Parser 00024 { 00025 public: 00026 Parser(Scanner&); 00027 ~Parser(); 00028 00029 Expression* parseExpression(); 00030 Expression* parseFinalExpression(); 00031 Expression* parseSubexpression(); 00032 Expression* parseFunctionCallExpression(); 00033 Expression* parseUnaryExpression(); 00034 Expression* parseMultiplyExpression(); 00035 Expression* parseAddExpression(); 00036 Expression* parseEqualityExpression(); 00037 Expression* parseRelationalExpression(); 00038 Expression* parseAssignmentExpression(); 00039 00040 Function* parseFunction(); 00041 00042 Statement* parseStatement(); 00043 Statement* parseVarStatement(); 00044 Statement* parseCompoundStatement(); 00045 Statement* parseExpressionStatement(); 00046 Statement* parseIfStatement(); 00047 Statement* parseWhileStatement(); 00048 Statement* parseReturnStatement(); 00049 00050 private: 00051 void syntaxError(const std::string&); 00052 00053 int resolveName(const std::string&); 00054 void defineLocal(const std::string&); 00055 void beginFrame(); 00056 void endFrame(); 00057 00058 Scanner& scanner; 00059 std::vector<std::string> scope; 00060 int loopDepth; 00061 int funcDepth; 00062 }; 00063 00064 } // namespace celx 00065 00066 #endif // _CELSCRIPT_SCRIPTPARSER_H_
1.4.1