Grammars for Functional and Spatial Reasoning in Design