]> git.unchartedbackwaters.co.uk Git - francis/ofc.git/commitdiff
Improve parser error messages.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Sun, 16 Sep 2012 16:10:37 +0000 (17:10 +0100)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Sun, 16 Sep 2012 16:10:37 +0000 (17:10 +0100)
src/Parser.hs

index df0f9d6a67b60973cf697e7fc03355d946a3f046..68937ed6652195cb24e0c1ad8024ad38028a1c6e 100644 (file)
@@ -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