142
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2002, 2004, 2005, |
|
4 2007 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 |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
142
|
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 |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
142
|
21 |
|
22 */ |
|
23 |
383
|
24 #if !defined (octave_token_h) |
|
25 #define octave_token_h 1 |
142
|
26 |
1755
|
27 #include <string> |
|
28 |
453
|
29 class |
|
30 token |
142
|
31 { |
|
32 public: |
3548
|
33 |
142
|
34 enum token_type |
|
35 { |
|
36 generic_token, |
|
37 string_token, |
|
38 double_token, |
|
39 ettype_token, |
|
40 pttype_token, |
3548
|
41 sym_rec_token |
142
|
42 }; |
|
43 |
|
44 enum end_tok_type |
|
45 { |
|
46 simple_end, |
|
47 for_end, |
|
48 function_end, |
|
49 if_end, |
2764
|
50 switch_end, |
142
|
51 while_end, |
1489
|
52 try_catch_end, |
3548
|
53 unwind_protect_end |
142
|
54 }; |
|
55 |
|
56 enum plot_tok_type |
|
57 { |
476
|
58 replot = 1, |
142
|
59 two_dee = 2, |
3548
|
60 three_dee = 3 |
142
|
61 }; |
|
62 |
|
63 token (int l = -1, int c = -1); |
3523
|
64 token (const std::string& s, int l = -1, int c = -1); |
3552
|
65 token (double d, const std::string& s = std::string (), |
|
66 int l = -1, int c = -1); |
142
|
67 token (end_tok_type t, int l = -1, int c = -1); |
|
68 token (plot_tok_type t, int l = -1, int c = -1); |
7336
|
69 token (symbol_table::symbol_record *s, int l = -1, int c = -1); |
142
|
70 |
1755
|
71 ~token (void); |
142
|
72 |
1755
|
73 int line (void) { return line_num; } |
|
74 int column (void) { return column_num; } |
142
|
75 |
3523
|
76 std::string text (void); |
142
|
77 double number (void); |
|
78 end_tok_type ettype (void); |
|
79 plot_tok_type pttype (void); |
7336
|
80 symbol_table::symbol_record *sym_rec (void); |
142
|
81 |
3523
|
82 std::string text_rep (void); |
581
|
83 |
142
|
84 private: |
3552
|
85 |
|
86 // No copying! |
|
87 |
1288
|
88 token (const token& tok); |
3552
|
89 |
1288
|
90 token& operator = (const token& tok); |
|
91 |
142
|
92 int line_num; |
|
93 int column_num; |
|
94 token_type type_tag; |
|
95 union |
|
96 { |
3523
|
97 std::string *str; |
142
|
98 double num; |
|
99 end_tok_type et; |
|
100 plot_tok_type pt; |
7336
|
101 symbol_table::symbol_record *sr; |
142
|
102 }; |
3523
|
103 std::string orig_text; |
142
|
104 }; |
|
105 |
|
106 #endif |
|
107 |
|
108 /* |
|
109 ;;; Local Variables: *** |
|
110 ;;; mode: C++ *** |
|
111 ;;; End: *** |
|
112 */ |