protected Term term() throws ParsingException {
        Term result;
        boolean f = false;
        if (tokens[position].equals(Lexeme.LEFT_P.s)) {
            position++;
            result = term();
        } else if (isLowercaseVariable(tokens[position])) {
            result = new Term(tokens[position]);
            position++;
            f = true;
            if (position < tokens.length && tokens[position].equals(Lexeme.LEFT_P.s)) {
                lookBack = position;
                position++;
                List<Term> arguments = new ArrayList<>(3);
                boolean success = true;
                try {
                    arguments.add(term());
                } catch (ParsingException e) {
                    position = lookBack;
                    success = false;
                }
                if (success) {
                    while (tokens[position].equals(Lexeme.COMMA.s)) {
                        position++;
                        arguments.add(term());
                    }
                    result.setArguments(arguments.toArray(new Term[arguments.size()]));
                    position++;
                }
            }
        } else
            throw new ParsingException("cannot parse term without name, incorrect invocation");

        if (!f) position++;
        return result;
    }