tools/pas2c/PascalParser.hs
changeset 10129 cd2a64a1f4aa
parent 10120 b7f632c12784
child 10131 4b4a043111f4
equal deleted inserted replaced
10128:0f6878b5395a 10129:cd2a64a1f4aa
   327         comments
   327         comments
   328         forward <- liftM isJust $ optionMaybe (try (string "forward;") >> comments)
   328         forward <- liftM isJust $ optionMaybe (try (string "forward;") >> comments)
   329         decorators <- many functionDecorator
   329         decorators <- many functionDecorator
   330         let inline = any (== "inline;") decorators
   330         let inline = any (== "inline;") decorators
   331             overload = any (== "overload;") decorators
   331             overload = any (== "overload;") decorators
   332         b <- if isImpl && (not forward) then
   332             external = any (== "external;") decorators
       
   333         -- TODO: don't mangle external functions names (and remove fpcrtl.h defines hacks)
       
   334         b <- if isImpl && (not forward) && (not external) then
   333                 liftM Just functionBody
   335                 liftM Just functionBody
   334                 else
   336                 else
   335                 return Nothing
   337                 return Nothing
   336         return $ [FunctionDeclaration i inline overload ret vs b]
   338         return $ [FunctionDeclaration i inline overload external ret vs b]
   337 
   339 
   338     functionDecorator = do
   340     functionDecorator = do
   339         d <- choice [
   341         d <- choice [
   340             try $ string "inline;"
   342             try $ string "inline;"
   341             , try $ caseInsensitiveString "cdecl;"
   343             , try $ caseInsensitiveString "cdecl;"
   342             , try $ string "overload;"
   344             , try $ string "overload;"
   343             , try $ string "export;"
   345             , try $ string "export;"
   344             , try $ string "varargs;"
   346             , try $ string "varargs;"
   345             , try (string' "external") >> comments >> iD >> optional (string' "name" >> comments >> stringLiteral pas) >> string' ";" >> return "external"
   347             , try (string' "external") >> comments >> iD >> comments >>
       
   348                 optional (string' "name" >> comments >> stringLiteral pas) >> string' ";" >> return "external;"
   346             ]
   349             ]
   347         comments
   350         comments
   348         return d
   351         return d
   349 
   352 
   350 
   353