diff --git a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Yaml.hs b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Yaml.hs index 95b6f74c1..3863834e2 100644 --- a/eo-phi-normalizer/src/Language/EO/Phi/Rules/Yaml.hs +++ b/eo-phi-normalizer/src/Language/EO/Phi/Rules/Yaml.hs @@ -75,9 +75,34 @@ convertRule Rule{..} ctx obj = | subst <- matchObject pattern obj , all (\cond -> checkCond ctx cond subst) when , obj' <- [applySubst subst result] - -- TODO #82:20m check that obj' does not have any metavariables + , not (objectHasMetavars obj') ] +objectHasMetavars :: Object -> Bool +objectHasMetavars (Formation bindings) = any bindingHasMetavars bindings +objectHasMetavars (Application object bindings) = objectHasMetavars object || any bindingHasMetavars bindings +objectHasMetavars (ObjectDispatch object attr) = objectHasMetavars object || attrHasMetavars attr +objectHasMetavars (GlobalDispatch attr) = attrHasMetavars attr +objectHasMetavars (ThisDispatch attr) = attrHasMetavars attr +objectHasMetavars Termination = False +objectHasMetavars (MetaObject _) = True + +bindingHasMetavars :: Binding -> Bool +bindingHasMetavars (AlphaBinding attr obj) = attrHasMetavars attr || objectHasMetavars obj +bindingHasMetavars (EmptyBinding attr) = attrHasMetavars attr +bindingHasMetavars (DeltaBinding _) = False +bindingHasMetavars (LambdaBinding _) = False +bindingHasMetavars (MetaBindings _) = True + +attrHasMetavars :: Attribute -> Bool +attrHasMetavars Phi = False +attrHasMetavars Rho = False +attrHasMetavars Sigma = False +attrHasMetavars VTX = False +attrHasMetavars (Label _) = False +attrHasMetavars (Alpha _) = False +attrHasMetavars (MetaAttr _) = True + -- | Given a condition, and a substition from object matching -- tells whether the condition matches the object checkCond :: Common.Context -> Condition -> Subst -> Bool