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, |
2764
|
54 switch_end, |
142
|
55 while_end, |
1489
|
56 try_catch_end, |
915
|
57 unwind_protect_end, |
142
|
58 }; |
|
59 |
|
60 enum plot_tok_type |
|
61 { |
476
|
62 replot = 1, |
142
|
63 two_dee = 2, |
|
64 three_dee = 3, |
|
65 }; |
|
66 |
|
67 token (int l = -1, int c = -1); |
1755
|
68 token (const string& s, int l = -1, int c = -1); |
|
69 token (double d, const string& s = string (), int l = -1, int c = -1); |
142
|
70 token (end_tok_type t, int l = -1, int c = -1); |
|
71 token (plot_tok_type t, int l = -1, int c = -1); |
|
72 token (symbol_record *s, int l = -1, int c = -1); |
|
73 |
1755
|
74 ~token (void); |
142
|
75 |
1755
|
76 int line (void) { return line_num; } |
|
77 int column (void) { return column_num; } |
142
|
78 |
1755
|
79 string text (void); |
142
|
80 double number (void); |
|
81 end_tok_type ettype (void); |
|
82 plot_tok_type pttype (void); |
|
83 symbol_record *sym_rec (void); |
|
84 |
1755
|
85 string text_rep (void); |
581
|
86 |
142
|
87 private: |
1288
|
88 token (const token& tok); |
|
89 token& operator = (const token& tok); |
|
90 |
142
|
91 int line_num; |
|
92 int column_num; |
|
93 token_type type_tag; |
|
94 union |
|
95 { |
1755
|
96 string *str; |
142
|
97 double num; |
|
98 end_tok_type et; |
|
99 plot_tok_type pt; |
|
100 symbol_record *sr; |
|
101 }; |
1755
|
102 string orig_text; |
142
|
103 }; |
|
104 |
|
105 #endif |
|
106 |
|
107 /* |
|
108 ;;; Local Variables: *** |
|
109 ;;; mode: C++ *** |
|
110 ;;; End: *** |
|
111 */ |