Skip to content

Commit

Permalink
TRANSIENT about 60 pct of the fix for shadowing module level bindings…
Browse files Browse the repository at this point in the history
…. Still remaining: shadowing the bindings made by function arguments.
  • Loading branch information
VincentToups committed Apr 8, 2013
1 parent 5d0b037 commit 545a202
Show file tree
Hide file tree
Showing 4 changed files with 437 additions and 291 deletions.
35 changes: 27 additions & 8 deletions proper.el
Expand Up @@ -192,13 +192,13 @@
(defun-match proper:to-prim ((list (or '_function 'function)
(prim:argument-list args) (tail body)))
`(_function ,(mapcar #'proper:to-prim args)
,@(mapcar #'proper:to-prim body)))
,@(proper:newline-seq-body->prim body)))

(defun-match proper:to-prim ((list (or '_function 'function)
(non-kw-symbol name)
(prim:argument-list args) (tail body)))
`(_function ,name ,(mapcar #'proper:to-prim args)
,@(mapcar #'proper:to-prim body)))
,@(proper:newline-seq-body->prim body)))

(defun-match proper:to-prim ((list '_return expr))
`(_return ,(proper:to-prim expr)))
Expand All @@ -209,18 +209,18 @@

(defun-match proper:to-prim ((list-rest '_while expression body))
`(_while ,(proper:to-prim expression)
,@(proper:map-to-prim body)))
,@(proper:newline-seq-body->prim body)))

(defun-match proper:to-prim ((list-rest (or 'for '_for)
(list (non-kw-symbol name)
(or 'in :in '_in) expression)
body))
`(_for (,(proper:to-prim name) _in ,(proper:to-prim expression))
,@(proper:map-to-prim body)))
,@(proper:newline-seq-body->prim body)))

(defun-match proper:to-prim ((list-rest (or 'for '_for) (and control
(list init cond update)) body))
`(_for ,(proper:map-to-prim control) ,@(proper:map-to-prim body)))
`(_for ,(proper:map-to-prim control) ,@(proper:newline-seq-body->prim body)))

(defun-match proper:to-prim ((list '_throw expr))
`(_throw ,(proper:to-prim expr)))
Expand Down Expand Up @@ -337,8 +337,27 @@
(defun-match proper:to-prim ((list '_comma-sequence (tail exprs)))
`(_comma-sequence ,@(proper:map-to-prim exprs)))

(defun-match- proper:newline-seq-body->prim ((list) acc)
(reverse acc))

(defun-match proper:newline-seq-body->prim ((list (list (or 'var '_var) (proper:symbol-macro s1) v1 (tail var-body))
(tail rest))
acc)
(let ((proper:symbol-macros (cons (make-hash-table) proper:symbol-macros))
(alias (intern (concat (symbol-name s1) (symbol-name (gensym))))))
(proper:add-to-symbol-macro-context s1 `(lambda (s) ',alias))
(proper:to-prim
`((_var ,alias ,v1) ,@(if var-body `((_var ,@var-body)) nil) ,@rest))))

(defun-match proper:newline-seq-body->prim ((list anything-else (tail rest))
acc)
(recur rest (cons (proper:to-prim anything-else) acc)))

(defun-match proper:newline-seq-body->prim (v)
(recur v nil))

(defun-match proper:to-prim ((list '_newline-sequence (tail exprs)))
`(_newline-sequence ,@(proper:map-to-prim exprs)))
`(_newline-sequence ,@(proper:newline-seq-body->prim exprs)))

(defun-match proper:to-prim ([(or '_: ':) (tail elements)])
(coerce `(_: ,@(proper:map-to-prim elements)) 'vector))
Expand Down Expand Up @@ -1255,7 +1274,7 @@
(match body
((list patternette (tail real-body))
`([: ,@patternette]
,@real-body))))
(_newline-sequence ,@real-body)))))
bodies)
(,anything-else
(_throw (_+ ,(format "Match fail in %S against: "
Expand Down Expand Up @@ -1701,7 +1720,7 @@
(_proper:macro-context
,@(loop for spec in specs collect
`(_proper:require-spec ,@spec))
,@body))))
(_newline-sequence ,@body)))))


(defvar proper:*node-rjs-root* nil)
Expand Down
8 changes: 7 additions & 1 deletion scratch.gazelle
@@ -1 +1,7 @@
"\\"
(require
(("hooves/hooves" :all))

(var range 10)
range)


10 changes: 9 additions & 1 deletion scratch.js
@@ -1 +1,9 @@
"\\";
require(["hooves/hooves"], (function (module4745e9d952) {
return (function (arguments) {
// ("hooves/hooves" :all)
;
var rangeG111958 = 10;
return rangeG111958;
;
}).call(this, (((((typeof arguments))===("undefined")))?(undefined) : (arguments)));
}));

0 comments on commit 545a202

Please sign in to comment.