public Node scan() throws SyntaxException, LexException, SemanticException { Node res = syntaxAnalyser.parse(); ArrayList<Node> tree = syntaxAnalyser.getTree(); ArrayList<Node> variables = new ArrayList<Node>(); tree.forEach( (node) -> { if (node.getTag() == Tag.VARIABLES) variables.add(node); }); setVariablesType(variables); ArrayList<Node> sequence = new ArrayList<Node>(); tree.forEach( (node) -> { if (node.getTag() == Tag.SEQUENCE) sequence.add(node); }); sequence.forEach( (node) -> { node.getChildren() .forEach( (node1) -> { try { check(node1.getChildren().get(0)); } catch (SemanticException e) { e.printStackTrace(); System.exit(1); } }); }); return res; }