Load scene render params

This commit is contained in:
josh committed 2026-11-02 22:28:18 -05:00
1 parent a3684b20b6
commit 0ba0ebfe71
4 files changed
+94 -8

No files matched your search

+32 -2
View File
@@ -1,5 +1,25 @@
tree;
tree_prefix P;
ptype double;
<<header
/* User terminate codes. */
#define PARSER_TERMINATE_NUMBER_RANGE 1u
>>
<<
#include <charconv>
/* Store the numeric value of the matched text in *out. Returns false if the
* value cannot be represented. */
static bool parse_number(uint8_t const * match_text, size_t match_length, double * out)
{
const char * first = (const char *)match_text;
const char * last = first + match_length;
std::from_chars_result r = std::from_chars(first, last, *out);
return (r.ec == std::errc()) && (r.ptr == last);
}
>>
drop /\s+/;
@@ -14,8 +34,18 @@ token rcurly /\}/;
token scene;
token width;
token uint /\d+/;
token number /-?\d+(\.\d+)?/;
token uint /\d+/ <<
if (!parse_number(match_text, match_length, &$$))
{
$terminate(PARSER_TERMINATE_NUMBER_RANGE);
}
>>
token number /-?\d+(\.\d+)?/ <<
if (!parse_number(match_text, match_length, &$$))
{
$terminate(PARSER_TERMINATE_NUMBER_RANGE);
}
>>
Start -> RenderParams Scene;