generalised parser functions for javascript language