diff --git a/src/fart.propane b/src/fart.propane index 5532859..5ad6515 100644 --- a/src/fart.propane +++ b/src/fart.propane @@ -31,7 +31,6 @@ token lcurly /\{/; token lt /> -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 -> ; diff --git a/src/fart/Parser.cpp b/src/fart/Parser.cpp index edd50d5..6c83c5a 100644 --- a/src/fart/Parser.cpp +++ b/src/fart/Parser.cpp @@ -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); }