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