mirror of
https://github.com/bkaradzic/bx.git
synced 2026-10-26 10:35:39 +00:00
Added HLSL double literal suffix (l/L). (#475)
This commit is contained in:
@@ -15,7 +15,7 @@ namespace bx
|
||||
static constexpr StringView kGlslInt[] = { "u", "U", "lu", "LU" };
|
||||
static constexpr StringView kGlslFloat[] = { "f", "F", "lf", "LF" };
|
||||
static constexpr StringView kHlslInt[] = { "u", "U", "l", "L", "ll", "LL", "ul", "lu", "uL", "Lu", "UL", "ull", "llu", "ULL", "LLU" };
|
||||
static constexpr StringView kHlslFloat[] = { "f", "F", "h", "H" };
|
||||
static constexpr StringView kHlslFloat[] = { "f", "F", "h", "H", "l", "L" };
|
||||
static constexpr StringView kCInt[] = { "u", "U", "l", "L", "ll", "LL", "ul", "lu", "uL", "Lu", "ull", "llu", "ULL", "LLU" };
|
||||
static constexpr StringView kCFloat[] = { "f", "F", "l", "L" };
|
||||
static constexpr StringView kMslFloat[] = { "f", "F", "h", "H" };
|
||||
@@ -139,14 +139,17 @@ namespace bx
|
||||
return parseDecimalFloat(_scanner, _profile);
|
||||
}
|
||||
|
||||
if (acceptSuffix(_scanner, _profile.intSuffix) )
|
||||
{
|
||||
return LiteralType::Decimal;
|
||||
}
|
||||
|
||||
if (0 != (_profile.flags & LiteralParser::PromoteFloatSuffix)
|
||||
&& acceptSuffix(_scanner, _profile.floatSuffix) )
|
||||
{
|
||||
return LiteralType::Float;
|
||||
}
|
||||
|
||||
acceptSuffix(_scanner, _profile.intSuffix);
|
||||
|
||||
return LiteralType::Decimal;
|
||||
}
|
||||
|
||||
|
||||
@@ -238,3 +238,25 @@ TEST_CASE("LiteralParser WGSL profile", "[parser]")
|
||||
REQUIRE(testWgsl("0b1", "0", LP::Decimal) ); // "0" then "b1"
|
||||
REQUIRE(testWgsl("5_5", "5", LP::Decimal) ); // "5" then "_5"
|
||||
}
|
||||
|
||||
static bool testHlsl(const bx::StringView& _input, const bx::StringView& _output, bx::LiteralParser::Type _type)
|
||||
{
|
||||
bx::LiteralParser p(_input, bx::LiteralParser::hlsl() );
|
||||
|
||||
return p.isOk()
|
||||
&& _type == p.getType()
|
||||
&& bx::isEqual(p.getLiteral(), _output)
|
||||
;
|
||||
}
|
||||
|
||||
TEST_CASE("LiteralParser HLSL profile", "[parser]")
|
||||
{
|
||||
typedef bx::LiteralParser LP;
|
||||
|
||||
REQUIRE(testHlsl("1.5f", "1.5f", LP::Float) );
|
||||
REQUIRE(testHlsl("1.5h", "1.5h", LP::Float) );
|
||||
REQUIRE(testHlsl("1.5L", "1.5L", LP::Float) ); // double
|
||||
REQUIRE(testHlsl("1.5l;", "1.5l", LP::Float) );
|
||||
REQUIRE(testHlsl("5L", "5L", LP::Decimal) ); // int64_t
|
||||
REQUIRE(testHlsl("5UL", "5UL", LP::Decimal) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user