예제 #1
0
파일: parser.cpp 프로젝트: STLVNUB/blitzmax
Val *Parser::parseLitVal(){
	Val *v;
	Type *ty;
	switch( curr() ){
	case T_INTCONST:
		v=new Val( toint(text()) );
		ty=Type::int32;
		break;
	case T_FLOATCONST:
		v=new Val( tofloat(text()) );
		ty=Type::float32;
		break;
	default:
		exp( "integer or floating point literal value" );
	}
	next();
	ty=parseLitType( ty );
	return v->cast( ty );
}
예제 #2
0
파일: parser.cpp 프로젝트: STLVNUB/blitzmax
CGExp *Parser::parseLitExp( Type *ty ){
	int sign=0;
	for(;;){
		if( cparse('+') ){
		}else if( cparse('-') ){
			sign=sign ? -sign : -1;
		}else{
			break;
		}
	}
	Val *v;
	switch( curr() ){
	case T_INTCONST:{
		int64 n=toint(text());
		if( sign<0 ) n=-n;
		v=new Val( n );
		next();
		break;
		}
	case T_FLOATCONST:{
		double n=tofloat(text());
		if( sign<0 ) n=-n;
		v=new Val( n );
		next();
		break;
		}
	case T_STRINGCONST:{
		if( sign ) exp( "Numeric or string literal value" );
		v=new Val( parseBString() );
		break;
		}
	default:
		exp( "Numeric or string literal value" );
	}
	ty=parseLitType( ty );
	v=v->cast( ty );
	return v->cg_exp;
}