このページを編集する際は,編集に関する方針に従ってください.[]
概要[]
引数[]
- tree *value
- location_t *loc
- unsigned char *cpp_flags
実装[]
326 /* Read a token and return its type. Fill *VALUE with its value, if
327 applicable. Fill *CPP_FLAGS with the token's flags, if it is
328 non-NULL. */
329
330 enum cpp_ttype
331 c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags)
332 {
333 static bool no_more_pch;
334 const cpp_token *tok;
335 enum cpp_ttype type;
336
337 timevar_push (TV_CPP);
338 retry:
339 tok = cpp_get_token (parse_in);
340 type = tok->type;
341
342 retry_after_at:
343 #ifdef USE_MAPPED_LOCATION
344 *loc = tok->src_loc;
345 #else
346 *loc = input_location;
347 #endif
348 switch (type)
349 {
350 case CPP_PADDING:
351 goto retry;
352
353 case CPP_NAME:
354 *value = HT_IDENT_TO_GCC_IDENT (HT_NODE (tok->val.node));
355 break;
356
357 case CPP_NUMBER:
358 {
359 unsigned int flags = cpp_classify_number (parse_in, tok);
360
361 switch (flags & CPP_N_CATEGORY)
362 {
363 case CPP_N_INVALID:
364 /* cpplib has issued an error. */
365 *value = error_mark_node;
366 break;
367
368 case CPP_N_INTEGER:
369 *value = interpret_integer (tok, flags);
370 break;
371
372 case CPP_N_FLOATING:
373 *value = interpret_float (tok, flags);
374 break;
375
376 default:
377 gcc_unreachable ();
378 }
379 }
380 break;
381
382 case CPP_ATSIGN:
383 /* An @ may give the next token special significance in Objective-C. */
384 if (c_dialect_objc ())
385 {
386 location_t atloc = input_location;
387
388 retry_at:
389 tok = cpp_get_token (parse_in);
390 type = tok->type;
391 switch (type)
392 {
393 case CPP_PADDING:
394 goto retry_at;
395
396 case CPP_STRING:
397 case CPP_WSTRING:
398 type = lex_string (tok, value, true);
399 break;
400
401 case CPP_NAME:
402 *value = HT_IDENT_TO_GCC_IDENT (HT_NODE (tok->val.node));
403 if (objc_is_reserved_word (*value))
404 {
405 type = CPP_AT_NAME;
406 break;
407 }
408 /* FALLTHROUGH */
409
410 default:
411 /* ... or not. */
412 error ("%Hstray %<@%> in program", &atloc);
413 goto retry_after_at;
414 }
415 break;
416 }
417
418 /* FALLTHROUGH */
419 case CPP_HASH:
420 case CPP_PASTE:
421 {
422 unsigned char name[4];
423
424 *cpp_spell_token (parse_in, tok, name, true) = 0;
425
426 error ("stray %qs in program", name);
427 }
428
429 goto retry;
430
431 case CPP_OTHER:
432 {
433 cppchar_t c = tok->val.str.text[0];
434
435 if (c == '"' || c == '\)
436 error ("missing terminating %c character", (int) c);
437 else if (ISGRAPH (c))
438 error ("stray %qc in program", (int) c);
439 else
440 error ("stray %<\\%o%> in program", (int) c);
441 }
442 goto retry;
443
444 case CPP_CHAR:
445 case CPP_WCHAR:
446 *value = lex_charconst (tok);
447 break;
448
449 case CPP_STRING:
450 case CPP_WSTRING:
451 if (!c_lex_return_raw_strings)
452 {
453 type = lex_string (tok, value, false);
454 break;
455 }
456
457 /* FALLTHROUGH */
458
459 case CPP_PRAGMA:
460 *value = build_string (tok->val.str.len, (char *) tok->val.str.text);
461 break;
462
463 /* These tokens should not be visible outside cpplib. */
464 case CPP_HEADER_NAME:
465 case CPP_COMMENT:
466 case CPP_MACRO_ARG:
467 gcc_unreachable ();
468
469 default:
470 *value = NULL_TREE;
471 break;
472 }
473
474 if (cpp_flags)
475 *cpp_flags = tok->flags;
476
477 if (!no_more_pch)
478 {
479 no_more_pch = true;
480 c_common_no_more_pch ();
481 }
482
483 timevar_pop (TV_CPP);
484
485 return type;
486 }