Changeset 8585

Show
Ignore:
Timestamp:
01/05/06 18:14:10 (3 years ago)
Author:
gaal
Message:

YAML emitting

  • "moose".yaml; 42.yaml; (undef).yaml work
  • (123.12).yaml gives funny results (because it's delegated to pugs' pretty-printer

Tests very welcome!

Location:
src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/Data/Yaml/Syck.hsc

    r8584 r8585  
    8787    node <- thawNode vp 
    8888    case node of 
     89        YamlNil -> do 
     90            -- return syck_emit_scalar(e, "string", scalar_none, 0, 0, 0, "~", 1); 
     91            withCString "string" $ \string_literal ->        
     92                withCString "~" $ \cs ->        
     93                    syck_emit_scalar e string_literal scalarNone 0 0 0 cs 1 
    8994        (YamlStr str) -> do 
    9095            -- return syck_emit_scalar(e, "string", scalar_none, 0, 0, 0, SvPVX(sv), SvCUR(sv)); 
  • src/Pugs/Prim/Yaml.hs

    r8566 r8585  
    77import Pugs.Internals 
    88import Pugs.AST 
     9import Pugs.Pretty 
    910import Data.Yaml.Syck 
    1011import qualified Data.Map as Map 
     
    4546toYaml :: Val -> Eval YamlNode 
    4647toYaml VUndef = return YamlNil 
     48--toYaml (VNum num) = return $ YamlStr -- better handled by pretty 
    4749toYaml (VStr str) = return $ YamlStr (encodeUTF8 str) 
    4850toYaml (VList nodes) = do 
    4951    fmap YamlSeq $ mapM toYaml nodes 
     52toYaml x = return $ YamlStr $ encodeUTF8 $ pretty x 
    5053--toYaml (VHash hash) = do 
    5154--    fmap YamlMap $ Map.toList hash