OLD | NEW |
---|---|
1 # Copyright 2011 the V8 project authors. All rights reserved. | 1 # Copyright 2011 the V8 project authors. All rights reserved. |
2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
4 # met: | 4 # met: |
5 # | 5 # |
6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 """) | 131 """) |
132 | 132 |
133 read_var = StrictTemplate("read-reserved-$id", """ | 133 read_var = StrictTemplate("read-reserved-$id", """ |
134 var x = $id; | 134 var x = $id; |
135 """) | 135 """) |
136 | 136 |
137 setter_arg = StrictTemplate("setter-param-$id", """ | 137 setter_arg = StrictTemplate("setter-param-$id", """ |
138 var x = {set foo($id) { }}; | 138 var x = {set foo($id) { }}; |
139 """) | 139 """) |
140 | 140 |
141 label_normal = Template("label-normal-$id", """ | |
142 $id: ''; | |
143 """) | |
144 | |
145 label_strict = StrictTemplate("label-strict-$id", """ | |
146 $id: ''; | |
147 """) | |
148 | |
149 break_normal = Template("break-normal-$id", """ | |
150 break $id; | |
151 """) | |
152 | |
153 break_strict = StrictTemplate("break-strict-$id", """ | |
154 break $id; | |
155 """) | |
156 | |
157 continue_normal = Template("continue-normal-$id", """ | |
158 continue $id; | |
159 """) | |
160 | |
161 continue_strict = StrictTemplate("continue-strict-$id", """ | |
162 continue $id; | |
Lasse Reichstein
2011/09/22 12:50:19
IIRC, you can't have break and continue outside of
Steven
2011/09/22 16:48:32
Done.
| |
163 """) | |
164 | |
141 non_strict_use = Template("nonstrict-$id", """ | 165 non_strict_use = Template("nonstrict-$id", """ |
142 var $id = 42; | 166 var $id = 42; |
143 $id++; | 167 $id++; |
144 $id--; | 168 $id--; |
145 ++$id; | 169 ++$id; |
146 --$id; | 170 --$id; |
147 $id += 10; | 171 $id += 10; |
148 $id -= 10; | 172 $id -= 10; |
149 try {} catch ($id) { } | 173 try {} catch ($id) { } |
150 function $id($id) { } | 174 function $id($id) { } |
151 var x = {$id: 42}; | 175 var x = {$id: 42}; |
152 x = {get $id() {}, set $id(value) {}}; | 176 x = {get $id() {}, set $id(value) {}}; |
153 function foo() { "use strict;" } | 177 function foo() { "use strict;" } |
154 var $id = 42; | 178 var $id = 42; |
155 $id++; | 179 $id++; |
156 $id--; | 180 $id--; |
157 ++$id; | 181 ++$id; |
158 --$id; | 182 --$id; |
159 $id += 10; | 183 $id += 10; |
160 $id -= 10; | 184 $id -= 10; |
161 try {} catch ($id) { } | 185 try {} catch ($id) { } |
162 function $id($id) { } | 186 function $id($id) { } |
163 x = {$id: 42}; | 187 x = {$id: 42}; |
164 x = {get $id() {}, set $id(value) {}}; | 188 x = {get $id() {}, set $id(value) {}}; |
189 $id: ''; | |
165 """) | 190 """) |
166 | 191 |
167 identifier_name_source = """ | 192 identifier_name_source = """ |
168 var x = {$id: 42}; | 193 var x = {$id: 42}; |
169 x = {get $id() {}, set $id(value) {}}; | 194 x = {get $id() {}, set $id(value) {}}; |
170 x.$id = 42; | 195 x.$id = 42; |
171 function foo() { "use strict;" } | 196 function foo() { "use strict;" } |
172 x = {$id: 42}; | 197 x = {$id: 42}; |
173 x = {get $id() {}, set $id(value) {}}; | 198 x = {get $id() {}, set $id(value) {}}; |
174 x.$id = 42; | 199 x.$id = 42; |
(...skipping 15 matching lines...) Expand all Loading... | |
190 setter_arg({"id": id}, "strict_param_name") | 215 setter_arg({"id": id}, "strict_param_name") |
191 for op in assign_ops.keys(): | 216 for op in assign_ops.keys(): |
192 assign_var({"id": id, "op":op, "opname": assign_ops[op]}, | 217 assign_var({"id": id, "op":op, "opname": assign_ops[op]}, |
193 "strict_lhs_assignment") | 218 "strict_lhs_assignment") |
194 catch_var({"id": id}, "strict_catch_variable") | 219 catch_var({"id": id}, "strict_catch_variable") |
195 declare_var({"id": id}, "strict_var_name") | 220 declare_var({"id": id}, "strict_var_name") |
196 prefix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_prefix") | 221 prefix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_prefix") |
197 prefix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_prefix") | 222 prefix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_prefix") |
198 postfix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_postfix") | 223 postfix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_postfix") |
199 postfix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_postfix") | 224 postfix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_postfix") |
225 label_normal({"id": id}, None) | |
226 label_strict({"id": id}, None) | |
227 break_normal({"id": id}, None) | |
228 break_strict({"id": id}, None) | |
229 continue_normal({"id": id}, None) | |
230 continue_strict({"id": id}, None) | |
200 non_strict_use({"id": id}, None) | 231 non_strict_use({"id": id}, None) |
201 | 232 |
202 | 233 |
203 # Reserved words just throw the same exception in all cases | 234 # Reserved words just throw the same exception in all cases |
204 # (with "const" being special, as usual). | 235 # (with "const" being special, as usual). |
205 for reserved_word in reserved_words + strict_reserved_words: | 236 for reserved_word in reserved_words + strict_reserved_words: |
206 if (reserved_word in strict_reserved_words): | 237 if (reserved_word in strict_reserved_words): |
207 message = "strict_reserved_word" | 238 message = "strict_reserved_word" |
Lasse Reichstein
2011/09/22 12:50:19
Make a label_message = message here and in case th
Steven
2011/09/22 16:48:32
Done.
| |
239 label_normal({"id": reserved_word}, None) | |
240 break_normal({"id": reserved_word}, None) | |
241 continue_normal({"id": reserved_word}, None) | |
242 label_strict({"id": reserved_word}, message) | |
243 break_strict({"id": reserved_word}, message) | |
244 continue_strict({"id": reserved_word}, message) | |
208 elif (reserved_word == "const"): | 245 elif (reserved_word == "const"): |
209 message = "unexpected_token" | 246 message = "unexpected_token" |
247 label_normal({"id": reserved_word}, message) | |
248 break_normal({"id": reserved_word}, message) | |
249 continue_normal({"id": reserved_word}, message) | |
250 # The error message for this case is different because | |
251 # ParseLabelledStatementOrExpression will try to parse this as an expression | |
252 # first, effectively disallowing the use in ParseVariableDeclarations, i.e. | |
253 # the preparser never sees that 'const' was intended to be a label. | |
254 label_strict({"id": reserved_word}, "strict_const") | |
255 break_strict({"id": reserved_word}, message) | |
256 continue_strict({"id": reserved_word}, message) | |
210 else: | 257 else: |
211 message = "reserved_word" | 258 message = "reserved_word" |
259 label_normal({"id": reserved_word}, message) | |
260 break_normal({"id": reserved_word}, message) | |
261 continue_normal({"id": reserved_word}, message) | |
262 label_strict({"id": reserved_word}, message) | |
263 break_strict({"id": reserved_word}, message) | |
264 continue_strict({"id": reserved_word}, message) | |
212 arg_name_own({"id":reserved_word}, message) | 265 arg_name_own({"id":reserved_word}, message) |
213 arg_name_nested({"id":reserved_word}, message) | 266 arg_name_nested({"id":reserved_word}, message) |
214 setter_arg({"id": reserved_word}, message) | 267 setter_arg({"id": reserved_word}, message) |
215 func_name_own({"id":reserved_word}, message) | 268 func_name_own({"id":reserved_word}, message) |
216 func_name_nested({"id":reserved_word}, message) | 269 func_name_nested({"id":reserved_word}, message) |
217 for op in assign_ops.keys(): | 270 for op in assign_ops.keys(): |
218 assign_var({"id":reserved_word, "op":op, "opname": assign_ops[op]}, message) | 271 assign_var({"id":reserved_word, "op":op, "opname": assign_ops[op]}, message) |
219 catch_var({"id":reserved_word}, message) | 272 catch_var({"id":reserved_word}, message) |
220 declare_var({"id":reserved_word}, message) | 273 declare_var({"id":reserved_word}, message) |
221 prefix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) | 274 prefix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) |
222 prefix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) | 275 prefix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) |
223 postfix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) | 276 postfix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) |
224 postfix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) | 277 postfix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) |
225 read_var({"id": reserved_word}, message) | 278 read_var({"id": reserved_word}, message) |
226 identifier_name({"id": reserved_word}, None); | 279 identifier_name({"id": reserved_word}, None); |
227 identifier_name_strict({"id": reserved_word}, None); | 280 identifier_name_strict({"id": reserved_word}, None); |
228 | 281 |
229 | 282 |
230 # Future reserved words in strict mode behave like normal identifiers | 283 # Future reserved words in strict mode behave like normal identifiers |
231 # in a non strict context. | 284 # in a non strict context. |
232 for reserved_word in strict_reserved_words: | 285 for reserved_word in strict_reserved_words: |
233 non_strict_use({"id": id}, None) | 286 non_strict_use({"id": id}, None) |
OLD | NEW |