00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#ifndef __KSCRIPT_PARSENODE_H__
00021
#define __KSCRIPT_PARSENODE_H__
00022
00023
#include <qstring.h>
00024
00025
#include "koscript_types.h"
00026
00027
#define MAX_NODE_SIZE 255
00028
00029
typedef enum
00030 {
00031 definitions = 0,
00032 exports,
00033 t_vertical_line,
00034 t_circumflex,
00035 t_ampersand,
00036 t_shiftright,
00037 t_shiftleft,
00038 t_plus_sign,
00039 t_minus_sign,
00040 t_asterik,
00041 t_solidus,
00042 t_percent_sign,
00043 t_tilde,
00044 t_integer_literal,
00045 t_string_literal,
00046 t_character_literal,
00047 t_floating_pt_literal,
00048 t_boolean_literal,
00049 scoped_name,
00050 const_dcl,
00051 func_dcl,
00052 func_lines,
00053 assign_expr,
00054 t_equal,
00055 t_notequal,
00056 t_less_or_equal,
00057 t_greater_or_equal,
00058 t_array,
00059 t_dict,
00060 func_params,
00061 func_param_in,
00062 func_param_out,
00063 func_param_inout,
00064 t_func_call,
00065 member_expr,
00066 t_array_const,
00067 t_array_element,
00068 t_dict_const,
00069 t_dict_element,
00070 t_while,
00071 t_do,
00072 t_for,
00073 t_if,
00074 t_incr,
00075 t_decr,
00076 t_less,
00077 t_greater,
00078 t_foreach,
00079 t_match,
00080 t_subst,
00081 t_not,
00082 func_call_params,
00083 t_return,
00084 destructor_dcl,
00085
import,
00086 t_struct,
00087 t_struct_members,
00088 t_qualified_names,
00089 t_scope,
00090 t_try,
00091 t_catch,
00092 t_catch_default,
00093 t_raise,
00094 t_cell,
00095 t_range,
00096 from,
00097 plus_assign,
00098 minus_assign,
00099 bool_or,
00100 bool_and,
00101 t_regexp_group,
00102 t_input,
00103 t_line,
00104 t_match_line
00105 } KSParseNodeType;
00106
00107
class KSContext;
00108
00113 class KSParseNodeExtra
00114 {
00115
public:
00116
virtual ~
KSParseNodeExtra() { }
00117 };
00118
00119
class KSParseNode
00120 {
00121
private:
00122 KSParseNode &operator=(
const KSParseNode &rhs);
00123 KSParseNode(
const KSParseNode &rhs);
00124
00125 KSParseNodeType type;
00126
QString ident;
00127
00128
QString fname;
00129
long line_no;
00130
bool bIsToplevel;
00131
00132
union u {
00133 KScript::Long _int;
00134 KScript::Boolean _bool;
00135 KScript::Double _float;
00136 ushort _char;
00137 } _u;
00138
QString* str;
00139
00140
KSParseNodeExtra* m_extra;
00141 KSParseNode *b1;
00142 KSParseNode *b2;
00143 KSParseNode *b3;
00144 KSParseNode *b4;
00145 KSParseNode *b5;
00146
00147
void printBranch(
int indent,
const char *tag,
bool detailed );
00148
00149
public:
00150 KSParseNode( KSParseNodeType aType, KSParseNode *one = NULL,
00151 KSParseNode *two = NULL, KSParseNode *three = NULL,
00152 KSParseNode *four = NULL, KSParseNode *five = NULL );
00153 ~KSParseNode();
00154
void clear();
00155
00156
bool eval( KSContext& );
00157
00158 KSParseNodeType getType() const;
00159
void setIdent( const
char *anIdent );
00160
void setIdent(
QString* anIdent );
00161
void setIdent( const
QString& anIdent );
00162
QString getIdent();
00163
QString getFname();
00164
long getLineNo();
00165
bool isToplevel();
00166
00167
void setIntegerLiteral( KScript::Long l );
00168 KScript::Long getIntegerLiteral();
00169
void setStringLiteral( const
char *s );
00170
void setStringLiteral( const
QString& s );
00171
void setStringLiteral(
QString* s );
00172
QString getStringLiteral();
00173
void setCharacterLiteral( const KScript::Char& c );
00174 KScript::Char getCharacterLiteral();
00175
void setFloatingPtLiteral( KScript::Double f );
00176 KScript::Double getFloatingPtLiteral();
00177
void setBooleanLiteral( KScript::Boolean b );
00178 KScript::Boolean getBooleanLiteral();
00179
00180 KSParseNode *branch1() {
return b1; }
00181 KSParseNode *branch2() {
return b2; }
00182 KSParseNode *branch3() {
return b3; }
00183 KSParseNode *branch4() {
return b4; }
00184 KSParseNode *branch5() {
return b5; }
00185 KSParseNode *getBranch(
int i );
00186
void setBranch(
int i, KSParseNode *node );
00187
00188
KSParseNodeExtra* extra();
00189
void setExtra(
KSParseNodeExtra* e );
00190
00191
void print(
bool detailed =
false );
00192 };
00193
00194
#endif