In the PCC macros folder of the OPL, there is contextForm.pl:
You could try this. After loading this macro library file, then try:
$answer = Formula("3x^2+xy+x");
If that does not behave as desired, let me know the details, and I may be able to suggest one or two more lines to make it work.