fix($parse): properly handle dots at the end of identifiers

Fixes #4613
Fixes #4912