From: Francis Russell Date: Fri, 14 Sep 2012 14:57:07 +0000 (+0100) Subject: Validate index types. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=6b6320822dc905e685f67816c495e51a5e02e2d4;p=francis%2Fofc.git Validate index types. --- diff --git a/src/ParsedOFL.hs b/src/ParsedOFL.hs index 6c7d3f9..461e6a8 100644 --- a/src/ParsedOFL.hs +++ b/src/ParsedOFL.hs @@ -124,6 +124,11 @@ isLValue _ e = validationFailure $ "Expression " ++ show e ++ " is not an assign indexExists :: OFL -> String -> ValidationResult indexExists ofl name = if (hasIndex ofl name) then validationSuccess else validationFailure $ "Unknown index " ++ name +indexIsType :: OFL -> String -> IndexType -> ValidationResult +indexIsType ofl name indexType = case indexType == (getIndexType ofl name) of + True -> validationSuccess + False -> validationFailure $ "Expected index " ++ name ++ " to be be of type " ++ show indexType + valueExists :: OFL -> String -> ValidationResult valueExists ofl name = if (hasValue ofl name) then validationSuccess else validationFailure $ "Unknown value " ++ name @@ -191,12 +196,13 @@ validateExpression ofl (Power a b) = do { validateExpression ofl b; } - validateExpression ofl (PositionComponent i) = do { indexExists ofl i; + indexIsType ofl i SpatialIndex } validateExpression ofl (Derivative e i) = do { validateExpression ofl e; indexExists ofl i; + indexIsType ofl i SpatialIndex }