         yaml_parser_set_input_file(&parser, fileHandler)
         
         repeat {
-            if (yaml_parser_parse(&parser, &event) == 0) {
-                print("Parser error %d\n", parser.error);
+            if yaml_parser_parse(&parser, &event) == 0 {
+                print("Parser error %d\n", parser.error)
                 exit(EXIT_FAILURE);
             }
             
             switch(event.type) {
-                case YAML_NO_EVENT: print("No event!"); break;
+                case YAML_NO_EVENT: print("No event!")
                 
                 /* Stream start/end */
-                case YAML_STREAM_START_EVENT: print("STREAM START"); break;
-                case YAML_STREAM_END_EVENT:   print("STREAM END");   break;
+                case YAML_STREAM_START_EVENT:   print("STREAM START")
+                case YAML_STREAM_END_EVENT:     print("STREAM END")
                 
                 /* Block delimeters */
-                case YAML_DOCUMENT_START_EVENT: print("Start Document");
-                case YAML_DOCUMENT_END_EVENT:   print("End Document");
-                case YAML_SEQUENCE_START_EVENT: print("Start Sequence");
-                case YAML_SEQUENCE_END_EVENT:   print("End Sequence");
-                case YAML_MAPPING_START_EVENT:  print("Start Mapping");
-                case YAML_MAPPING_END_EVENT:    print("End Mapping");
+                case YAML_DOCUMENT_START_EVENT: print("Start Document")
+                case YAML_DOCUMENT_END_EVENT:   print("End Document")
+                case YAML_SEQUENCE_START_EVENT: print("Start Sequence")
+                case YAML_SEQUENCE_END_EVENT:   print("End Sequence")
+                case YAML_MAPPING_START_EVENT:  print("Start Mapping")
+                case YAML_MAPPING_END_EVENT:    print("End Mapping")
                 
                 /* Data */
-                case YAML_ALIAS_EVENT:  print("Got alias (anchor %s)\n", event.data.alias.anchor);
-                case YAML_SCALAR_EVENT: print("Got scalar (value %s)\n", event.data.scalar.value);
+                case YAML_ALIAS_EVENT:
+                    print("Got alias (anchor: \(event.data.alias.anchor)");
+                case YAML_SCALAR_EVENT:
+                    
+                    print("Got scalar (value: \(scalarToString(event.data.scalar)))")
+                
                 
             default: print("Uknown event");
             }


import yaml

public class YAMLParser {
    
    public init() {
        
    }
    
    public func yamlGetVersionString() -> String? {
        let version = yaml_get_version_string()

        
        yaml_event_delete(&event);
        
        yaml_parser_delete(&parser);
        fclose(fileHandler);
    }

        
    // MARK: Private routines
    
    func scalarToString(scalar:scalar_t) -> String? {
        let len = scalar.length
        let ptr = scalar.value
    
        return cStringToString(ptr, length: len)
    }
    
    func cStringToString(ptr: UnsafeMutablePointer<UInt8>, length len: Int) -> String? {
        if let theString = NSString(bytes: ptr, length: len, encoding: NSUTF8StringEncoding) {
            return theString as String
        } else {
            return nil
        }
    }
}
