factored out parsing functions from parser into common