Treat init expression in parens as just expression instead of array initializer when there's only one entry in expressions list
authorunc0rr
Sun, 16 Sep 2012 23:30:55 +0400 (2012-09-16)
changeset 7690 6ef121a80cb0
parent 7688 9daa06188551
child 7692 9545f2bf087c
Treat init expression in parens as just expression instead of array initializer when there's only one entry in expressions list
tools/PascalParser.hs
--- a/tools/PascalParser.hs	Sun Sep 16 22:55:33 2012 +0400
+++ b/tools/PascalParser.hs	Sun Sep 16 23:30:55 2012 +0400
@@ -565,8 +565,9 @@
     term = comments >> choice [
         liftM (uncurry BuiltInFunction) $ builtInFunction initExpression 
         , try $ brackets pas (commaSep pas $ initExpression) >>= return . InitSet
-        , try $ parens pas (commaSep pas $ initExpression) >>= return . InitArray
-        , parens pas (sepEndBy recField (char ';' >> comments)) >>= return . InitRecord
+        , try $ parens pas (commaSep pas $ initExpression) >>= \ia -> when (null $ tail ia) mzero >> return (InitArray ia)
+        , try $ parens pas (sepEndBy recField (char ';' >> comments)) >>= return . InitRecord
+        , parens pas initExpression
         , try $ integer pas >>= \i -> notFollowedBy (char '.') >> (return . InitNumber . show) i
         , try $ float pas >>= return . InitFloat . show
         , try $ integer pas >>= return . InitNumber . show