tools/pas2c/PascalParser.hs
branchwebgl
changeset 9954 bf51bc7e2808
parent 9166 3774ac58e65e
child 10111 459bc720cea1
equal deleted inserted replaced
9952:32f5982604f4 9954:bf51bc7e2808
   577 initExpression = buildExpressionParser table term <?> "initialization expression"
   577 initExpression = buildExpressionParser table term <?> "initialization expression"
   578     where
   578     where
   579     term = comments >> choice [
   579     term = comments >> choice [
   580         liftM (uncurry BuiltInFunction) $ builtInFunction initExpression
   580         liftM (uncurry BuiltInFunction) $ builtInFunction initExpression
   581         , try $ brackets pas (commaSep pas $ initExpression) >>= return . InitSet
   581         , try $ brackets pas (commaSep pas $ initExpression) >>= return . InitSet
   582         , try $ parens pas (commaSep pas $ initExpression) >>= \ia -> when (null $ tail ia) mzero >> return (InitArray ia)
   582         , try $ parens pas (commaSep pas $ initExpression) >>= \ia -> when ((notRecord $ head ia) && (null $ tail ia)) mzero >> return (InitArray ia)
   583         , try $ parens pas (sepEndBy recField (char ';' >> comments)) >>= return . InitRecord
   583         , try $ parens pas (sepEndBy recField (char ';' >> comments)) >>= return . InitRecord
   584         , parens pas initExpression
   584         , parens pas initExpression
   585         , try $ integer pas >>= \i -> notFollowedBy (char '.') >> (return . InitNumber . show) i
   585         , try $ integer pas >>= \i -> notFollowedBy (char '.') >> (return . InitNumber . show) i
   586         , try $ float pas >>= return . InitFloat . show
   586         , try $ float pas >>= return . InitFloat . show
   587         , try $ integer pas >>= return . InitNumber . show
   587         , try $ integer pas >>= return . InitNumber . show
   592         , try $ string "nil" >> return InitNull
   592         , try $ string "nil" >> return InitNull
   593         , itypeCast
   593         , itypeCast
   594         , iD >>= return . InitReference
   594         , iD >>= return . InitReference
   595         ]
   595         ]
   596 
   596 
       
   597     notRecord (InitRecord _) = False
       
   598     notRecord _ = True
       
   599 
   597     recField = do
   600     recField = do
   598         i <- iD
   601         i <- iD
   599         spaces
   602         spaces
   600         char ':'
   603         char ':'
   601         spaces
   604         spaces