Reintroduce options block to scene file grammar; remove scene block
This commit is contained in:
1 parent
0ba0ebfe71
commit
de2c51376a
2 files changed
+14
-13
No files matched your search
+7
-8
@@ -31,7 +31,6 @@ token lcurly /\{/;
|
|||||||
token lt /</;
|
token lt /</;
|
||||||
token options;
|
token options;
|
||||||
token rcurly /\}/;
|
token rcurly /\}/;
|
||||||
token scene;
|
|
||||||
token width;
|
token width;
|
||||||
|
|
||||||
token uint /\d+/ <<
|
token uint /\d+/ <<
|
||||||
@@ -47,7 +46,7 @@ token number /-?\d+(\.\d+)?/ <<
|
|||||||
}
|
}
|
||||||
>>
|
>>
|
||||||
|
|
||||||
Start -> RenderParams Scene;
|
Start -> Options? SceneItems;
|
||||||
|
|
||||||
Background -> background Vector;
|
Background -> background Vector;
|
||||||
|
|
||||||
@@ -56,14 +55,14 @@ Height -> height uint;
|
|||||||
Number -> uint;
|
Number -> uint;
|
||||||
Number -> number;
|
Number -> number;
|
||||||
|
|
||||||
RenderParams -> ;
|
Options -> options lcurly OptionsItems rcurly;
|
||||||
RenderParams -> RenderParam RenderParams;
|
|
||||||
|
|
||||||
RenderParam -> Background;
|
OptionsItems -> ;
|
||||||
RenderParam -> Height;
|
OptionsItems -> OptionsItem OptionsItems;
|
||||||
RenderParam -> Width;
|
|
||||||
|
|
||||||
Scene -> scene lcurly SceneItems rcurly;
|
OptionsItem -> Background;
|
||||||
|
OptionsItem -> Height;
|
||||||
|
OptionsItem -> Width;
|
||||||
|
|
||||||
SceneItems -> ;
|
SceneItems -> ;
|
||||||
|
|
||||||
|
|||||||
+7
-5
@@ -116,19 +116,21 @@ Scene * Parser::build_scene(const string_view & input_file, PStart start)
|
|||||||
{
|
{
|
||||||
Scene * scene = new Scene();
|
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;
|
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());
|
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);
|
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);
|
ok = token_to_size(input_file, width.pToken2(), &scene->params.width);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user