Reintroduce options block to scene file grammar; remove scene block

This commit is contained in:
josh committed 2026-11-03 19:25:58 -05:00
1 parent 0ba0ebfe71
commit de2c51376a
2 files changed
+14 -13

No files matched your search

+7 -8
View File
@@ -31,7 +31,6 @@ token lcurly /\{/;
token lt /</;
token options;
token rcurly /\}/;
token scene;
token width;
token uint /\d+/ <<
@@ -47,7 +46,7 @@ token number /-?\d+(\.\d+)?/ <<
}
>>
Start -> RenderParams Scene;
Start -> Options? SceneItems;
Background -> background Vector;
@@ -56,14 +55,14 @@ Height -> height uint;
Number -> uint;
Number -> number;
RenderParams -> ;
RenderParams -> RenderParam RenderParams;
Options -> options lcurly OptionsItems rcurly;
RenderParam -> Background;
RenderParam -> Height;
RenderParam -> Width;
OptionsItems -> ;
OptionsItems -> OptionsItem OptionsItems;
Scene -> scene lcurly SceneItems rcurly;
OptionsItem -> Background;
OptionsItem -> Height;
OptionsItem -> Width;
SceneItems -> ;
+7 -5
View File
@@ -116,19 +116,21 @@ Scene * Parser::build_scene(const string_view & input_file, PStart start)
{
Scene * scene = new Scene();
for (PRenderParams rps = start.pRenderParams(); p_node_valid(rps); rps = rps.pRenderParams())
/* If the options block is absent, pOptions() returns a null node and so
* does pOptionsItems() on it, so the loop body is skipped. */
for (POptionsItems items = start.pOptions().pOptionsItems(); p_node_valid(items); items = items.pOptionsItems())
{
PRenderParam rp = rps.pRenderParam();
POptionsItem item = items.pOptionsItem();
bool ok = true;
if (PBackground background = rp.pBackground(); p_node_valid(background))
if (PBackground background = item.pBackground(); p_node_valid(background))
{
scene->params.background = vector_to_color(background.pVector());
}
else if (PHeight height = rp.pHeight(); p_node_valid(height))
else if (PHeight height = item.pHeight(); p_node_valid(height))
{
ok = token_to_size(input_file, height.pToken2(), &scene->params.height);
}
else if (PWidth width = rp.pWidth(); p_node_valid(width))
else if (PWidth width = item.pWidth(); p_node_valid(width))
{
ok = token_to_size(input_file, width.pToken2(), &scene->params.width);
}