If you try to do everything at once, it's very hard. Breaking it into steps makes it simpler:
1. Turn the expression string into a list of tokens. A token can be a variable name, an operator, or a parenthesis.
2. Turn the token list into a tree of tokens, where each operator token has child tokens of its operands.
3. Integrate the lowest-level sub-expressions, than combine them according to the operators, e.g. the integral of A + B is the integral of A plus the integral of B.
For step 2, apply two rules to your token list until you have a single operator token left in the list, representing the whole expression. (If you end up with more than one token in the list, you probably started with an illegal expression):
1. If you have the pattern: "(", [token], ")", replace it with [token], i.e. delete parenthesis tokens around a single value.
2. In the most deeply-nested parentheses, replace [token] [operator] [token] in the list with [operator], and set [operator]'s left and right child-node pointers to the two token operands. Do this for the highest-precedence operators first.
Well, the End result depends very much on the lanuage definitions you assume, and, what you want to do with the end result.
You need to define Language Rules, for instance, where do f,x,y,a,b,c come from.
In 'C' the compiler builds a Symbol Table, which is a cross referenced database of all variables encountered in a module.
What do you want to do with it. If you want to store it as a 'General Formula, your best bet is probably to convert it to RPN (Reverse Polish Notation) and write an RPN Evaluator for when the rubber hits the road,
In general, I would start with writing a Scanner,the Scanner breaks down the text into Tokens
the 'C' rules are like: A Variable starts with 'A..Z','a..z' or '_'
A Variable name can then be followed with the same, and the chars '0..9'
A Numerical starts with '0..9'
A White Space is a ' '(space), '\t' or a '\n'
So , in the above, the name of the first var is 'f', the next char is a '(' which is not a
legal char for a varname. So, the First token is a Lexical Token, with Identifier 'f'
The Next Token would be a Special Token, LPAREN,
Going on in general, (Your Language Definition does not allow for comments),
I would also write a Parser
The Parser calls the scanner , to pick off tokens One by One, ignoring intervening whitespace, or comments, and creates a parsing tree (But it all still depends what you want to do with the expression in the larger scheme of things.
A Book: Writing Compilers & Interpreters (An Applied Approach) by Ronald Mak, ISBN 0-471-50968-X
That's exactly what the method you're invoking returns, the height/width referenced to its parent coordinate system.
If you want to get the offset referenced to the screen (1st level of DOM) you can get it by adding all offset values invoking recursively to 'get_offsetParent' method (n-1) times.