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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
142
|
21 |
|
22 */ |
|
23 |
383
|
24 #if !defined (octave_token_h) |
|
25 #define octave_token_h 1 |
142
|
26 |
1755
|
27 #include <string> |
|
28 |
142
|
29 class symbol_record; |
|
30 |
453
|
31 class |
|
32 token |
142
|
33 { |
|
34 public: |
3548
|
35 |
142
|
36 enum token_type |
|
37 { |
|
38 generic_token, |
|
39 string_token, |
|
40 double_token, |
|
41 ettype_token, |
|
42 pttype_token, |
3548
|
43 sym_rec_token |
142
|
44 }; |
|
45 |
|
46 enum end_tok_type |
|
47 { |
|
48 simple_end, |
|
49 for_end, |
|
50 function_end, |
|
51 if_end, |
2764
|
52 switch_end, |
142
|
53 while_end, |
1489
|
54 try_catch_end, |
3548
|
55 unwind_protect_end |
142
|
56 }; |
|
57 |
|
58 enum plot_tok_type |
|
59 { |
476
|
60 replot = 1, |
142
|
61 two_dee = 2, |
3548
|
62 three_dee = 3 |
142
|
63 }; |
|
64 |
|
65 token (int l = -1, int c = -1); |
3523
|
66 token (const std::string& s, int l = -1, int c = -1); |
3552
|
67 token (double d, const std::string& s = std::string (), |
|
68 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 |
3523
|
78 std::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 |
3523
|
84 std::string text_rep (void); |
581
|
85 |
142
|
86 private: |
3552
|
87 |
|
88 // No copying! |
|
89 |
1288
|
90 token (const token& tok); |
3552
|
91 |
1288
|
92 token& operator = (const token& tok); |
|
93 |
142
|
94 int line_num; |
|
95 int column_num; |
|
96 token_type type_tag; |
|
97 union |
|
98 { |
3523
|
99 std::string *str; |
142
|
100 double num; |
|
101 end_tok_type et; |
|
102 plot_tok_type pt; |
|
103 symbol_record *sr; |
|
104 }; |
3523
|
105 std::string orig_text; |
142
|
106 }; |
|
107 |
|
108 #endif |
|
109 |
|
110 /* |
|
111 ;;; Local Variables: *** |
|
112 ;;; mode: C++ *** |
|
113 ;;; End: *** |
|
114 */ |