     }
   }
 
+  func parseModule(scanner: NSScanner, _ lineNumber: Int) {
+    mustScanWord(scanner, "{")
+
+    scanner.scanUpToString("}", intoString: nil)
+    scanner.scanString("}", intoString: nil)
+  }
+
   func validate() {
     // TODO: Implement some validations
     return

import Foundation

private let commentToken = "#"
private let whitespaceCharacterSet = NSCharacterSet.whitespaceCharacterSet()

let WhitespaceAndNewlineCharacterSet = NSCharacterSet.whitespaceAndNewlineCharacterSet()

class Roostfile {

  var sources: [String] = []

  func parseFromString(string: String) {
    // Map names to processors
    let map = [
      "name":    self.parseName,
      "sources": self.parseSources,
      "module":  self.parseModule
    ]

    let stringAsNSString = string as NSString

    var lineNumber = 0
    
    var scanner = NSScanner(string: string)
    scanner.charactersToBeSkipped = WhitespaceCharacterSet

    commandLoop: while !scanner.atEnd {
      consumeCommentsAndNewlines(scanner)

      let maybeWord = scanWord(scanner)

      if maybeWord == nil {
        if scanner.atEnd { return }

        println("Ran out of input")
        exit(1)
      }

      let word = maybeWord!

      for (command, action) in map {
        if word == command {
          // println("Action found for \(word)")
          action(scanner, 0)
          continue commandLoop
        }
      }

      println("Unrecognied token `\(word)`")
      exit(1)
    }


    /*
    stringAsNSString.enumerateLinesUsingBlock { (line, stop) in
      let scanner = NSScanner(string: line)
      lineNumber += 1

