created factor function for the expression grammar