Fixed Parser#parse and added -ea jvm argument in build.xml

This commit is contained in:
Quentin Legot 2021-03-08 13:01:32 +01:00
parent e644f05e23
commit dee7b8862a
2 changed files with 6 additions and 4 deletions

View File

@ -19,6 +19,7 @@
</target> </target>
<target name="run" description="execution" depends="compile"> <target name="run" description="execution" depends="compile">
<java classname="lsystem.Main" fork="true"> <java classname="lsystem.Main" fork="true">
<jvmarg value="-ea"/>
<classpath refid="project.classpath"/> <classpath refid="project.classpath"/>
</java> </java>
</target> </target>

View File

@ -97,7 +97,7 @@ public class Parser {
Element root = null; Element root = null;
Element workingElement = null; Element workingElement = null;
String number = ""; String number = "";
boolean bracket = false; List<Element> bracket = new ArrayList<>();
float[] appliedRotation = new float[3]; float[] appliedRotation = new float[3];
Element lastCreatedElement = null; Element lastCreatedElement = null;
@ -120,6 +120,7 @@ public class Parser {
lastCreatedElement = element; lastCreatedElement = element;
appliedRotation = new float[]{0f, 0f, 0f}; appliedRotation = new float[]{0f, 0f, 0f};
workingElement.children.add(element); workingElement.children.add(element);
workingElement = lastCreatedElement;
} }
} else { } else {
float n = getFloat(number); float n = getFloat(number);
@ -135,11 +136,11 @@ public class Parser {
} }
if(c == '[') { if(c == '[') {
workingElement = lastCreatedElement; workingElement = lastCreatedElement;
bracket = true; bracket.add(lastCreatedElement);
} }
if(c == ']') { if(c == ']') {
assert workingElement != null; assert workingElement != null && !bracket.isEmpty();
workingElement = workingElement.parent; workingElement = bracket.remove(bracket.size() - 1);
} }
} }
} }