From 69447f879fa331dfc9b41009f2f39be65f0b9b1a Mon Sep 17 00:00:00 2001 From: Samaresh Kumar Singh Date: Mon, 17 Nov 2025 15:25:56 -0600 Subject: [PATCH 1/2] Update grammar README to reflect actual parser behavior The documentation stated that non-terminal symbols must be 'dashed lowercase words' like 'move' or 'check-mate', but the actual parser supports much more flexibility. Rule names can include: - Uppercase letters (e.g., dataType, UPPER-CASE) - Numbers (e.g., rule123) - Both dashes and underscores This was discovered when c.gbnf used 'dataType' with an uppercase letter, which works correctly despite the documentation saying otherwise. Updated the docs to accurately describe the parser's capabilities rather than restrict them. Fixes #7720 Signed-off-by: Samaresh Kumar Singh --- grammars/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/README.md b/grammars/README.md index a63198b5aeb8e..adf089af643b6 100644 --- a/grammars/README.md +++ b/grammars/README.md @@ -36,7 +36,7 @@ castle ::= ... ## Non-Terminals and Terminals -Non-terminal symbols (rule names) stand for a pattern of terminals and other non-terminals. They are required to be a dashed lowercase word, like `move`, `castle`, or `check-mate`. +Non-terminal symbols (rule names) stand for a pattern of terminals and other non-terminals. Rule names can be composed of letters (both uppercase and lowercase), numbers, dashes, and underscores. For example: `move`, `castle`, `check-mate`, `dataType`, `UPPER-CASE`, or `rule_123` are all valid non-terminal names. Terminals are actual characters ([code points](https://en.wikipedia.org/wiki/Code_point)). They can be specified as a sequence like `"1"` or `"O-O"` or as ranges like `[1-9]` or `[NBKQR]`. From 103666598f35ac134bf0b2fe130cd8936e481323 Mon Sep 17 00:00:00 2001 From: Samaresh Kumar Singh Date: Mon, 17 Nov 2025 15:30:41 -0600 Subject: [PATCH 2/2] Fix locale-dependent float printing in GGUF metadata Previously, std::to_string was used to format float and double values, which respects the LC_NUMERIC locale setting. This caused inconsistent output where some tools would print '0,000000' (comma) while others printed '0.000000' (period), depending on the system locale. Now using std::ostringstream with std::locale::classic() to ensure float values are always formatted with a period as the decimal separator, regardless of the system locale settings. Signed-off-by: Samaresh Kumar Singh --- src/llama-impl.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/llama-impl.cpp b/src/llama-impl.cpp index 6ec709dd323a6..e5bd07604d643 100644 --- a/src/llama-impl.cpp +++ b/src/llama-impl.cpp @@ -122,8 +122,18 @@ static std::string gguf_data_to_str(enum gguf_type type, const void * data, int case GGUF_TYPE_INT32: return std::to_string(((const int32_t *)data)[i]); case GGUF_TYPE_UINT64: return std::to_string(((const uint64_t *)data)[i]); case GGUF_TYPE_INT64: return std::to_string(((const int64_t *)data)[i]); - case GGUF_TYPE_FLOAT32: return std::to_string(((const float *)data)[i]); - case GGUF_TYPE_FLOAT64: return std::to_string(((const double *)data)[i]); + case GGUF_TYPE_FLOAT32: { + std::ostringstream oss; + oss.imbue(std::locale::classic()); + oss << ((const float *)data)[i]; + return oss.str(); + } + case GGUF_TYPE_FLOAT64: { + std::ostringstream oss; + oss.imbue(std::locale::classic()); + oss << ((const double *)data)[i]; + return oss.str(); + } case GGUF_TYPE_BOOL: return ((const bool *)data)[i] ? "true" : "false"; default: return format("unknown type %d", type); }