142
|
1 /* |
|
2 |
11523
|
3 Copyright (C) 1993-2011 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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
142
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
142
|
20 |
|
21 */ |
|
22 |
383
|
23 #if !defined (octave_token_h) |
|
24 #define octave_token_h 1 |
142
|
25 |
1755
|
26 #include <string> |
|
27 |
453
|
28 class |
|
29 token |
142
|
30 { |
|
31 public: |
3548
|
32 |
142
|
33 enum token_type |
|
34 { |
|
35 generic_token, |
|
36 string_token, |
|
37 double_token, |
|
38 ettype_token, |
9476
|
39 sym_rec_token, |
|
40 scls_rec_token, |
|
41 meta_rec_token |
142
|
42 }; |
|
43 |
|
44 enum end_tok_type |
|
45 { |
|
46 simple_end, |
9476
|
47 classdef_end, |
|
48 events_end, |
142
|
49 for_end, |
|
50 function_end, |
|
51 if_end, |
9476
|
52 methods_end, |
|
53 properties_end, |
2764
|
54 switch_end, |
142
|
55 while_end, |
1489
|
56 try_catch_end, |
3548
|
57 unwind_protect_end |
142
|
58 }; |
|
59 |
|
60 token (int l = -1, int c = -1); |
3523
|
61 token (const std::string& s, int l = -1, int c = -1); |
3552
|
62 token (double d, const std::string& s = std::string (), |
10313
|
63 int l = -1, int c = -1); |
142
|
64 token (end_tok_type t, int l = -1, int c = -1); |
7336
|
65 token (symbol_table::symbol_record *s, int l = -1, int c = -1); |
9476
|
66 token (symbol_table::symbol_record *cls, |
|
67 symbol_table::symbol_record *pkg, int l = -1, int c = -1); |
|
68 token (symbol_table::symbol_record *mth, |
|
69 symbol_table::symbol_record *cls, |
|
70 symbol_table::symbol_record *pkg, int l = -1, int c = -1); |
142
|
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); |
7336
|
80 symbol_table::symbol_record *sym_rec (void); |
142
|
81 |
9476
|
82 symbol_table::symbol_record *method_rec (void); |
|
83 symbol_table::symbol_record *class_rec (void); |
|
84 symbol_table::symbol_record *package_rec (void); |
|
85 |
|
86 symbol_table::symbol_record *meta_class_rec (void); |
|
87 symbol_table::symbol_record *meta_package_rec (void); |
|
88 |
3523
|
89 std::string text_rep (void); |
581
|
90 |
142
|
91 private: |
3552
|
92 |
|
93 // No copying! |
|
94 |
1288
|
95 token (const token& tok); |
3552
|
96 |
1288
|
97 token& operator = (const token& tok); |
|
98 |
142
|
99 int line_num; |
|
100 int column_num; |
|
101 token_type type_tag; |
|
102 union |
|
103 { |
3523
|
104 std::string *str; |
142
|
105 double num; |
|
106 end_tok_type et; |
7336
|
107 symbol_table::symbol_record *sr; |
9476
|
108 struct |
|
109 { |
|
110 symbol_table::symbol_record *mr; |
|
111 symbol_table::symbol_record *cr; |
|
112 symbol_table::symbol_record *pr; |
|
113 } sc; |
|
114 struct |
|
115 { |
|
116 symbol_table::symbol_record *cr; |
|
117 symbol_table::symbol_record *pr; |
|
118 } mc; |
142
|
119 }; |
3523
|
120 std::string orig_text; |
142
|
121 }; |
|
122 |
|
123 #endif |