Split function rpn_scan in two.