142
|
1 // token.h -*- C++ -*- |
|
2 /* |
|
3 |
1009
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
142
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
142
|
21 |
|
22 */ |
|
23 |
383
|
24 #if !defined (octave_token_h) |
|
25 #define octave_token_h 1 |
142
|
26 |
1297
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
1755
|
31 #include <string> |
|
32 |
142
|
33 class symbol_record; |
|
34 |
453
|
35 class |
|
36 token |
142
|
37 { |
|
38 public: |
|
39 enum token_type |
|
40 { |
|
41 generic_token, |
|
42 string_token, |
|
43 double_token, |
|
44 ettype_token, |
|
45 pttype_token, |
|
46 sym_rec_token, |
|
47 }; |
|
48 |
|
49 enum end_tok_type |
|
50 { |
|
51 simple_end, |
|
52 for_end, |
|
53 function_end, |
|
54 if_end, |
|
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 ;;; page-delimiter: "^/\\*" *** |
|
111 ;;; End: *** |
|
112 */ |