Beispiel #1
0
/*
 *	create a symbol table entry unless one already exists 
 */
void	create_symbol( int type, unsigned char value, char *buffer, int length)
{
	CLIPS	*clips;
/*
 *	first search for same identifier string
 */
	clips = find_symbol( data.level, buffer, length);
/*
 *	update symbol type entry or make new symbol table entry
 */
	if( clips)
	{
		if( 0 < type)
			clips->token = type;
		if( 0 < value)
			clips->value = value;
		return;
	}
	clips = al_clips( type, value, get_address(), 0, buffer, length);
	clips->level = data.level;
/*
 *	attach it to the head of the symbol table list (LIFO)
 */
	clips->next = data.symbol_table;
	data.symbol_table = clips;
	return;
}
Beispiel #2
0
/*
 *	encode a constant floating point value
 */
CLIPS	*constant_float( char *text, int length)
{
	CLIPS	*clips;
	float	f = 0;
	sscanf( text, "%f", &f);
	clips = al_clips( LITERAL, 0, 0, 0, 0);
	//ansi_c_audit_float( clips->value, f, text, length);
	return( clips);
}
Beispiel #3
0
/*
 *	encode an identifier
 */
CLIPS	*identifier( char *text, int length)
{
	CLIPS	*clips;
/*
 *	but add one for nul
 */
	clips = al_clips( IDENTIFIER, 0, 0, text, length + 1);
	return( clips);
}
Beispiel #4
0
/*
 *	encode a constant octal value
 */
CLIPS	*constant_octal( char *text, int length)
{
	CLIPS	*clips;
	int	o = 0;
	sscanf( text, "%o", &o);
	clips = al_clips( LITERAL, 0, 0, 0, 0);
	//ansi_c_audit_octal( clips->value, o, text, length);
	return( clips);
}
Beispiel #5
0
/*
 *	encode a string literal
 */
CLIPS	*string_literal( char *text, int length)
{
	CLIPS	*clips;
/*
 *	do not need the beginning " and also remove the ending " but add one for nul (-2 + 1 = -1)
 */
	//text[ length - 1] = 0;
	clips = al_clips( LITERAL, 0, 0, text, length + 1);
	return( clips);
}
Beispiel #6
0
/*
 *	encode a constant decimal value
 */
CLIPS	*constant_decimal( char *text, int length)
{
	CLIPS	*clips;
	int	u = 0;
	sscanf( text, "%u", &u);
	clips = al_clips( LITERAL, 0, 0, 0, 0);
	//ansi_c_audit_decimal( clips->lValue, u, text, length);

	return( clips);
}
Beispiel #7
0
/*
 *	encode a constant hex value
 */
CLIPS	*constant_hex( char *text, int length)
{	
	CLIPS	*clips;

	int	x = 0;
	sscanf( text, "%x", &x);
	clips = al_clips( LITERAL, 0, 0, 0, 0);
	//ansi_c_audit_hex( clips->value, x, text, length);
	return( clips);
}
Beispiel #8
0
/*
 *	encode a constant character value
 */
CLIPS	*constant_char( char *text, int length)
{
	CLIPS	*clips;
	unsigned int c = 0;
	switch( text[ 1])
	{
	case '\\':
		switch( text[ 2])
		{
		case 'n':	/* newline */
			c = 0x0a;
			break;
		case 'r':	/* cr */
			c = 0x0d;
			break;
		case 't':	/* tab */
			c = 0x09;
			break;
		case 'b':	/* backspace */
			c = 0x08;
			break;
		case '\\':	
			c = 0x5c;
			break;
		case '?':
			c = 0x3f;
			break;
		case '\'':
			c = 0x27;
			break;
		case '"':
			c = 0x22;
			break;
		case 'x':
		case 'X':
			text[1] = '0';
			sscanf( &text[1], "%x", &c);
			break;
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
			sscanf( &text[2], "%o", &c);
			break;
		default:
			{
				int i;
				for( i = 2; i < length; i++)
				{
					if( text[ i] == '\'')
						break;
					c = text[ i];
				}
			}
			break;
		}
		break;
	default:
		c = text[1];
		break;
	}
	clips = al_clips( LITERAL, (unsigned char)c,0, 0, 0);
	//ansi_c_audit_char( clips->value, c, text, length);
	return( clips);
}