tools/PascalParser.hs
changeset 6426 2d44f6561e72
parent 6425 1ef4192aa80d
child 6443 23364a5fcc86
equal deleted inserted replaced
6425:1ef4192aa80d 6426:2d44f6561e72
   202     arrayDecl = do
   202     arrayDecl = do
   203         try $ do
   203         try $ do
   204             optional $ (try $ string "packed") >> comments
   204             optional $ (try $ string "packed") >> comments
   205             string "array"
   205             string "array"
   206         comments
   206         comments
   207         r <- optionMaybe $ do
   207         r <- option [] $ do
   208             char '['
   208             char '['
   209             r <- rangeDecl
   209             r <- commaSep pas rangeDecl
   210             char ']'
   210             char ']'
   211             comments
   211             comments
   212             return r
   212             return r
   213         string "of"
   213         string "of"
   214         comments
   214         comments
   215         t <- typeDecl
   215         t <- typeDecl
   216         return $ ArrayDecl r t
   216         if null r then
       
   217             return $ ArrayDecl Nothing t
       
   218             else
       
   219             return $ foldr (\a b -> ArrayDecl (Just a) b) (ArrayDecl (Just $ head r) t) (tail r) 
   217     recordDecl = do
   220     recordDecl = do
   218         try $ do
   221         try $ do
   219             optional $ (try $ string "packed") >> comments
   222             optional $ (try $ string "packed") >> comments
   220             string "record"
   223             string "record"
   221         comments
   224         comments