From 6b6320822dc905e685f67816c495e51a5e02e2d4 Mon Sep 17 00:00:00 2001 From: Francis Russell Date: Fri, 14 Sep 2012 15:57:07 +0100 Subject: [PATCH] Validate index types. --- src/ParsedOFL.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 } -- 2.47.3