Generic parsing functionality