Permalink
Browse files

again

  • Loading branch information...
1 parent 083883d commit d258158ebe8480ade8beb66f1abaa199877c7e48 @drewlesueur committed Mar 3, 2013
Showing with 50 additions and 0 deletions.
  1. +50 −0 drews_lang_2.js
View
@@ -0,0 +1,50 @@
+// Possible todo:
+// scope chains
+// macro
+//implement map
+poor_module("drews_lang", function () {
+ var to_string = Object.prototype.toString
+ var is_array = function (a) { return to_string.call(a) == '[object Array]' }
+ var is_function = function (obj) { return typeof obj === 'function'; }
+ var is_string = function (a) { return to_string.call(a) == '[object String]' }
+ var drews_expression = poor_module("drews_express")
+
+
+ var commands = {
+ alert: function (args) {
+ alert(args[0])
+ }, say: function (args) {
+ console.log(args[0])
+ }
+ }
+
+ var to_linked_list = function (list, list_i, linked_list) {
+ if (list_i == list.length) {
+ return linked_list
+ } else {
+ var item = list[list_i]
+
+ }
+ }
+
+ var evaluate = function (raw_code, _scope) {
+ scope = _scope || {}
+ if (is_array(raw_code)) {
+ code = raw_code
+ } else {
+ code = drews_expression(raw_code)
+ code = to_linked_list(raw_code)
+ }
+ code = macro_expand(code)
+ i = 0;
+ code.push(return_cmd);
+ while (true) {
+ if (i >= code.length) {break}
+ line = code[i]
+ debugger
+ eval_line();
+ }
+ return ret_val
+ }
+ return evaluate;
+})

0 comments on commit d258158

Please sign in to comment.