Index: libcfa/prelude/Makefile.in
===================================================================
--- libcfa/prelude/Makefile.in	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ libcfa/prelude/Makefile.in	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -1,6 +1,6 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
@@ -331,6 +331,6 @@
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
 	esac;
 
@@ -377,8 +377,5 @@
 
 
-distdir: $(BUILT_SOURCES)
-	$(MAKE) $(AM_MAKEFLAGS) distdir-am
-
-distdir-am: $(DISTFILES)
+distdir: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
Index: libcfa/src/Makefile.am
===================================================================
--- libcfa/src/Makefile.am	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ libcfa/src/Makefile.am	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -33,5 +33,5 @@
 # The built sources must not depend on the installed headers
 AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
-AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
+AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -fexceptions -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
 AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
 CFACC = @CFACC@
Index: libcfa/src/Makefile.in
===================================================================
--- libcfa/src/Makefile.in	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ libcfa/src/Makefile.in	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -456,5 +456,5 @@
 # The built sources must not depend on the installed headers
 AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
-AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
+AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -fexceptions -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
 AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
 @BUILDLIB_FALSE@headers_nosrc = 
Index: libcfa/src/exception.c
===================================================================
--- libcfa/src/exception.c	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ libcfa/src/exception.c	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -10,6 +10,6 @@
 // Created On       : Mon Jun 26 15:13:00 2017
 // Last Modified By : Andrew Beach
-// Last Modified On : Fri Apr 03 11:57:00 2020
-// Update Count     : 14
+// Last Modified On : Mon Apr 06 14:40:00 2020
+// Update Count     : 15
 //
 
@@ -75,4 +75,8 @@
 // RESUMPTION ================================================================
 
+static void reset_top_resume(struct __cfaehm_try_resume_node ** store) {
+	this_exception_context()->top_resume = *store;
+}
+
 void __cfaehm_throw_resume(exception_t * except) {
 	struct exception_context_t * context = this_exception_context();
@@ -80,4 +84,5 @@
 	__cfaabi_dbg_print_safe("Throwing resumption exception\n");
 
+	__attribute__((cleanup(reset_top_resume)))
 	struct __cfaehm_try_resume_node * original_head = context->top_resume;
 	struct __cfaehm_try_resume_node * current = context->top_resume;
@@ -86,5 +91,4 @@
 		context->top_resume = current->next;
 		if (current->handler(except)) {
-			context->top_resume = original_head;
 			return;
 		}
@@ -92,5 +96,4 @@
 
 	__cfaabi_dbg_print_safe("Unhandled exception\n");
-	context->top_resume = original_head;
 
 	// Fall back to termination:
Index: tests/errors/.expect/completeType.txt
===================================================================
--- tests/errors/.expect/completeType.txt	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ tests/errors/.expect/completeType.txt	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -27,5 +27,5 @@
     void 
   )
-  Environment:( _85_4_DT ) -> instance of struct A with body 0 (no widening)
+  Environment:( _85_2_DT ) -> instance of struct A with body 0 (no widening)
 
 
@@ -50,5 +50,5 @@
     void 
   )
-  Environment:( _85_4_DT ) -> instance of struct B with body 1 (no widening)
+  Environment:( _85_2_DT ) -> instance of struct B with body 1 (no widening)
 
 
Index: tests/exceptions/.expect/interact.txt
===================================================================
--- tests/exceptions/.expect/interact.txt	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ tests/exceptions/.expect/interact.txt	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -14,2 +14,8 @@
 resumption catch, will terminate
 inner termination catch
+
+throwing resume moon
+resumption moon catch, will terminate
+termination catch
+throwing resume star
+resumption star catch
Index: tests/exceptions/.expect/resume.txt
===================================================================
--- tests/exceptions/.expect/resume.txt	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ tests/exceptions/.expect/resume.txt	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -25,2 +25,6 @@
 caught second exception
 recaught first exception
+
+inner catch
+inner catch
+outer catch
Index: tests/exceptions/.expect/terminate.txt
===================================================================
--- tests/exceptions/.expect/terminate.txt	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ tests/exceptions/.expect/terminate.txt	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -24,2 +24,5 @@
 caught second exception
 recaught first exception
+
+inner catch
+outer catch
Index: tests/exceptions/interact.cfa
===================================================================
--- tests/exceptions/interact.cfa	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ tests/exceptions/interact.cfa	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -86,5 +86,4 @@
 		printf("outer terminate catch (error)\n");
 	}
-#if 0
 	printf("\n");
 
@@ -111,4 +110,3 @@
 		printf("outermost catch (error)\n");
 	}
-#endif
 }
Index: tests/exceptions/resume.cfa
===================================================================
--- tests/exceptions/resume.cfa	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ tests/exceptions/resume.cfa	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -99,3 +99,17 @@
 		printf("caught second exception (bad location)\n");
 	}
+	printf("\n");
+
+	// Check successive operations.
+	try {
+		try {
+			THROW_RESUME(&(zen){});
+			THROW_RESUME(&(zen){});
+		} catchResume (zen *) {
+			printf("inner catch\n");
+		}
+		THROW_RESUME(&(zen){});
+	} catchResume (zen *) {
+		printf("outer catch\n");
+	}
 }
Index: tests/exceptions/terminate.cfa
===================================================================
--- tests/exceptions/terminate.cfa	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ tests/exceptions/terminate.cfa	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -99,3 +99,17 @@
 		printf("caught second exception (bad location)\n");
 	}
+	printf("\n");
+
+	// Check successive operations.
+	try {
+		try {
+			THROW(&(zen){});
+			THROW(&(zen){});
+		} catch (zen *) {
+			printf("inner catch\n");
+		}
+		THROW(&(zen){});
+	} catch (zen *) {
+		printf("outer catch\n");
+	}
 }
Index: tools/langserver/src/json.hpp
===================================================================
--- tools/langserver/src/json.hpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
+++ tools/langserver/src/json.hpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -0,0 +1,11 @@
+#pragma once
+
+#include <nlohmann/json.hpp>
+
+namespace json {
+      static inline auto parse(const std::vector<char> & buff) {
+            return nlohmann::json::parse(buff.begin(), buff.end());
+      }
+
+      using obj = nlohmann::json;
+}
Index: tools/langserver/src/log.cpp
===================================================================
--- tools/langserver/src/log.cpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
+++ tools/langserver/src/log.cpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -0,0 +1,24 @@
+#include "log.hpp"
+
+#include <iostream>
+#include <fstream>
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
+
+int g_argc;
+char** g_argv;
+
+static std::ofstream create() {
+      struct passwd *pw = getpwuid(getuid());
+      const char *homedir = pw->pw_dir;
+
+      std::string target = std::string(homedir) + "/.cfa-ls.log";
+      return std::ofstream{ target };
+}
+
+std::ostream & log() {
+      static std::ofstream log = create();
+      return log;
+}
Index: tools/langserver/src/log.hpp
===================================================================
--- tools/langserver/src/log.hpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
+++ tools/langserver/src/log.hpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -0,0 +1,7 @@
+#pragma once
+
+#include <iostream>
+
+extern std::ostream & log();
+extern int g_argc;
+extern char** g_argv;
Index: tools/langserver/src/main.cpp
===================================================================
--- tools/langserver/src/main.cpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
+++ tools/langserver/src/main.cpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -0,0 +1,120 @@
+#include <cstdio>
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <unistd.h>
+
+#include "json.hpp"
+#include "log.hpp"
+#include "server.hpp"
+
+static void request(std::vector<char> & buf);
+static void reply(const json::obj & );
+
+json::obj noop( const json::obj & ) {
+	return {};
+}
+
+std::unordered_map<std::string, json::obj (*)( const json::obj & )> actions {
+	{ "initialize", server::init },
+	{ "initialized", noop }
+};
+
+int main(int argc, char * argv[]) {
+	g_argc = argc;
+	g_argv = argv;
+
+	log() << "Language Server called with args:" << std::endl;
+	for(int i = 0; i < argc; i++) {
+		log() << "\t- " << argv[i] << std::endl;
+	}
+
+	// std::cout.setf(std::ios::unitbuf);
+
+	// char buff[1000];
+	// int r = 0;
+	// while(0 != (r = read(STDIN_FILENO, buff, 1000))) {
+	// 	for(int i = 0; i < r; i++) {
+	// 		log() << buff[i];
+	// 	}
+	// }
+	// log() << std::endl;
+
+	// return 0;
+
+	std::vector<char> buffer;
+	while(true) {
+		request(buffer);
+		if(buffer.size() == 0) break;
+
+		auto top = json::parse(buffer);
+
+		auto action = actions.find( top["method"] );
+		if(action != actions.end()) {
+			log() << "Executing request '" << action->first << "'" << std::endl;
+			json::obj response = {
+				{"id", top["id"] }
+			};
+
+			try{
+				response["result"] = action->second( top["params"] );
+			} catch( const json::obj & error ) {
+				response["result"] = "";
+				response["error"] = error;
+			}
+
+			reply(response);
+		}
+		else {
+			log() << "WARNING no action for method '" << top["method"].dump(4) << "'" << std::endl;
+		}
+	}
+
+	log() << "Language Server closing after end of file" << std::endl;
+
+	return 0;
+}
+
+static void request(std::vector<char> & buffer) {
+	std::string lenstr;
+	std::getline( std::cin, lenstr );
+	if(std::cin.eof()) { buffer.clear(); return; };
+
+	if (lenstr.rfind("Content-Length: ", 0) != 0) {
+		log() << "Expected content length bug got '" << lenstr << "' instead " << std::endl;
+		std::exit(EXIT_FAILURE);
+	}
+
+	size_t idx = sizeof("Content-Length:");
+	size_t end;
+	size_t len = std::stoul(lenstr.substr(idx), &end);
+	if(lenstr.length() != (idx + end + 1)) {
+		log() << "Inconsistent size of integer in content length: " << lenstr.length() << " vs " << (idx + end) << std::endl;
+	}
+
+	log() << "New request of " << len << " bytes" << std::endl;
+	buffer.resize( len + 2 );
+	std::cin.read(buffer.data(), buffer.size());
+
+	for(char c : buffer) {
+		log() << c;
+	}
+	log() << std::endl;
+	return;
+}
+
+static void reply( const json::obj & response) {
+	if(response["result"].is_null()) {
+		log() << "No response needed" << std::endl;
+		return;
+	}
+
+	log() << "Responding with : " << response.dump(4) << std::endl;
+	const std::string & r = response.dump();
+	std::cout << "Content-Length: " << r.length() << "\r\n\r\n";
+	std::cout.flush();
+	std::cout  << r << "\r\n";
+	std::cout.flush();
+}
Index: tools/langserver/src/server.cpp
===================================================================
--- tools/langserver/src/server.cpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
+++ tools/langserver/src/server.cpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -0,0 +1,47 @@
+#include "server.hpp"
+#include "log.hpp"
+
+namespace server {
+      class server {
+      public:
+            void check_ready() {
+                  if(!ready) {
+                        throw json::obj({
+                              { "code", -32002 },
+                              { "message", "Server not initialized" }
+                        });
+                  }
+            }
+
+            void init() { ready = true; };
+      private:
+            bool ready = false;
+
+      };
+
+      static server g_server;
+
+      json::obj init( const json::obj & ) {
+            g_server.init();
+		return {
+			{ "capabilities", {
+                        {"textDocumentSync", {
+                              {"openClose", true},
+                              {"change", 1}
+                        }},
+                        {"documentHighlightProvider", {
+                              {"workDoneProgress", false}
+                        }},
+                        {"completionProvider", {
+                              {"triggerCharacters", json::obj::array()},
+                              {"allCommitCharacters", json::obj::array()},
+                              {"resolveProvider", true}
+                        }}
+                  } },
+			{ "serverInfo", {
+				{ "name", "Cforall Language Server" },
+				{ "version", "0.1" }
+			}}
+		};
+	}
+}
Index: tools/langserver/src/server.hpp
===================================================================
--- tools/langserver/src/server.hpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
+++ tools/langserver/src/server.hpp	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "json.hpp"
+
+namespace server {
+	json::obj init(const json::obj & );
+};
Index: tools/vscode/uwaterloo.cforall-0.1.0/client/main.js
===================================================================
--- tools/vscode/uwaterloo.cforall-0.1.0/client/main.js	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
+++ tools/vscode/uwaterloo.cforall-0.1.0/client/main.js	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -0,0 +1,56 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+// The module 'vscode' contains the VS Code extensibility API
+// Import the module and reference it with the alias vscode in your code below
+const path = require("path");
+const vscode = require("vscode");
+
+
+const vscode_lc = require('vscode-languageclient');
+
+let client = {}
+
+// this method is called when your extension is activated
+// your extension is activated the very first time the command is executed
+function activate(context) {
+	vscode.window.showInformationMessage('Cforall Extension Starting');
+
+	// The debug options for the server
+	// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
+	let debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
+
+	// If the extension is launched in debug mode then the debug server options are used
+	// Otherwise the run options are used
+	let serverOptions = {
+		run: { command: 'cfa-ls', transport: vscode_lc.TransportKind.stdio },
+		debug: {
+			command: 'cfa-ls',
+			transport: vscode_lc.TransportKind.stdio,
+			options: debugOptions
+		}
+	};
+
+	// Options to control the language client
+	let selector = [{ scheme: 'file', language: 'cforall' }];
+	let clientOptions = {
+		// Register the server for cforall documents
+		documentSelector: selector
+	};
+
+	// Create the language client and start the client.
+	client = new vscode_lc.LanguageClient(
+		'cforall',
+		'Cforall Language Server',
+		serverOptions,
+		clientOptions
+	);
+
+	// Start the client. This will also launch the server
+	client.start();
+
+}
+exports.activate = activate;
+
+// this method is called when your extension is deactivated
+function deactivate() { }
+exports.deactivate = deactivate;
Index: tools/vscode/uwaterloo.cforall-0.1.0/package.json
===================================================================
--- tools/vscode/uwaterloo.cforall-0.1.0/package.json	(revision 23ecea4b78bd072667005ab5346894709e66b7ef)
+++ tools/vscode/uwaterloo.cforall-0.1.0/package.json	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -15,4 +15,8 @@
 		"Other"
 	],
+	"activationEvents": [
+		"onLanguage:cforall"
+	],
+	"main": "./client/main.js",
 	"contributes": {
 		"languages": [
@@ -39,5 +43,34 @@
 				"path": "./syntaxes/cfa.tmLanguage.json"
 			}
-		]
+		],
+		"configuration": {
+			"type": "object",
+			"title": "Example configuration",
+			"properties": {
+				"cforall.maxNumberOfProblems": {
+					"scope": "resource",
+					"type": "number",
+					"default": 100,
+					"description": "Controls the maximum number of problems produced by the server."
+				},
+				"cforall.trace.server": {
+					"scope": "window",
+					"type": "string",
+					"enum": [
+						"off",
+						"messages",
+						"verbose"
+					],
+					"default": "off",
+					"description": "Traces the communication between VS Code and the language server."
+				}
+			}
+		}
+	},
+	"dependencies": {
+		"vscode-languageclient": "^4.1.4"
+	},
+	"devDependencies": {
+		"vscode-languageclient": "^4.1.4"
 	}
 }
Index: tools/vscode/uwaterloo.cforall-0.1.0/server/out/server
===================================================================
--- tools/vscode/uwaterloo.cforall-0.1.0/server/out/server	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
+++ tools/vscode/uwaterloo.cforall-0.1.0/server/out/server	(revision e276be6a8916de2345a6b39ef103c6499a9f7f6e)
@@ -0,0 +1,1 @@
+../../../ls
