This is a really complicated task, which is prone to bugs. How do you want to treat "2x" compared to "x2"? If "x" is a variable, "x2" can be a variable also. Or it can mean "x * 2". There is no clear and clean way, to distinguish this. Therefore Matlab uses the * as multiplication operator and omitting it in "2x" is no valid syntax.
If you want to write a really intelligent parser, make sure to publish the results as PhD or sell it at least to Google for their AI resarch.
Are you sure, that this job is required to solve your problem?