in reply to howto parse (or determining end) of a line of perl

How have you implemented the calculator? If you already have a parser, just check whether it produces the starting symbol, if not, ask for more input. See for example my Marpa::R2 calculator with variables tolerant to missing semicolons on GitHub.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,