Mercurial > hg > octave-lyh
annotate libinterp/parse-tree/token.cc @ 16104:c8974e28da59
move nesting_level to lexical_feedback class
* lex.h, lex.ll (brace_bracket_paren_nesting_level): Rename to
bbp_nesting_level and nest class definition inside lexical_feedback
class.
(nesting_level): Move global variable to lexical_feedback_class.
Change all uses.
(reset_parser): Don't clear nesting_level.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Feb 2013 21:54:15 -0500 |
parents | 2fc554ffbc28 |
children | 947cf10c94da 12bf6a3f8c45 |
rev | line source |
---|---|
142 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3 Copyright (C) 1993-2012 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 | |
240 | 23 #ifdef HAVE_CONFIG_H |
1192 | 24 #include <config.h> |
142 | 25 #endif |
26 | |
1343 | 27 #include <cassert> |
142 | 28 |
1288 | 29 #include "error.h" |
4055 | 30 #include "oct-obj.h" |
1352 | 31 #include "symtab.h" |
142 | 32 #include "token.h" |
33 #include "utils.h" | |
34 | |
529 | 35 token::token (int l, int c) |
142 | 36 { |
37 line_num = l; | |
38 column_num = c; | |
39 type_tag = generic_token; | |
40 } | |
41 | |
3523 | 42 token::token (const std::string& s, int l, int c) |
142 | 43 { |
44 line_num = l; | |
45 column_num = c; | |
46 type_tag = string_token; | |
3523 | 47 str = new std::string (s); |
142 | 48 } |
49 | |
3523 | 50 token::token (double d, const std::string& s, int l, int c) |
142 | 51 { |
52 line_num = l; | |
53 column_num = c; | |
54 type_tag = double_token; | |
55 num = d; | |
1971 | 56 orig_text = s; |
142 | 57 } |
58 | |
529 | 59 token::token (end_tok_type t, int l, int c) |
142 | 60 { |
61 line_num = l; | |
62 column_num = c; | |
63 type_tag = ettype_token; | |
64 et = t; | |
65 } | |
66 | |
7336 | 67 token::token (symbol_table::symbol_record *s, int l, int c) |
142 | 68 { |
69 line_num = l; | |
70 column_num = c; | |
71 type_tag = sym_rec_token; | |
72 sr = s; | |
73 } | |
74 | |
9476 | 75 token::token (symbol_table::symbol_record *cls, |
76 symbol_table::symbol_record *pkg, int l, int c) | |
77 { | |
78 line_num = l; | |
79 column_num = c; | |
80 type_tag = meta_rec_token; | |
81 mc.cr = cls; | |
82 mc.pr = pkg; | |
83 } | |
84 | |
85 token::token (symbol_table::symbol_record *mth, | |
86 symbol_table::symbol_record *cls, | |
87 symbol_table::symbol_record *pkg, int l, int c) | |
88 { | |
89 line_num = l; | |
90 column_num = c; | |
91 type_tag = scls_rec_token; | |
92 sc.mr = mth; | |
93 sc.cr = cls; | |
94 sc.pr = pkg; | |
95 } | |
96 | |
142 | 97 token::~token (void) |
98 { | |
99 if (type_tag == string_token) | |
1755 | 100 delete str; |
142 | 101 } |
102 | |
3536 | 103 std::string |
1755 | 104 token::text (void) |
142 | 105 { |
106 assert (type_tag == string_token); | |
1755 | 107 return *str; |
142 | 108 } |
109 | |
110 double | |
111 token::number (void) | |
112 { | |
113 assert (type_tag == double_token); | |
114 return num; | |
115 } | |
116 | |
117 token::end_tok_type | |
118 token::ettype (void) | |
119 { | |
120 assert (type_tag == ettype_token); | |
121 return et; | |
122 } | |
123 | |
7336 | 124 symbol_table::symbol_record * |
142 | 125 token::sym_rec (void) |
126 { | |
127 assert (type_tag == sym_rec_token); | |
128 return sr; | |
129 } | |
130 | |
9476 | 131 symbol_table::symbol_record * |
132 token::method_rec (void) | |
133 { | |
134 assert (type_tag == scls_rec_token); | |
135 return sc.mr; | |
136 } | |
137 | |
138 symbol_table::symbol_record * | |
139 token::class_rec (void) | |
140 { | |
141 assert (type_tag == scls_rec_token); | |
142 return sc.cr; | |
143 } | |
144 | |
145 symbol_table::symbol_record * | |
146 token::package_rec (void) | |
147 { | |
148 assert (type_tag == scls_rec_token); | |
149 return sc.pr; | |
150 } | |
151 | |
152 symbol_table::symbol_record * | |
153 token::meta_class_rec (void) | |
154 { | |
155 assert (type_tag == meta_rec_token); | |
156 return mc.cr; | |
157 } | |
158 | |
159 symbol_table::symbol_record * | |
160 token::meta_package_rec (void) | |
161 { | |
162 assert (type_tag == meta_rec_token); | |
163 return mc.pr; | |
164 } | |
165 | |
3536 | 166 std::string |
581 | 167 token::text_rep (void) |
168 { | |
169 return orig_text; | |
170 } |