142
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
142
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
142
|
20 |
|
21 */ |
|
22 |
383
|
23 #if !defined (octave_token_h) |
|
24 #define octave_token_h 1 |
142
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
1297
|
27 #pragma interface |
|
28 #endif |
|
29 |
1755
|
30 #include <string> |
|
31 |
142
|
32 class symbol_record; |
|
33 |
453
|
34 class |
|
35 token |
142
|
36 { |
|
37 public: |
3548
|
38 |
142
|
39 enum token_type |
|
40 { |
|
41 generic_token, |
|
42 string_token, |
|
43 double_token, |
|
44 ettype_token, |
|
45 pttype_token, |
3548
|
46 sym_rec_token |
142
|
47 }; |
|
48 |
|
49 enum end_tok_type |
|
50 { |
|
51 simple_end, |
|
52 for_end, |
|
53 function_end, |
|
54 if_end, |
2764
|
55 switch_end, |
142
|
56 while_end, |
1489
|
57 try_catch_end, |
3548
|
58 unwind_protect_end |
142
|
59 }; |
|
60 |
|
61 enum plot_tok_type |
|
62 { |
476
|
63 replot = 1, |
142
|
64 two_dee = 2, |
3548
|
65 three_dee = 3 |
142
|
66 }; |
|
67 |
|
68 token (int l = -1, int c = -1); |
3523
|
69 token (const std::string& s, int l = -1, int c = -1); |
3552
|
70 token (double d, const std::string& s = std::string (), |
|
71 int l = -1, int c = -1); |
142
|
72 token (end_tok_type t, int l = -1, int c = -1); |
|
73 token (plot_tok_type t, int l = -1, int c = -1); |
|
74 token (symbol_record *s, int l = -1, int c = -1); |
|
75 |
1755
|
76 ~token (void); |
142
|
77 |
1755
|
78 int line (void) { return line_num; } |
|
79 int column (void) { return column_num; } |
142
|
80 |
3523
|
81 std::string text (void); |
142
|
82 double number (void); |
|
83 end_tok_type ettype (void); |
|
84 plot_tok_type pttype (void); |
|
85 symbol_record *sym_rec (void); |
|
86 |
3523
|
87 std::string text_rep (void); |
581
|
88 |
142
|
89 private: |
3552
|
90 |
|
91 // No copying! |
|
92 |
1288
|
93 token (const token& tok); |
3552
|
94 |
1288
|
95 token& operator = (const token& tok); |
|
96 |
142
|
97 int line_num; |
|
98 int column_num; |
|
99 token_type type_tag; |
|
100 union |
|
101 { |
3523
|
102 std::string *str; |
142
|
103 double num; |
|
104 end_tok_type et; |
|
105 plot_tok_type pt; |
|
106 symbol_record *sr; |
|
107 }; |
3523
|
108 std::string orig_text; |
142
|
109 }; |
|
110 |
|
111 #endif |
|
112 |
|
113 /* |
|
114 ;;; Local Variables: *** |
|
115 ;;; mode: C++ *** |
|
116 ;;; End: *** |
|
117 */ |