From f139613030d4032cd7ad28009adb50ee973ce3f9 Mon Sep 17 00:00:00 2001 From: Francis Russell Date: Sun, 16 Sep 2012 17:10:37 +0100 Subject: [PATCH] Improve parser error messages. --- src/Parser.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Parser.hs b/src/Parser.hs index df0f9d6..68937ed 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -48,7 +48,7 @@ parseType = foldl1' (<|>) [do lReserved $ show t; return t | t <- [minBound::Bas parseIndex = foldl1' (<|>) [do lReserved $ show t; return t | t <- [minBound::IndexType ..]] parseDeclaration :: Parsec String OFL () -parseDeclaration = parseValueDeclaration <|> parseIndexDeclaration +parseDeclaration = parseValueDeclaration <|> parseIndexDeclaration "declaration" parseValueDeclaration :: Parsec String OFL () parseValueDeclaration = do @@ -75,7 +75,7 @@ parseAssignment = do modifyState(\x -> addAssignment x lhs rhs) "assignment" -parseExpression = buildExpressionParser oflOperatorTable parseTerm +parseExpression = buildExpressionParser oflOperatorTable parseTerm "expression" parseTerm = do lReserved "laplacian"; operand <- lParens parseExpression; return $ Laplacian operand @@ -112,7 +112,7 @@ parseDerivative = do return $ Derivative e1 index "derivative" -parseIdentifierAccess = do +parseIdentifierAccess = do ident <- parseIdentifier indices <- option [] (lBrackets $ lCommaSep parseIdentifier) return $ IndexedIdentifier ident indices @@ -147,7 +147,7 @@ parseFortranParam = do return $ FortranParameter properties parseFortranParamProperty = - parseNameProperty <|> parseTypeProperty <|> parseSpaceProperty <|> parseIndexedProperty where + 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 @@ -182,7 +182,7 @@ parsePPDFunctionSet = do return $ PPDFunctionSet properties parsePPDFunctionSetProperty = - parseBasisProperty <|> parseDataProperty where + 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 -- 2.47.3