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
4a5941c
commit 2f368dc
Showing
3 changed files
with
45 additions
and
69 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) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
@@ -20,7 +8,7 @@ | |
|
||
(defun keyword-parser (symbol) | ||
(singleton (constantly symbol) | ||
(lambda (token) (symbol-equal symbol token)))) | ||
(lambda (token) (symbol-equal symbol token)))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
|
@@ -39,7 +27,7 @@ | |
|
||
(define-parser each-the-parser | ||
(alternative (keyword-parser 'each) | ||
(keyword-parser 'the))) | ||
(keyword-parser 'the))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
|
@@ -48,7 +36,7 @@ | |
|
||
(define-parser in-of-parser | ||
(alternative (keyword-parser 'in) | ||
(keyword-parser 'of))) | ||
(keyword-parser 'of))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
|
@@ -65,9 +53,9 @@ | |
|
||
(define-parser compound+ | ||
(repeat+ (lambda (&rest forms) | ||
(cons 'progn forms)) | ||
(singleton #'identity #'consp))) | ||
(cons 'progn forms)) | ||
(singleton #'identity #'consp))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
;;; This parser succeeds whenever the list of tokens is either empty | ||
|
@@ -92,8 +80,8 @@ | |
|
||
(defun non-clause-keyword (tokens) | ||
(if (or (null tokens) | ||
(member (car tokens) *clause-keywords* | ||
:test #'symbol-equal)) | ||
(member (car tokens) *clause-keywords* | ||
:test #'symbol-equal)) | ||
(values t nil tokens) | ||
(values nil nil tokens))) | ||
|
||
|
@@ -111,11 +99,11 @@ | |
|
||
(defun parse-clause (tokens) | ||
(loop for parser in *clause-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)))) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;;; | ||
|
@@ -132,14 +120,14 @@ | |
;;; Create a list of clauses from the body of the LOOP form. | ||
(defun parse-loop-body (body) | ||
(let ((remaining-body body) | ||
(clauses '())) | ||
(clauses '())) | ||
(loop until (null remaining-body) | ||
do (multiple-value-bind (success-p clause rest) | ||
(parse-clause remaining-body) | ||
(if success-p | ||
(progn (setf remaining-body rest) | ||
(push clause clauses)) | ||
;; FIXME: this is not the right error to signal. | ||
(error 'expected-keyword-but-found | ||
:found (car rest))))) | ||
do (multiple-value-bind (success-p clause rest) | ||
(parse-clause remaining-body) | ||
(if success-p | ||
(progn (setf remaining-body rest) | ||
(push clause clauses)) | ||
;; FIXME: this is not the right error to signal. | ||
(error 'expected-keyword-but-found | ||
:found (car rest))))) | ||
(reverse clauses))) |
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
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) 2015 | ||
;;;; | ||
;;;; 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) | ||
|
||
;;; Recall that in the dictionary entry for LOOP, the HyperSpec says: | ||
|
@@ -46,19 +34,19 @@ | |
|
||
(define-parser selectable-clause-parser | ||
(alternative 'do-clause-parser | ||
'return-clause-parser | ||
'collect-clause-parser | ||
'append-clause-parser | ||
'nconc-clause-parser | ||
'count-clause-parser | ||
'sum-clause-parser | ||
'maximize-clause-parser | ||
'minimize-clause-parser | ||
'conditional-clause-parser)) | ||
'return-clause-parser | ||
'collect-clause-parser | ||
'append-clause-parser | ||
'nconc-clause-parser | ||
'count-clause-parser | ||
'sum-clause-parser | ||
'maximize-clause-parser | ||
'minimize-clause-parser | ||
'conditional-clause-parser)) | ||
|
||
(define-parser and-selectable-clause-parser | ||
(consecutive (lambda (and selectable-clause) | ||
(declare (ignore and)) | ||
selectable-clause) | ||
(keyword-parser 'and) | ||
'selectable-clause-parser)) | ||
(declare (ignore and)) | ||
selectable-clause) | ||
(keyword-parser 'and) | ||
'selectable-clause-parser)) |