From dee7b8862adf76ccb77c95dc39bf922d1cd94b93 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Mon, 8 Mar 2021 13:01:32 +0100 Subject: [PATCH] Fixed Parser#parse and added -ea jvm argument in build.xml --- build.xml | 1 + src/lsystem/engine/Parser.java | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.xml b/build.xml index 2780510..d08656a 100644 --- a/build.xml +++ b/build.xml @@ -19,6 +19,7 @@ + diff --git a/src/lsystem/engine/Parser.java b/src/lsystem/engine/Parser.java index f4971e2..a21eded 100644 --- a/src/lsystem/engine/Parser.java +++ b/src/lsystem/engine/Parser.java @@ -97,7 +97,7 @@ public class Parser { Element root = null; Element workingElement = null; String number = ""; - boolean bracket = false; + List bracket = new ArrayList<>(); float[] appliedRotation = new float[3]; Element lastCreatedElement = null; @@ -120,6 +120,7 @@ public class Parser { lastCreatedElement = element; appliedRotation = new float[]{0f, 0f, 0f}; workingElement.children.add(element); + workingElement = lastCreatedElement; } } else { float n = getFloat(number); @@ -135,11 +136,11 @@ public class Parser { } if(c == '[') { workingElement = lastCreatedElement; - bracket = true; + bracket.add(lastCreatedElement); } if(c == ']') { - assert workingElement != null; - workingElement = workingElement.parent; + assert workingElement != null && !bracket.isEmpty(); + workingElement = bracket.remove(bracket.size() - 1); } } }