 
     private func expression() throws -> Expr {
         return try equiality()
+    }
+    
+    private func declaration() throws -> Stmt? {
+        do {
+            if match(.Var) {
+                return try varDeclaration()
+            }
+            
+            return try statement()
+        } catch Error.parseFailure {
+            synchronize()
+            return nil // Recovered from error mode. Return nil and continue parsing.
+        }
     }
     
     private func statement() throws -> Stmt {

        
        do {
            while !isAtEnd() {
                statements.append(try statement())
            }
        } catch {
            return nil

        let value = try expression()
        try consume(.semicolon, message: "Expect ';' after value.")
        return Stmt.Print(expression: value)
    }
    
    private func varDeclaration() throws -> Stmt {
        let name = try consume(.identifier, message: "Expect variable name.")
        
        var initializer: Expr?
        if match(.equal) {
            initializer = try expression()
        }
        
        try consume(.semicolon, message: "Expect ';' after variable declaration.")
        
        return Stmt.Var(name: name, initializer: initializer)
    }
    
    private func expressionStatement() throws -> Stmt {
