-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(in-package :micros/walker) | ||
|
||
(defclass defun-form (ast) | ||
((name :initarg :name | ||
:type variable-symbol | ||
:reader ast-name) | ||
(lambda-list :initarg :lambda-list | ||
:reader ast-lambda-list) | ||
(body :initarg :body | ||
:type implict-progn-form | ||
:reader ast-body))) | ||
|
||
(defmethod walk-form ((walker walker) (name (eql 'defun)) form env path) | ||
(with-walker-bindings (name lambda-list &body body) (rest form) | ||
(multiple-value-bind (lambda-list env) | ||
(walk-lambda-list walker lambda-list env (cons 2 path)) | ||
;; TODO: declare | ||
(make-instance 'defun-form | ||
:name name | ||
:lambda-list lambda-list | ||
:body (make-instance 'implict-progn-form | ||
:forms (walk-forms walker body env path 3)) | ||
:path (cons 0 path))))) | ||
|
||
(defmethod visit (visitor (ast defun-form)) | ||
(visit visitor (ast-lambda-list ast)) | ||
(visit visitor (ast-body ast))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(defpackage :micros/walker | ||
(:use :cl) | ||
(:export :collect-highlight-paths)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(in-package :micros/walker) | ||
|
||
(eval-when (:compile-toplevel :load-toplevel :execute) | ||
(defun proper-list-p (x) | ||
(and (listp x) | ||
(null (cdr (last x)))))) | ||
|
||
(deftype proper-list (&optional (element-type '*)) | ||
(declare (ignore element-type)) | ||
'(and list (satisfies proper-list-p))) | ||
|
||
(deftype variable-symbol () | ||
'(and symbol (not keyword))) | ||
|
||
(deftype non-list () | ||
'(and (not null) (not list))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters