Ejemplo n.º 1
0
static BOOL
FParseHex(LEX * plex,
          int ch)
{
  LEX lex;

  ch = tolower(ch);
  if ((ch == '0') && ((*(pchLex) == 'x') || (*(pchLex) == 'X')))
  {
    pchLex++;
    ch = *pchLex++;
  }
  if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f'))
  {
    lex.lt = ltConst;
    lex.val = 0;
    while ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f'))
    {
      lex.val *= 16;

      if ((ch >= '0' && ch <= '9'))
        lex.val += ch - '0';
      else
        lex.val += ch - 'a' + 10;
      ch = *pchLex++;
      ch = tolower(ch);
    }
    AllowLUAtEndOfConstant(ch);
    *plex = lex;
    return fTrue;
  }
  return fFalse;
}
Ejemplo n.º 2
0
static BOOL
FParseHex(LEX * plex,
          int ch)
{
	ch = tolower(ch);
	if ((ch == '0') && ((*(pchLex) == 'x') || (*(pchLex) == 'X')))
	{
		pchLex++;
		ch = *pchLex++;
	}
	if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f'))
	{
		plex->lt = ltConst;
		plex->val = 0;
		while ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f'))
		{
			plex->val *= 16;

			if ((ch >= '0' && ch <= '9'))
				plex->val += ch - '0';
			else
				plex->val += ch - 'a' + 10;
			ch = *pchLex++;
			ch = tolower(ch);
		}

		plex->size = lsUnspecified;
		if (ch == '.')
		{
			if (*pchLex == 'b' || *pchLex == 'B')
			{
				plex->size = lsByte;
				pchLex += 2;
			}
			else if (*pchLex == 'w' || *pchLex == 'W')
			{
				plex->size = lsWord;
				pchLex += 2;
			}
			else if (*pchLex == 'l' || *pchLex == 'L')
			{
				plex->size = lsLong;
				pchLex += 2;
			}
		}

		AllowLUAtEndOfConstant(ch);
		return fTrue;
	}
	return fFalse;
}
Ejemplo n.º 3
0
static BOOL
FParseConst(LEX * plex,
            int ch)
{
  char *pchStore;

  pchStore = plex->szId;
  Assert(wBaseCur == 10);
  if ((ch >= '0' && ch <= '9') || ch == '.')
  {
    plex->lt = ltConst;
    plex->val = 0;
    if ((ch == '0') && ((*(pchLex) == 'x') || (*(pchLex) == 'X')))
    {
      *pchStore++ = *pchLex++;
      *pchStore = (char)ch;
      ch = *pchLex++;
      return FParseHex(plex, ch);
    }

    while (ch >= '0' && ch <= '9')
    {
      plex->val *= 10;
      plex->val += ch - '0';
      *pchStore++ = (char)ch;
      ch = *pchLex++;
    }

    plex->size = lsUnspecified;
    if (ch == '.')
    {
      if (*pchLex == 'b' || *pchLex == 'B')
      {
       plex->size = lsByte;
       pchLex += 2;
      }
      else if (*pchLex == 'w' || *pchLex == 'W')
      {
       plex->size = lsWord;
       pchLex += 2;
      }
      else if (*pchLex == 'l' || *pchLex == 'L')
      {
       plex->size = lsLong;
       pchLex += 2;
      }
    }
  }
  else if (ch == '\'')
  {
    int cc;

    plex->lt = ltConst;
    plex->val = 0;
    *pchStore++ = (char)ch;
    for (cc = 0; cc < 4; ++cc)
    {
      ch = (BYTE) * pchLex++;
      *pchStore++ = (char)ch;

            /***    printf("char=[%c]\n", ch); ***/
      if (ch == '\'')
        break;

      if (ch < ' ')
        ErrorLine("Unknown character in '' constant: %c", ch);

      plex->val *= 256;
      plex->val += ch;                           /* high-byte first as a guess */
    }

        /***    Compensate for when we got a full 4 characters ***/
    if (ch != '\'')
      ch = (BYTE) * pchLex++;

    ++pchLex;                                    /* compensate for later -- by caller */
    if (ch != '\'')
      ErrorLine("Unknown '' constant terminator: %c", ch);
  }
  else
  {
    *pchStore = 0;
    return fFalse;
  }

    /***    Note: 'pchLex' is now one past the character that's in 'ch' - the next character to parse ***/
  AllowLUAtEndOfConstant(ch);

  *pchStore = 0;
  return fTrue;
}