diff tpc.js @ 44:9dd370530f69

Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
author Mike Pavone <pavone@retrodev.com>
date Thu, 12 Jul 2012 22:49:08 -0700
parents 27a2167663dd
children 2a9c6eed0c70
line wrap: on
line diff
--- a/tpc.js	Thu Jul 12 22:10:58 2012 -0700
+++ b/tpc.js	Thu Jul 12 22:49:08 2012 -0700
@@ -20,26 +20,19 @@
 		var parsed = parser.parse(text);
 		var c = parsed.toCModule();
 		print(c);
-	} catch(error) {
-		if (error.name == 'SyntaxError') {
-			print('SyntaxError on at', error.line, ',', error.column, ':', error.message);
-			var lines = text.split('\n');
-			print(lines[error.line-1]);
-			var spacer = '';
-			for (var i = 1; i < error.column; i++) {
-				if (lines[error.line-1].charAt(i-1) == '\t') {
-					spacer += '    ';
-				} else {
-					spacer += ' ';
-				}
-			}
-			print(spacer + '^');
-		} else {
-			print("Exception:");
-			var keys = Object.keys(error);
-			for (var i = 0; i < keys.length; ++i) {
-				print('\t', keys[i], error[keys[i]]);
+	} catch(error if error.name == 'SyntaxError') {
+		print('SyntaxError on at', error.line, ',', error.column, ':', error.message);
+		var lines = text.split('\n');
+		print(lines[error.line-1]);
+		var spacer = '';
+		for (var i = 1; i < error.column; i++) {
+			if (lines[error.line-1].charAt(i-1) == '\t') {
+				spacer += '    ';
+			} else {
+				spacer += ' ';
 			}
 		}
+		print(spacer + '^');
+
 	}
 }