* Helper for nextNode, which does the real work
*
* @return a Node or null if file ends
*/
public Node nextNode1(int depth) throws ParserException {
Node first = lexer.nextToken();
// end of file
if (first == null) {
return null;
}
if (Delimeter.isOpen(first)) { // try to get matched (...)
List<Node> elements = new ArrayList<>();
Node next;
for (next = nextNode1(depth + 1);
!Delimeter.match(first, next);
next = nextNode1(depth + 1))
{
if (next == null) {
throw new ParserException("unclosed delimeter till end of file: " + first.toString(), first);
} else if (Delimeter.isClose(next)) {
throw new ParserException("unmatched closing delimeter: " +
next.toString() + " does not close " + first.toString(), next);
} else {
elements.add(next);
}
}
return new Tuple(elements, first, next, first.file, first.start, next.end, first.line, first.col);