public Function parse() {
        System.out.println(s);

        StringTokenizer tokenizer = new StringTokenizer(s);

        while (tokenizer.hasMoreTokens()) {
            String str = tokenizer.nextToken();

            last = operation_stack.peek();
            if (str.equals("(")) {
                operation_stack.push(str);
            } else if (str.equals(")")) {           
                //vyhodnocuje az po predch. zatvorku
                while (!last.equals("(")) {
                    f = createFunction(last, f);
                    operation_stack.pop();
                    last = operation_stack.peek();
                }
                operation_stack.pop();

            } else if (priority.indexOf(str) > -1) { //nie je to cislo, ale op.

                if (priority.indexOf(str) >= priority.indexOf(last)) {
                    operation_stack.push(str);
                } else {
                    while (priority.indexOf(str) < priority.indexOf(last)) {
                        f = createFunction(last, f);                        
                        operation_stack.remove(last);                        
                        last = operation_stack.peek(); 
                    }
                    operation_stack.push(str);
                }
            } else if (str.equals("z")) {
                function_stack.push(id);
            } else {
                Complex c = parse_complex(str);
                Function constant = new Constant(c);
                function_stack.push(constant);
            }           
        }
        // System.out.println(operation_stack);
        // System.out.println(complex_stack);
        return f;
    }