Permalink
Browse files

add standard library and console example

  • Loading branch information...
1 parent 70583f6 commit d3b535d666ff44caa558c33aa96d6771aa0d85c4 @jlongster committed Apr 23, 2012
View
@@ -0,0 +1,3 @@
+[submodule "stdlib"]
+ path = stdlib
+ url = git@github.com:jlongster/stdlib.git
View
@@ -4,7 +4,8 @@ var fs = require('fs');
var comp = require("../compiler.js");
var args = process.argv.slice(2);
-var src;
+var src = false;
+var file = false;
var expand = false;
var compiled1 = false;
var compiled2 = false;
@@ -41,7 +42,7 @@ if (args[0] == '-e') {
args = args.slice(2);
}
else {
- src = fs.readFileSync(args[0], 'utf-8');
+ file = args[0];
args = args.slice(1);
}
@@ -60,6 +61,9 @@ else if(compiled3) {
else if(linearized) {
comp["print-linearized"](src);
}
+else if(file) {
+ comp["compile-file"](file);
+}
else {
comp.compile(src);
}
View
@@ -2182,10 +2182,10 @@ add_dash_to_dash_globals("\uFDD1__exit");
var _per_current_dash_filepath = false;
var get_dash_current_dash_filepath = (function() {return _per_current_dash_filepath;
});
-var compile_dash_file = (function(path){
+var compile_dash_file = (function(file){
var rest = vector_dash__gt_list(Array.prototype.slice.call(arguments, 1));
-_per_current_dash_filepath = path;
-return apply(compile_dash_program,cons(fs["readFileSync"](path,"utf-8"),rest));
+_per_current_dash_filepath = path["dirname"](file);
+return apply(compile_dash_program,cons(fs["readFileSync"](file,"utf-8"),rest));
});
var compile_dash_program = (function(src){
var rest = vector_dash__gt_list(Array.prototype.slice.call(arguments, 1));
View
@@ -1136,11 +1136,11 @@
(define (get-current-filepath)
%current-filepath)
-(define (compile-file path . rest)
- (set! %current-filepath path)
+(define (compile-file file . rest)
+ (set! %current-filepath (path.dirname file))
(apply
compile-program
- (cons (fs.readFileSync path "utf-8") rest)))
+ (cons (fs.readFileSync file "utf-8") rest)))
(define (compile-program src . rest)
;; read the source and force it into a begin expression
Oops, something went wrong.

0 comments on commit d3b535d

Please sign in to comment.