changed lexer/parser to be able to read float constants, if they have "f"-suffix

This commit is contained in:
egaburov
2013-09-13 10:26:15 +02:00
parent a97eb7b7cb
commit a9913c8337
2 changed files with 28 additions and 6 deletions

View File

@@ -149,7 +149,8 @@ struct ForeachDimension {
%union {
uint64_t intVal;
double floatVal;
float floatVal;
double doubleVal;
std::string *stringVal;
const char *constCharPtr;
@@ -185,7 +186,7 @@ struct ForeachDimension {
%token TOKEN_INT64_CONSTANT TOKEN_UINT64_CONSTANT
%token TOKEN_INT32DOTDOTDOT_CONSTANT TOKEN_UINT32DOTDOTDOT_CONSTANT
%token TOKEN_INT64DOTDOTDOT_CONSTANT TOKEN_UINT64DOTDOTDOT_CONSTANT
%token TOKEN_FLOAT_CONSTANT TOKEN_STRING_C_LITERAL
%token TOKEN_FLOAT_CONSTANT TOKEN_DOUBLE_CONSTANT TOKEN_STRING_C_LITERAL
%token TOKEN_IDENTIFIER TOKEN_STRING_LITERAL TOKEN_TYPE_NAME TOKEN_NULL
%token TOKEN_PTR_OP TOKEN_INC_OP TOKEN_DEC_OP TOKEN_LEFT_OP TOKEN_RIGHT_OP
%token TOKEN_LE_OP TOKEN_GE_OP TOKEN_EQ_OP TOKEN_NE_OP
@@ -326,9 +327,13 @@ primary_expression
(uint64_t)yylval.intVal, @1);
}
| TOKEN_FLOAT_CONSTANT {
$$ = new ConstExpr(AtomicType::UniformDouble->GetAsConstType(),
$$ = new ConstExpr(AtomicType::UniformFloat->GetAsConstType(),
yylval.floatVal, @1);
}
| TOKEN_DOUBLE_CONSTANT {
$$ = new ConstExpr(AtomicType::UniformDouble->GetAsConstType(),
yylval.doubleVal, @1);
}
| TOKEN_TRUE {
$$ = new ConstExpr(AtomicType::UniformBool->GetAsConstType(), true, @1);
}