Handle optionals correctly
Currently, "unfilled" optionals (i.e., ones that do not have a child), lead to a NullPointerException
because the getX
method is called without testing for their existence first.
MWE:
Root ::= [A] ;
A ;
Root root = new Root(); // do not set A
Dumper.read(root).dumpAsPNG(somePath);
Will lead to
Caused by: java.lang.NullPointerException
at ast.ASTNode.getChild(ASTNode.java:...)
at ast.Root.getA(Root.java:...)