Exemple #1
0
static void
x_php_lex (token_ty *tp)
{
  phase4_get (tp);
  if (tp->type == token_type_string_literal
      && !(phase5_last == token_type_dot
	   || phase5_last == token_type_operator1
	   || phase5_last == token_type_operator2
	   || phase5_last == token_type_rparen))
    {
      char *sum = tp->string;
      size_t sum_len = strlen (sum);

      for (;;)
	{
	  token_ty token2;

	  phase4_get (&token2);
	  if (token2.type == token_type_dot)
	    {
	      token_ty token3;

	      phase4_get (&token3);
	      if (token3.type == token_type_string_literal)
		{
		  token_ty token_after;

		  phase4_get (&token_after);
		  if (token_after.type != token_type_operator1)
		    {
		      char *addend = token3.string;
		      size_t addend_len = strlen (addend);

		      sum = (char *) xrealloc (sum, sum_len + addend_len + 1);
		      memcpy (sum + sum_len, addend, addend_len + 1);
		      sum_len += addend_len;

		      phase4_unget (&token_after);
		      free_token (&token3);
		      free_token (&token2);
		      continue;
		    }
		  phase4_unget (&token_after);
		}
	      phase4_unget (&token3);
	    }
	  phase4_unget (&token2);
	  break;
	}
      tp->string = sum;
    }
  phase5_last = tp->type;
}
Exemple #2
0
static void
phase5_get (token_ty *tp)
{
  phase4_get (tp);

  /* Combine symbol1 . ... . symbolN to a single strings, so that
     we can recognize function calls like
     gettext.gettext.  The information present for
     symbolI.....symbolN has precedence over the information for
     symbolJ.....symbolN with J > I.  */
  if (tp->type == token_type_symbol)
    {
      char *sum = tp->string;
      size_t sum_len = strlen (sum);

      for (;;)
        {
          token_ty token2;

          phase4_get (&token2);
          if (token2.type == token_type_dot)
            {
              token_ty token3;

              phase4_get (&token3);
              if (token3.type == token_type_symbol)
                {
                  char *addend = token3.string;
                  size_t addend_len = strlen (addend);

                  sum = (char *) xrealloc (sum, sum_len + 1 + addend_len + 1);
                  sum[sum_len] = '.';
                  memcpy (sum + sum_len + 1, addend, addend_len + 1);
                  sum_len += 1 + addend_len;

                  free_token (&token2);
                  free_token (&token3);
                  continue;
                }
              phase4_unget (&token3);
            }
          phase4_unget (&token2);
          break;
        }
      tp->string = sum;
    }
}