Exemple #1
0
/*
 * ==============
 * PR_Lex
 * 
 * Sets pr_token, pr_token_type, and possibly pr_immediate and pr_immediate_type
 * ==============
 */
void 
PR_Lex(void)
{
    int c;

    pr_token[0] = 0;

    if (!pr_file_p) {
	pr_token_type = tt_eof;
	return;
    }
    PR_LexWhitespace();

    c = *pr_file_p;

    if (!c) {
	pr_token_type = tt_eof;
	return;
    }
/* handle quoted strings as a unit */
    if (c == '\"') {
	PR_LexString();
	return;
    }
/* handle quoted vectors as a unit */
    if (c == '\'') {
	PR_LexVector();
	return;
    }
/* if the first character is a valid identifier, parse until a non-id */
/* character is reached */
    if ((c >= '0' && c <= '9') || (c == '-' && pr_file_p[1] >= '0' && pr_file_p[1] <= '9')) {
	pr_token_type = tt_immediate;
	pr_immediate_type = &type_float;
	pr_immediate._float = PR_LexNumber();
	return;
    }
    if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_') {
	PR_LexName();
	return;
    }
    if (c == '$') {
	PR_LexGrab();
	return;
    }
/* parse symbol strings until a non-symbol is found */
    PR_LexPunctuation();
}
Exemple #2
0
/*
==============
PR_Lex

Sets pr_token, pr_token_type, and possibly pr_immediate and pr_immediate_type
==============
*/
void PR_Lex (void)
{
	int		c;

	pr_token[0] = 0;

	if (!pr_file_p)
	{
		pr_token_type = tt_eof;
		return;
	}

	PR_LexWhitespace ();

	c = *pr_file_p;
	if (!c)
	{
		pr_token_type = tt_eof;
		return;
	}

// handle quoted strings as a unit
	if (c == (int)'\"')
	{
		PR_LexString ();
		return;
	}

// handle quoted vectors as a unit
	if (c == (int)'\'')
	{
		PR_LexVector ();
		return;
	}

// if the first character is a valid identifier, parse until a non-id
// character is reached
	if ( isdigit(c) ||
		( c == (int)'.' && isdigit((int)(unsigned char)pr_file_p[1]) ) ||
		( c == (int)'-' && (isdigit((int)(unsigned char)pr_file_p[1]) || pr_file_p[1] == '.') )
		)
	{
		pr_token_type = tt_immediate;
		pr_immediate_type = &type_const_float;
		pr_immediate._float = PR_LexNumber ();
		return;
	}

	if ( isalpha(c) || c == (int)'_' )
	{
		PR_LexName ();
		return;
	}

	if (c == (int)'$')
	{
		PR_LexGrab ();
		return;
	}

   if (c == (int)'#')
   {
      if ( isalpha((int)(unsigned char)pr_file_p[1]) || pr_file_p[1] == '_' )
      {
         PR_LexPrecomp();
         return;
      }
   }

// parse symbol strings until a non-symbol is found
	PR_LexPunctuation ();
}