@@ -147,21 +147,24 @@ parse = do
147 requireEvent EventStreamEnd
147 requireEvent EventStreamEnd
148 return res
148 return res
150−parseScalar :: ByteString -> Anchor
150+parseScalar :: ByteString -> Anchor -> Style
151 -> C.Sink Event Parse Text
151 -> C.Sink Event Parse Text
152−parseScalar v a = do
152+parseScalar v a style = do
153 let res = decodeUtf8With lenientDecode v
153 let res = decodeUtf8With lenientDecode v
154 case a of
154 case a of
155 Nothing -> return res
155 Nothing -> return res
156 Just an -> do
156 Just an -> do
157− lift $ modify (Map.insert an $ textToValue res)
157+ lift $ modify (Map.insert an $ textToValue style res)
158 return res
158 return res
160−textToValue :: Text -> Value -- FIXME check for quoting style?
160+textToValue :: Style -> Text -> Value
161+textToValue SingleQuoted t = String t
162+textToValue DoubleQuoted t = String t
163+textToValue Folded t = String t
161−textToValue "true" = Bool True
164+textToValue _ "true" = Bool True
162−textToValue "false" = Bool False
165+textToValue _ "false" = Bool False
163−textToValue "null" = Null
166+textToValue _ "null" = Null
164−textToValue t
167+textToValue _ t
165 | Right (x, "") <- signed decimal t = Number $ I x
168 | Right (x, "") <- signed decimal t = Number $ I x
166 | Right (x, "") <- double t = Number $ D x
169 | Right (x, "") <- double t = Number $ D x
167 | otherwise = String t
170 | otherwise = String t
@@ -170,7 +173,7 @@ parseO :: C.Sink Event Parse Value
170parseO = do
173parseO = do
171 me <- CL.head
174 me <- CL.head
172 case me of
175 case me of
173− Just (EventScalar v _t _s a) -> fmap textToValue $ parseScalar v a
176+ Just (EventScalar v _t style a) -> fmap (textToValue style) $ parseScalar v a style
174 Just (EventSequenceStart a) -> parseS a id
177 Just (EventSequenceStart a) -> parseS a id
175 Just (EventMappingStart a) -> parseM a M.empty
178 Just (EventMappingStart a) -> parseM a M.empty
176 Just (EventAlias an) -> do
179 Just (EventAlias an) -> do
@@ -215,7 +218,7 @@ parseM a front = do
216 CL.drop 1
219 CL.drop 1
217 s <- case me of
220 s <- case me of
218− Just (EventScalar v _ _ a') -> parseScalar v a'
221+ Just (EventScalar v _ style a') -> parseScalar v a' style
219 _ -> liftIO $ throwIO $ UnexpectedEvent me Nothing
222 _ -> liftIO $ throwIO $ UnexpectedEvent me Nothing
220 o <- parseO
223 o <- parseO