tools/PascalParser.hs
changeset 7550 3c4b4cb40f40
parent 7513 39866eb9e4a6
child 7641 42dba3e7fed2
equal deleted inserted replaced
7508:763d3961400b 7550:3c4b4cb40f40
   268         comments
   268         comments
   269         return ret
   269         return ret
   270         char ';'
   270         char ';'
   271         comments
   271         comments
   272         forward <- liftM isJust $ optionMaybe (try (string "forward;") >> comments)
   272         forward <- liftM isJust $ optionMaybe (try (string "forward;") >> comments)
   273         many functionDecorator
   273         inline <- liftM (any (== "inline;")) $ many functionDecorator
   274         b <- if isImpl && (not forward) then
   274         b <- if isImpl && (not forward) then
   275                 liftM Just functionBody
   275                 liftM Just functionBody
   276                 else
   276                 else
   277                 return Nothing
   277                 return Nothing
   278         return $ [OperatorDeclaration i rid ret vs b]
   278         return $ [OperatorDeclaration i rid inline ret vs b]
   279 
   279 
   280 
   280 
   281     funcDecl = do
   281     funcDecl = do
   282         fp <- try (string "function") <|> try (string "procedure")
   282         fp <- try (string "function") <|> try (string "procedure")
   283         comments
   283         comments
   293             else
   293             else
   294             return VoidType
   294             return VoidType
   295         char ';'
   295         char ';'
   296         comments
   296         comments
   297         forward <- liftM isJust $ optionMaybe (try (string "forward;") >> comments)
   297         forward <- liftM isJust $ optionMaybe (try (string "forward;") >> comments)
   298         many functionDecorator
   298         inline <- liftM (any (== "inline;")) $ many functionDecorator
   299         b <- if isImpl && (not forward) then
   299         b <- if isImpl && (not forward) then
   300                 liftM Just functionBody
   300                 liftM Just functionBody
   301                 else
   301                 else
   302                 return Nothing
   302                 return Nothing
   303         return $ [FunctionDeclaration i ret vs b]
   303         return $ [FunctionDeclaration i inline ret vs b]
   304 
   304 
   305     functionDecorator = choice [
   305     functionDecorator = do
   306         try $ string "inline;"
   306         d <- choice [
   307         , try $ caseInsensitiveString "cdecl;"
   307             try $ string "inline;"
   308         , try $ string "overload;"
   308             , try $ caseInsensitiveString "cdecl;"
   309         , try $ string "export;"
   309             , try $ string "overload;"
   310         , try $ string "varargs;"
   310             , try $ string "export;"
   311         , try (string "external") >> comments >> iD >> optional (string "name" >> comments >> stringLiteral pas)>> string ";"
   311             , try $ string "varargs;"
   312         ] >> comments
   312             , try (string "external") >> comments >> iD >> optional (string "name" >> comments >> stringLiteral pas)>> string ";"
       
   313             ]
       
   314         comments
       
   315         return d
   313 
   316 
   314 
   317 
   315 program = do
   318 program = do
   316     string "program"
   319     string "program"
   317     comments
   320     comments