Skip to content

Commit

Permalink
Remove copyright notice and untabify.
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-strandh committed Oct 1, 2020
1 parent 4a5941c commit 2f368dc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 69 deletions.
56 changes: 22 additions & 34 deletions Code/Loop/parse-common.lisp
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)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand All @@ -20,7 +8,7 @@

(defun keyword-parser (symbol)
(singleton (constantly symbol)
(lambda (token) (symbol-equal symbol token))))
(lambda (token) (symbol-equal symbol token))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
Expand All @@ -39,7 +27,7 @@

(define-parser each-the-parser
(alternative (keyword-parser 'each)
(keyword-parser 'the)))
(keyword-parser 'the)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
Expand All @@ -48,7 +36,7 @@

(define-parser in-of-parser
(alternative (keyword-parser 'in)
(keyword-parser 'of)))
(keyword-parser 'of)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
Expand All @@ -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
Expand All @@ -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)))

Expand All @@ -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))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
Expand All @@ -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)))
20 changes: 10 additions & 10 deletions Code/Loop/run-time-support.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
(defun sum (x y)
(unless (numberp y)
(error 'sum-argument-must-be-number
:datum y))
:expected-type 'number
:datum y))
:expected-type 'number
(+ x y))

;;; This function is called in a MAX clause in order to compute the
;;; max of the accumulated value and the new one.
(defun maximize (x y)
(unless (realp y)
(error 'max-argument-must-be-real
:datum y))
:expected-type 'real
:datum y))
:expected-type 'real
(max x y))

;;; This function is called in a MIN clause in order to compute the
;;; min of the accumulated value and the new one.
(defun minimize (x y)
(unless (realp y)
(error 'min-argument-must-be-real
:datum y))
:expected-type 'real
:datum y))
:expected-type 'real
(min x y))

;;; This function is called during restructuring to compute the CAR of
Expand All @@ -34,8 +34,8 @@
(if (listp x)
(car x)
(error 'value-must-be-list
:datum x
:expected-type 'list)))
:datum x
:expected-type 'list)))

;;; This function is called during restructuring to compute the CDR of
;;; some value. If that value turns out not to be a LIST, then an
Expand All @@ -44,5 +44,5 @@
(if (listp x)
(cdr x)
(error 'value-must-be-list
:datum x
:expected-type 'list)))
:datum x
:expected-type 'list)))
38 changes: 13 additions & 25 deletions Code/Loop/selectable-clause.lisp
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:
Expand Down Expand Up @@ -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))

0 comments on commit 2f368dc

Please sign in to comment.