There are reagents that are specific for each macro molecules in foods. When these reagent are applied to the the food molecules, color changes occur which allow us to know the exact identification the the food macro molecule present in the food.
For instance, iodine is a reagent, that will give blue-black color when applied to starch.