From: Francis Russell Date: Thu, 20 Sep 2012 15:18:16 +0000 (+0100) Subject: Shorten some line lengths. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=9cd3bb9d47dc7dbaa0851052d923e47ce743b994;p=francis%2Fofc.git Shorten some line lengths. --- diff --git a/src/Parser.hs b/src/Parser.hs index 472e0b7..13dd462 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -203,18 +203,40 @@ parseFortranParam = do parseFortranParamProperty :: OFLParser FortranParameterProperty parseFortranParamProperty = - parseNameProperty <|> parseTypeProperty <|> parseSpaceProperty <|> parseIndexedProperty "Fortran parameter property" where - parseNameProperty = do _ <- lSymbol "name"; name <- lParens lStringLiteral; return $ ParamName name - parseTypeProperty = do _ <- lSymbol "type"; fType <- lParens parseFortranType; return $ ParamType fType - parseSpaceProperty = do _ <- lSymbol "space"; info <- lParens parseSpaceInfo; return $ Space info - parseSpaceInfo = do - _ <- lSymbol "psinc_fine_grid"; indices <- lParens $ lCommaSep1 lIdentifier; return $ FinePsinc indices - <|> do _ <- lSymbol "psinc_coarse_grid"; indices <- lParens $ lCommaSep1 lIdentifier; return $ CoarsePsinc indices - parseIndexedProperty = do _ <- lSymbol "indexed"; indices <- lParens $ lCommaSep1 lIdentifier; return $ Indexed indices + parseNameProperty + <|> parseTypeProperty + <|> parseSpaceProperty + <|> parseIndexedProperty + "Fortran parameter property" where + parseNameProperty = do + _ <- lSymbol "name" + name <- lParens lStringLiteral + return $ ParamName name + parseTypeProperty = do + _ <- lSymbol "type" + fType <- lParens parseFortranType + return $ ParamType fType + parseSpaceProperty = do + _ <- lSymbol "space" + info <- lParens parseSpaceInfo + return $ Space info + parseSpaceInfo = parseFineGrid <|> parseCoarseGrid + parseFineGrid = do + _ <- lSymbol "psinc_fine_grid" + indices <- lParens $ lCommaSep1 lIdentifier + return $ FinePsinc indices + parseCoarseGrid = do + _ <- lSymbol "psinc_coarse_grid" + indices <- lParens $ lCommaSep1 lIdentifier + return $ CoarsePsinc indices + parseIndexedProperty = do + _ <- lSymbol "indexed" + indices <- lParens $ lCommaSep1 lIdentifier + return $ Indexed indices parseFortranType :: OFLParser FortranType parseFortranType = do - baseType <- parseBaseType; + baseType <- parseBaseType maybeIndices <- optionMaybe parseArrayIndices case maybeIndices of Nothing -> return baseType @@ -241,9 +263,17 @@ parsePPDFunctionSet = do parsePPDFunctionSetProperty :: OFLParser PPDFunctionSetProperty parsePPDFunctionSetProperty = - parseBasisProperty <|> parseDataProperty "PPD function set property" where - parseBasisProperty = do _ <- lSymbol "basis"; ident <- lParens lIdentifier; return $ PPDBasis ident - parseDataProperty = do _ <- lSymbol "data"; ident <- lParens lIdentifier; return $ PPDData ident + parseBasisProperty + <|> parseDataProperty + "PPD function set property" where + parseBasisProperty = do + _ <- lSymbol "basis" + ident <- lParens lIdentifier + return $ PPDBasis ident + parseDataProperty = do + _ <- lSymbol "data" + ident <- lParens lIdentifier + return $ PPDData ident runOFLParser :: String -> Either ParseError OFL runOFLParser inputString = runParser parseOFL emptyOFL "" inputString diff --git a/src/TopLevel.hs b/src/TopLevel.hs index 9d1e0f5..c11e687 100644 --- a/src/TopLevel.hs +++ b/src/TopLevel.hs @@ -220,7 +220,9 @@ indexIsType ofl name indexType = if indexType == (getIndexType ofl name) else 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 +valueExists ofl name = if (hasValue ofl name) + then validationSuccess + else validationFailure $ "Unknown value " ++ name isFunction :: OFL -> Expression -> ValidationResult isFunction ofl e = case (getType ofl e) of