00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_token_h)
00025 #define octave_token_h 1
00026
00027 #include <string>
00028
00029 class
00030 token
00031 {
00032 public:
00033
00034 enum token_type
00035 {
00036 generic_token,
00037 string_token,
00038 double_token,
00039 ettype_token,
00040 pttype_token,
00041 sym_rec_token,
00042 scls_rec_token,
00043 meta_rec_token
00044 };
00045
00046 enum end_tok_type
00047 {
00048 simple_end,
00049 classdef_end,
00050 events_end,
00051 for_end,
00052 function_end,
00053 if_end,
00054 methods_end,
00055 properties_end,
00056 switch_end,
00057 while_end,
00058 try_catch_end,
00059 unwind_protect_end
00060 };
00061
00062 enum plot_tok_type
00063 {
00064 replot = 1,
00065 two_dee = 2,
00066 three_dee = 3
00067 };
00068
00069 token (int l = -1, int c = -1);
00070 token (const std::string& s, int l = -1, int c = -1);
00071 token (double d, const std::string& s = std::string (),
00072 int l = -1, int c = -1);
00073 token (end_tok_type t, int l = -1, int c = -1);
00074 token (plot_tok_type t, int l = -1, int c = -1);
00075 token (symbol_table::symbol_record *s, int l = -1, int c = -1);
00076 token (symbol_table::symbol_record *cls,
00077 symbol_table::symbol_record *pkg, int l = -1, int c = -1);
00078 token (symbol_table::symbol_record *mth,
00079 symbol_table::symbol_record *cls,
00080 symbol_table::symbol_record *pkg, int l = -1, int c = -1);
00081
00082 ~token (void);
00083
00084 int line (void) { return line_num; }
00085 int column (void) { return column_num; }
00086
00087 std::string text (void);
00088 double number (void);
00089 end_tok_type ettype (void);
00090 plot_tok_type pttype (void);
00091 symbol_table::symbol_record *sym_rec (void);
00092
00093 symbol_table::symbol_record *method_rec (void);
00094 symbol_table::symbol_record *class_rec (void);
00095 symbol_table::symbol_record *package_rec (void);
00096
00097 symbol_table::symbol_record *meta_class_rec (void);
00098 symbol_table::symbol_record *meta_package_rec (void);
00099
00100 std::string text_rep (void);
00101
00102 private:
00103
00104
00105
00106 token (const token& tok);
00107
00108 token& operator = (const token& tok);
00109
00110 int line_num;
00111 int column_num;
00112 token_type type_tag;
00113 union
00114 {
00115 std::string *str;
00116 double num;
00117 end_tok_type et;
00118 plot_tok_type pt;
00119 symbol_table::symbol_record *sr;
00120 struct
00121 {
00122 symbol_table::symbol_record *mr;
00123 symbol_table::symbol_record *cr;
00124 symbol_table::symbol_record *pr;
00125 } sc;
00126 struct
00127 {
00128 symbol_table::symbol_record *cr;
00129 symbol_table::symbol_record *pr;
00130 } mc;
00131 };
00132 std::string orig_text;
00133 };
00134
00135 #endif
00136
00137
00138
00139
00140
00141