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 |
1297
|
23 #if defined (__GNUG__) |
|
24 #pragma implementation |
|
25 #endif |
|
26 |
240
|
27 #ifdef HAVE_CONFIG_H |
1192
|
28 #include <config.h> |
142
|
29 #endif |
|
30 |
1343
|
31 #include <cassert> |
142
|
32 |
1288
|
33 #include "error.h" |
1352
|
34 #include "symtab.h" |
142
|
35 #include "token.h" |
|
36 #include "utils.h" |
|
37 |
529
|
38 token::token (int l, int c) |
142
|
39 { |
|
40 line_num = l; |
|
41 column_num = c; |
|
42 type_tag = generic_token; |
|
43 } |
|
44 |
1755
|
45 token::token (const string& s, int l, int c) |
142
|
46 { |
|
47 line_num = l; |
|
48 column_num = c; |
|
49 type_tag = string_token; |
1755
|
50 str = new string (s); |
142
|
51 } |
|
52 |
1971
|
53 token::token (double d, const string& s, int l, int c) |
142
|
54 { |
|
55 line_num = l; |
|
56 column_num = c; |
|
57 type_tag = double_token; |
|
58 num = d; |
1971
|
59 orig_text = s; |
142
|
60 } |
|
61 |
529
|
62 token::token (end_tok_type t, int l, int c) |
142
|
63 { |
|
64 line_num = l; |
|
65 column_num = c; |
|
66 type_tag = ettype_token; |
|
67 et = t; |
|
68 } |
|
69 |
529
|
70 token::token (plot_tok_type t, int l, int c) |
142
|
71 { |
|
72 line_num = l; |
|
73 column_num = c; |
|
74 type_tag = pttype_token; |
|
75 pt = t; |
|
76 } |
|
77 |
529
|
78 token::token (symbol_record *s, int l, int c) |
142
|
79 { |
|
80 line_num = l; |
|
81 column_num = c; |
|
82 type_tag = sym_rec_token; |
|
83 sr = s; |
|
84 } |
|
85 |
|
86 token::~token (void) |
|
87 { |
|
88 if (type_tag == string_token) |
1755
|
89 delete str; |
142
|
90 } |
|
91 |
1755
|
92 string |
|
93 token::text (void) |
142
|
94 { |
|
95 assert (type_tag == string_token); |
1755
|
96 return *str; |
142
|
97 } |
|
98 |
|
99 double |
|
100 token::number (void) |
|
101 { |
|
102 assert (type_tag == double_token); |
|
103 return num; |
|
104 } |
|
105 |
|
106 token::end_tok_type |
|
107 token::ettype (void) |
|
108 { |
|
109 assert (type_tag == ettype_token); |
|
110 return et; |
|
111 } |
|
112 |
|
113 token::plot_tok_type |
|
114 token::pttype (void) |
|
115 { |
|
116 assert (type_tag == pttype_token); |
|
117 return pt; |
|
118 } |
|
119 |
|
120 symbol_record * |
|
121 token::sym_rec (void) |
|
122 { |
|
123 assert (type_tag == sym_rec_token); |
|
124 return sr; |
|
125 } |
|
126 |
1755
|
127 string |
581
|
128 token::text_rep (void) |
|
129 { |
|
130 return orig_text; |
|
131 } |
|
132 |
1488
|
133 token::token (const token& /* tok */) |
1288
|
134 { |
|
135 panic_impossible (); |
|
136 } |
|
137 |
|
138 token& |
1488
|
139 token::operator = (const token& /* tok */) |
1288
|
140 { |
|
141 panic_impossible (); |
|
142 } |
|
143 |
142
|
144 /* |
|
145 ;;; Local Variables: *** |
|
146 ;;; mode: C++ *** |
|
147 ;;; End: *** |
|
148 */ |