142
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2002, 2004, 2005, |
9476
|
4 2007, 2008, 2009 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, |
9476
|
41 sym_rec_token, |
|
42 scls_rec_token, |
|
43 meta_rec_token |
142
|
44 }; |
|
45 |
|
46 enum end_tok_type |
|
47 { |
|
48 simple_end, |
9476
|
49 classdef_end, |
|
50 events_end, |
142
|
51 for_end, |
|
52 function_end, |
|
53 if_end, |
9476
|
54 methods_end, |
|
55 properties_end, |
2764
|
56 switch_end, |
142
|
57 while_end, |
1489
|
58 try_catch_end, |
3548
|
59 unwind_protect_end |
142
|
60 }; |
|
61 |
|
62 enum plot_tok_type |
|
63 { |
476
|
64 replot = 1, |
142
|
65 two_dee = 2, |
3548
|
66 three_dee = 3 |
142
|
67 }; |
|
68 |
|
69 token (int l = -1, int c = -1); |
3523
|
70 token (const std::string& s, int l = -1, int c = -1); |
3552
|
71 token (double d, const std::string& s = std::string (), |
10313
|
72 int l = -1, int c = -1); |
142
|
73 token (end_tok_type t, int l = -1, int c = -1); |
|
74 token (plot_tok_type t, int l = -1, int c = -1); |
7336
|
75 token (symbol_table::symbol_record *s, int l = -1, int c = -1); |
9476
|
76 token (symbol_table::symbol_record *cls, |
|
77 symbol_table::symbol_record *pkg, int l = -1, int c = -1); |
|
78 token (symbol_table::symbol_record *mth, |
|
79 symbol_table::symbol_record *cls, |
|
80 symbol_table::symbol_record *pkg, int l = -1, int c = -1); |
142
|
81 |
1755
|
82 ~token (void); |
142
|
83 |
1755
|
84 int line (void) { return line_num; } |
|
85 int column (void) { return column_num; } |
142
|
86 |
3523
|
87 std::string text (void); |
142
|
88 double number (void); |
|
89 end_tok_type ettype (void); |
|
90 plot_tok_type pttype (void); |
7336
|
91 symbol_table::symbol_record *sym_rec (void); |
142
|
92 |
9476
|
93 symbol_table::symbol_record *method_rec (void); |
|
94 symbol_table::symbol_record *class_rec (void); |
|
95 symbol_table::symbol_record *package_rec (void); |
|
96 |
|
97 symbol_table::symbol_record *meta_class_rec (void); |
|
98 symbol_table::symbol_record *meta_package_rec (void); |
|
99 |
3523
|
100 std::string text_rep (void); |
581
|
101 |
142
|
102 private: |
3552
|
103 |
|
104 // No copying! |
|
105 |
1288
|
106 token (const token& tok); |
3552
|
107 |
1288
|
108 token& operator = (const token& tok); |
|
109 |
142
|
110 int line_num; |
|
111 int column_num; |
|
112 token_type type_tag; |
|
113 union |
|
114 { |
3523
|
115 std::string *str; |
142
|
116 double num; |
|
117 end_tok_type et; |
|
118 plot_tok_type pt; |
7336
|
119 symbol_table::symbol_record *sr; |
9476
|
120 struct |
|
121 { |
|
122 symbol_table::symbol_record *mr; |
|
123 symbol_table::symbol_record *cr; |
|
124 symbol_table::symbol_record *pr; |
|
125 } sc; |
|
126 struct |
|
127 { |
|
128 symbol_table::symbol_record *cr; |
|
129 symbol_table::symbol_record *pr; |
|
130 } mc; |
142
|
131 }; |
3523
|
132 std::string orig_text; |
142
|
133 }; |
|
134 |
|
135 #endif |