From d39b6d7120495d2ae1029bd791d3805ff7022c9b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 23 May 2022 17:46:26 +0200 Subject: [PATCH] Fix processing `else` and `elif` preprocessor blocks in Flax.Build bindings parser --- .../Flax.Build/Bindings/BindingsGenerator.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.cs index 0bff58946..292f07773 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.cs @@ -361,6 +361,7 @@ namespace Flax.Build.Bindings break; } case "if": + case "elif": { // Parse condition var condition = string.Empty; @@ -510,6 +511,22 @@ namespace Flax.Build.Bindings case "ifdef": ifsCount++; break; + case "else": + if (ifsCount == 1) + { + // Continue with `else` block + return; + } + break; + case "elif": + if (ifsCount == 1) + { + // Rollback to process conditional block + tokenizer.PreviousToken(); + tokenizer.PreviousToken(); + return; + } + break; case "endif": ifsCount--; break;