forked from robert-strandh/SICL
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove copyright notice and untabify.
- Loading branch information
1 parent
c87f9f7
commit aa012ed
Showing
3 changed files
with
226 additions
and
262 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 |
---|---|---|
@@ -1,15 +1,3 @@ | ||
;;;; Copyright (c) 2014 | ||
;;;; | ||
;;;; Robert Strandh ([email protected]) | ||
;;;; | ||
;;;; all rights reserved. | ||
;;;; | ||
;;;; Permission is hereby granted to use this software for any | ||
;;;; purpose, including using, modifying, and redistributing it. | ||
;;;; | ||
;;;; The software is provided "as-is" with no warranty. The user of | ||
;;;; this software assumes any responsibility of the consequences. | ||
|
||
(cl:in-package #:sicl-loop) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
@@ -60,8 +48,8 @@ | |
|
||
(defmethod bound-variables ((clause for-as-clause)) | ||
(reduce #'append | ||
(mapcar #'bound-variables (subclauses clause)) | ||
:from-end t)) | ||
(mapcar #'bound-variables (subclauses clause)) | ||
:from-end t)) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
|
@@ -77,30 +65,30 @@ | |
|
||
(defun for-as-subclause-parser (tokens) | ||
(loop for parser in *for-as-subclause-parsers* | ||
do (multiple-value-bind (successp result rest) | ||
(funcall parser tokens) | ||
(when successp | ||
(return (values t result rest)))) | ||
finally (return (values nil nil tokens)))) | ||
do (multiple-value-bind (successp result rest) | ||
(funcall parser tokens) | ||
(when successp | ||
(return (values t result rest)))) | ||
finally (return (values nil nil tokens)))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
;;; Parse a FOR-AS clause. | ||
|
||
(define-parser for-as-clause-parser | ||
(consecutive (lambda (for subclause more-subclauses) | ||
(declare (ignore for)) | ||
(make-instance 'for-as-clause | ||
:subclauses (cons subclause more-subclauses))) | ||
(alternative (keyword-parser 'for) | ||
(keyword-parser 'as)) | ||
'for-as-subclause-parser | ||
(repeat* #'list | ||
(consecutive (lambda (and subclause) | ||
(declare (ignore and)) | ||
subclause) | ||
(keyword-parser 'and) | ||
'for-as-subclause-parser)))) | ||
(declare (ignore for)) | ||
(make-instance 'for-as-clause | ||
:subclauses (cons subclause more-subclauses))) | ||
(alternative (keyword-parser 'for) | ||
(keyword-parser 'as)) | ||
'for-as-subclause-parser | ||
(repeat* #'list | ||
(consecutive (lambda (and subclause) | ||
(declare (ignore and)) | ||
subclause) | ||
(keyword-parser 'and) | ||
'for-as-subclause-parser)))) | ||
|
||
(add-clause-parser 'for-as-clause-parser) | ||
|
||
|
@@ -114,46 +102,46 @@ | |
|
||
(defmethod initial-bindings ((clause for-as-clause)) | ||
(reduce #'append (mapcar #'initial-bindings (subclauses clause)) | ||
:from-end t)) | ||
:from-end t)) | ||
|
||
(defmethod final-bindings ((clause for-as-clause)) | ||
(reduce #'append (mapcar #'final-bindings (subclauses clause)) | ||
:from-end t)) | ||
:from-end t)) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
;;; Compute the declarations. | ||
|
||
(defmethod declarations ((clause for-as-clause)) | ||
(reduce #'append (mapcar #'declarations (subclauses clause)) | ||
:from-end t)) | ||
:from-end t)) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
;;; Compute the prologue-form. | ||
|
||
(defmethod prologue-form ((clause for-as-clause) end-tag) | ||
`(progn ,@(mapcar (lambda (subclause) | ||
(prologue-form subclause end-tag)) | ||
(subclauses clause)))) | ||
(prologue-form subclause end-tag)) | ||
(subclauses clause)))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
;;; Compute the termination-form. | ||
|
||
(defmethod termination-form ((clause for-as-clause) end-tag) | ||
`(progn ,@(mapcar (lambda (subclause) | ||
(termination-form subclause end-tag)) | ||
(subclauses clause)))) | ||
(termination-form subclause end-tag)) | ||
(subclauses clause)))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
;;; Compute the body-form. | ||
|
||
(defmethod body-form ((clause for-as-clause) end-tag) | ||
`(progn ,@(mapcar (lambda (clause) | ||
(body-form clause end-tag)) | ||
(subclauses clause)))) | ||
(body-form clause end-tag)) | ||
(subclauses clause)))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
|
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 |
---|---|---|
@@ -1,15 +1,3 @@ | ||
;;;; Copyright (c) 2014 | ||
;;;; | ||
;;;; Robert Strandh ([email protected]) | ||
;;;; | ||
;;;; all rights reserved. | ||
;;;; | ||
;;;; Permission is hereby granted to use this software for any | ||
;;;; purpose, including using, modifying, and redistributing it. | ||
;;;; | ||
;;;; The software is provided "as-is" with no warranty. The user of | ||
;;;; this software assumes any responsibility of the consequences. | ||
|
||
(cl:in-package #:sicl-loop) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
@@ -22,41 +10,41 @@ | |
|
||
(defmethod bound-variables ((subclause for-as-equals-then)) | ||
(mapcar #'car | ||
(extract-variables (var-spec subclause) nil))) | ||
(extract-variables (var-spec subclause) nil))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
;;; Parsers. | ||
|
||
(define-parser for-as-equals-then-parser-1 | ||
(consecutive (lambda (var-spec type-spec = form1 then form2) | ||
(declare (ignore = then)) | ||
(make-instance 'for-as-equals-then | ||
:var-spec var-spec | ||
:type-spec type-spec | ||
:initial-form form1 | ||
:subsequent-form form2)) | ||
;; Accept anything for now. Analyze later. | ||
'anything-parser | ||
'optional-type-spec-parser | ||
(keyword-parser '=) | ||
'anything-parser | ||
(keyword-parser 'then) | ||
'anything-parser)) | ||
(declare (ignore = then)) | ||
(make-instance 'for-as-equals-then | ||
:var-spec var-spec | ||
:type-spec type-spec | ||
:initial-form form1 | ||
:subsequent-form form2)) | ||
;; Accept anything for now. Analyze later. | ||
'anything-parser | ||
'optional-type-spec-parser | ||
(keyword-parser '=) | ||
'anything-parser | ||
(keyword-parser 'then) | ||
'anything-parser)) | ||
|
||
(define-parser for-as-equals-then-parser-2 | ||
(consecutive (lambda (var-spec type-spec = form1) | ||
(declare (ignore =)) | ||
(make-instance 'for-as-equals-then | ||
:var-spec var-spec | ||
:type-spec type-spec | ||
:initial-form form1 | ||
:subsequent-form form1)) | ||
;; Accept anything for now. Analyze later. | ||
'anything-parser | ||
'optional-type-spec-parser | ||
(keyword-parser '=) | ||
'anything-parser)) | ||
(declare (ignore =)) | ||
(make-instance 'for-as-equals-then | ||
:var-spec var-spec | ||
:type-spec type-spec | ||
:initial-form form1 | ||
:subsequent-form form1)) | ||
;; Accept anything for now. Analyze later. | ||
'anything-parser | ||
'optional-type-spec-parser | ||
(keyword-parser '=) | ||
'anything-parser)) | ||
|
||
;;; Make sure parser 1 is tried first. For that, it must be added | ||
;;; last. | ||
|
@@ -69,19 +57,19 @@ | |
|
||
(defmethod initial-bindings ((clause for-as-equals-then)) | ||
(loop with d-var-spec = (var-spec clause) | ||
with d-type-spec = (type-spec clause) | ||
for (variable) in (extract-variables d-var-spec d-type-spec) | ||
collect `(,variable nil))) | ||
with d-type-spec = (type-spec clause) | ||
for (variable) in (extract-variables d-var-spec d-type-spec) | ||
collect `(,variable nil))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
;;; Compute the declarations. | ||
|
||
(defmethod declarations ((clause for-as-equals-then)) | ||
(loop with d-var-spec = (var-spec clause) | ||
with d-type-spec = (type-spec clause) | ||
for (variable type) in (extract-variables d-var-spec d-type-spec) | ||
collect `(cl:type (or null ,type) ,variable))) | ||
with d-type-spec = (type-spec clause) | ||
for (variable type) in (extract-variables d-var-spec d-type-spec) | ||
collect `(cl:type (or null ,type) ,variable))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
|
@@ -93,8 +81,8 @@ | |
(fresh-variables (var-spec clause)) | ||
`(let* ,(destructure-variables temp-tree (initial-form clause)) | ||
(setq ,@(loop for (original . temp) in dictionary | ||
collect original | ||
collect temp))))) | ||
collect original | ||
collect temp))))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
|
@@ -105,5 +93,5 @@ | |
(fresh-variables (var-spec clause)) | ||
`(let* ,(destructure-variables temp-tree (subsequent-form clause)) | ||
(setq ,@(loop for (original . temp) in dictionary | ||
collect original | ||
collect temp))))) | ||
collect original | ||
collect temp))))) |
Oops, something went wrong.