示例#1
0
文件: pr_lex.c 项目: base698/ProQCC
/*
 * ==============
 * 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();
}
示例#2
0
/*
==============
PR_LexVector

Parses a single quoted vector
==============
*/
void PR_LexVector (void)
{
	int		i;
	
	pr_file_p++;
	pr_token_type = tt_immediate;
	pr_immediate_type = &type_vector;
	for (i=0 ; i<3 ; i++)
	{
		pr_immediate.vector[i] = PR_LexNumber ();
		PR_LexWhitespace ();
	}
	if (*pr_file_p != '\'')
		PR_ParseError ("Bad vector");
	pr_file_p++;
}
示例#3
0
文件: pr_lex.cpp 项目: luaman/zq
/*
==============
PR_LexVector

Parses a single quoted vector
==============
*/
void PR_LexVector (void)
{
	int		i;

	pr_file_p++;
	pr_token_type = tt_immediate;
	pr_immediate_type = &type_const_vector;

	// FIXME, we'd better not allow any whitespace but space chars and tabs inside vector immediates...
	PR_LexWhitespace ();
	for (i=0 ; i<3 ; i++)
	{
		pr_immediate.vector[i] = PR_LexNumber ();
		PR_LexWhitespace ();
	}
	if (*pr_file_p != '\'')
		PR_ParseError ("bad vector");
	pr_file_p++;
}
示例#4
0
文件: pr_lex.cpp 项目: luaman/zq
/*
==============
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 ();
}