private Node parseFactor(final Node parent) throws SyntaxException, IOException {
        if (scanner.getCurrentToken().isType(TokenType.IDENTIFIER)) {
            return IdentifierNode.newInstance(parent, scanner.getCurrentToken().getValue());
        }

        if (scanner.getCurrentToken().isType(TokenType.LITERAL)) {
            // TODO Implement range parsing.
            /*if (assertToken(scanner.peekToken(), TokenType.OPERATOR, ".")) {
                echo "range";
                range = dom.createElement(Type.RANGE);
                range.setAttribute("from", scanner.currentToken().getValue(true));
                scanner.nextToken(); // Omit ".." literal.
                scanner.nextToken();
                range.setAttribute("to", scanner.currentToken().getValue(true));
                return range;
            }*/

            return TerminalNode.newInstance(parent, scanner.getCurrentToken().getValue(true));
        }

        if (scanner.getCurrentToken().isType(TokenType.COMMENT)) {
            return CommentNode.newInstance(parent, scanner.getCurrentToken().getValue());
        }

        if (assertToken(scanner.getCurrentToken(), TokenType.L_PAREN, "(")) {
            scanner.nextToken();
            final Node expression = parseExpression(parent);

            if (!assertToken(scanner.getCurrentToken(), TokenType.R_PAREN, ")")) {
                raiseError("Group must end with ')'");
            }

            return expression;
        }

        if (assertToken(scanner.getCurrentToken(), TokenType.L_BRACK, "[")) {
            scanner.nextToken();
            final Node expression = parseExpression(parent);
            final Option option = Option.newInstance(parent);
            option.addChild(expression);

            if (!assertToken(scanner.getCurrentToken(), TokenType.R_BRACK, "]")) {
                raiseError("Option must end with ']'");
            }

            return option;
        }

        if (assertToken(scanner.getCurrentToken(), TokenType.L_BRACE, "{")) {
            scanner.nextToken();
            final Node expression = parseExpression(parent);
            final LoopNode loop       = LoopNode.newInstance(parent);
            loop.addChild(expression);

            if (!assertToken(scanner.getCurrentToken(), TokenType.R_BRACE, "}")) {
                raiseError("Loop must end with '}'");
            }

            return loop;
        }

        raiseError("Factor expected");
        return null;
    }