In this paper, a parametric shape grammar for the derivation of the floor plans of educational buildings (madrasas) in Mamluk architecture is presented. The grammar is constructed using a corpus of sixteen Mamluk madrasas that were built in Egypt, Syria, and Palestine during the Mamluk period. Based on an epistemological premise of structuralism, the morphology of Mamluk madrasas is analyzed to deduce commonalities of the formal and compositional aspects among them. The set of underlying common lexical and syntactic elements that are shared by the study cases is listed. The shape rule schemata to derive Mamluk madrasa floor plans are formulated. The sets of lexical elements and syntactic rules are systematized to form a linguistic framework. The theoretical framework for the formal language of Mamluk architecture is structured to establish a basis for a computerized model for the automatic derivation of Mamluk madrasa floor plans.