I do quite distinictly remeber this mel is allready written and you can download it for further expanion for yoru needs form higehend.
easiest is if you can just asume everything is perfectly ordered inside parentheses.
I suggest you use tokenize instead of substitute loops when you use singyular delimitters its faster. if you msut use this approach.
then you can allways take the first part up to the parenthesis create that node, read in the datas of such nodes and populate them wich each node that comes along)
NOW one thing to note! a expression is not NECCESERILY slower than the equal thing expressed as a node network. IT greatly depends on what is connected and how those connections change. let use consider the following network. IT may in some instances be substantialy faster.
IM asuming here you use pure expressions not something that uses mel inside, jiust direct connections and pure expressivity
CODE
CLAMP
/ | \
1 0 ADD
/ \
1 MULT
/ \
0.5 Some input connection
NOw then this routine is NOT simplified by a node network one bit, infact it may be thet teh expression is more efficient in this case, oratleast a similliar case where there are more operations. Because all teh nodes need to be evaluated anyway, but they arenent evaluated in one go wich is the case for expressions, the expression eingene is possibly more efficient here (or atleast it will be once teh chain gets bigger).
Likewise if all or most the input connections downstream have tendency to change from eval to eval, then it does not matter that there are several inputs. However if teh ibnputs change frequantly indoependently freom eachoter its a different thing. (note it can be true that network is slightly faster for animation but NOT playback wich is more critical anyway)
however:
CODE
ADD
/ \
CLAMP Input connection that changes OFTEN
/ | \
1 0 ADD
/ \
MULT
/ \
0.5 Some input connection thet rarely changes
NOW this may infact be faster because the values of the entire CLAMP subtree is cached. NOW however you could compress the lower part to a expression isntead
CODE
ADD
/ \
EXPR Input connection that changes OFTEN
|
Some input connection thet rarely changes
Something to thinkabout.