fix issue in parser

main
Brett 2025-03-04 11:05:59 -05:00
parent 25187319ab
commit a2a60b18b5
3 changed files with 10 additions and 3 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake)
set(BLT_VERSION 5.1.4)
set(BLT_VERSION 5.1.5)
set(BLT_TARGET BLT)

View File

@ -186,10 +186,11 @@ namespace blt::logging
auto [type, value] = peek();
switch (type)
{
case fmt_token_type::STRING:
return;
case fmt_token_type::SPACE:
case fmt_token_type::MINUS:
case fmt_token_type::PLUS:
case fmt_token_type::STRING:
case fmt_token_type::COLON:
{
std::stringstream ss;
@ -217,6 +218,7 @@ namespace blt::logging
switch (type)
{
case fmt_token_type::STRING:
return;
case fmt_token_type::SPACE:
case fmt_token_type::COLON:
case fmt_token_type::MINUS:
@ -246,6 +248,7 @@ namespace blt::logging
switch (type)
{
case fmt_token_type::STRING:
return;
case fmt_token_type::COLON:
case fmt_token_type::MINUS:
case fmt_token_type::PLUS:
@ -317,7 +320,9 @@ namespace blt::logging
{
if (!has_next())
throw std::runtime_error("Missing token when parsing precision");
auto [_, value] = next();
auto [type, value] = next();
if (type != fmt_token_type::NUMBER)
throw std::runtime_error("Expected number when parsing precision");
m_spec.precision = std::stoll(std::string(value));
}

View File

@ -38,5 +38,7 @@ int main()
blt::logging::println("This is a println with a precision {:.10f}", 42.232342349);
blt::logging::println("This is a println with hex {:.10x}", 4250);
blt::logging::println("This is a println with hex with leading {:#.10x}", 4250);
blt::logging::println("This is a println with binary {:#b}", 6969420);
blt::logging::println("This is a println with binary with space {: #b}", 6969421);
// blt::logging::println("This is println {}\twith a std::endl in the middle of it");
}