142
|
1 /* |
|
2 |
1884
|
3 Copyright (C) 1996 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 |
1297
|
26 #if defined (__GNUG__) |
|
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: |
|
38 enum token_type |
|
39 { |
|
40 generic_token, |
|
41 string_token, |
|
42 double_token, |
|
43 ettype_token, |
|
44 pttype_token, |
|
45 sym_rec_token, |
|
46 }; |
|
47 |
|
48 enum end_tok_type |
|
49 { |
|
50 simple_end, |
|
51 for_end, |
|
52 function_end, |
|
53 if_end, |
|
54 while_end, |
1489
|
55 try_catch_end, |
915
|
56 unwind_protect_end, |
142
|
57 }; |
|
58 |
|
59 enum plot_tok_type |
|
60 { |
476
|
61 replot = 1, |
142
|
62 two_dee = 2, |
|
63 three_dee = 3, |
|
64 }; |
|
65 |
|
66 token (int l = -1, int c = -1); |
1755
|
67 token (const string& s, int l = -1, int c = -1); |
|
68 token (double d, const string& s = string (), int l = -1, int c = -1); |
142
|
69 token (end_tok_type t, int l = -1, int c = -1); |
|
70 token (plot_tok_type t, int l = -1, int c = -1); |
|
71 token (symbol_record *s, int l = -1, int c = -1); |
|
72 |
1755
|
73 ~token (void); |
142
|
74 |
1755
|
75 int line (void) { return line_num; } |
|
76 int column (void) { return column_num; } |
142
|
77 |
1755
|
78 string text (void); |
142
|
79 double number (void); |
|
80 end_tok_type ettype (void); |
|
81 plot_tok_type pttype (void); |
|
82 symbol_record *sym_rec (void); |
|
83 |
1755
|
84 string text_rep (void); |
581
|
85 |
142
|
86 private: |
1288
|
87 token (const token& tok); |
|
88 token& operator = (const token& tok); |
|
89 |
142
|
90 int line_num; |
|
91 int column_num; |
|
92 token_type type_tag; |
|
93 union |
|
94 { |
1755
|
95 string *str; |
142
|
96 double num; |
|
97 end_tok_type et; |
|
98 plot_tok_type pt; |
|
99 symbol_record *sr; |
|
100 }; |
1755
|
101 string orig_text; |
142
|
102 }; |
|
103 |
|
104 #endif |
|
105 |
|
106 /* |
|
107 ;;; Local Variables: *** |
|
108 ;;; mode: C++ *** |
|
109 ;;; End: *** |
|
110 */ |