このページを編集する際は,編集に関する方針に従ってください.[]
概要[]
引数[]
- c_token *token
実装[]
289 /* Read in and lex a single token, storing it in *TOKEN. */
290
291 static void
292 c_lex_one_token (c_token *token)
293 {
294 timevar_push (TV_LEX);
295 token->type = c_lex_with_flags (&token->value, &token->location, NULL);
296 token->in_system_header = in_system_header;
297 switch (token->type)
298 {
299 case CPP_NAME:
300 token->id_kind = C_ID_NONE;
301 token->keyword = RID_MAX;
302 {
303 tree decl;
304
305 int objc_force_identifier = objc_need_raw_identifier;
306 OBJC_NEED_RAW_IDENTIFIER (0);
307
308 if (C_IS_RESERVED_WORD (token->value))
309 {
310 enum rid rid_code = C_RID_CODE (token->value);
311
312 if (c_dialect_objc ())
313 {
314 if (!OBJC_IS_AT_KEYWORD (rid_code)
315 && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context))
316 {
317 /* Return the canonical spelling for this keyword. */
318 token->value = ridpointers[(int) rid_code];
319 token->type = CPP_KEYWORD;
320 token->keyword = rid_code;
321 break;
322 }
323 }
324 else
325 {
326 /* Return the canonical spelling for this keyword. */
327 token->value = ridpointers[(int) rid_code];
328 token->type = CPP_KEYWORD;
329 token->keyword = rid_code;
330 break;
331 }
332 }
333
334 decl = lookup_name (token->value);
335 if (decl)
336 {
337 if (TREE_CODE (decl) == TYPE_DECL)
338 {
339 token->id_kind = C_ID_TYPENAME;
340 break;
341 }
342 }
343 else if (c_dialect_objc ())
344 {
345 tree objc_interface_decl = objc_is_class_name (token->value);
346 /* Objective-C class names are in the same namespace as
347 variables and typedefs, and hence are shadowed by local
348 declarations. */
349 if (objc_interface_decl
350 && (global_bindings_p ()
351 || (!objc_force_identifier && !decl)))
352 {
353 token->value = objc_interface_decl;
354 token->id_kind = C_ID_CLASSNAME;
355 break;
356 }
357 }
358 }
359 token->id_kind = C_ID_ID;
360 break;
361 case CPP_AT_NAME:
362 /* This only happens in Objective-C; it must be a keyword. */
363 token->type = CPP_KEYWORD;
364 token->id_kind = C_ID_NONE;
365 token->keyword = C_RID_CODE (token->value);
366 break;
367 case CPP_COLON:
368 case CPP_COMMA:
369 case CPP_CLOSE_PAREN:
370 case CPP_SEMICOLON:
371 /* These tokens may affect the interpretation of any identifiers
372 following, if doing Objective-C. */
373 OBJC_NEED_RAW_IDENTIFIER (0);
374 token->id_kind = C_ID_NONE;
375 token->keyword = RID_MAX;
376 break;
377 default:
378 token->id_kind = C_ID_NONE;
379 token->keyword = RID_MAX;
380 break;
381 }
382 timevar_pop (TV_LEX);
383 }