(define clause-pattern
(let ((clause-pattern* (lambda args (apply clause-pattern args))))
(spar-or
- (spar-push-elt-if identifier? spar-arg:form)
- (spar-elt
+ (spar-push-subform-if identifier? spar-arg:form)
+ (spar-subform
(spar-call-with-values list
(spar-or
- (spar-and (spar-push-elt-if spar-arg:compare 'or spar-arg:form)
+ (spar-and (spar-push-subform-if spar-arg:compare 'or spar-arg:form)
(spar* clause-pattern*)
(spar-match-null))
- (spar-and (spar-push-elt-if spar-arg:compare 'and spar-arg:form)
+ (spar-and (spar-push-subform-if spar-arg:compare 'and spar-arg:form)
(spar* clause-pattern*)
(spar-match-null))
- (spar-and (spar-push-elt-if spar-arg:compare 'not spar-arg:form)
+ (spar-and (spar-push-subform-if spar-arg:compare 'not spar-arg:form)
clause-pattern*
(spar-match-null))))))))
`((values compare)
(scons-call keyword:define name value)))
(scons-rule
`((spar
- ,(spar-elt
- (spar-push-elt-if identifier? spar-arg:form)
+ ,(spar-subform
+ (spar-push-subform-if identifier? spar-arg:form)
(spar-push-form-if mit-lambda-list? spar-arg:form)))
(+ any))
(lambda (name bvl body-forms)
(apply scons-named-lambda (cons name bvl) body-forms))))
(scons-rule
`((spar
- ,(spar-elt
- (spar-push-elt)
+ ,(spar-subform
+ (spar-push-subform)
(spar-push-form-if mit-lambda-list? spar-arg:form)))
(+ any))
(lambda (nested bvl body-forms)
(seq-item ctx
(map-in-order (lambda (p) (p))
deferred-items)))
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar* (spar-elt spar-push-deferred-classified))
+ (spar* (spar-subform spar-push-deferred-classified))
(spar-match-null)))))
(define :if
(spar-classifier->runtime
(delay
(spar-call-with-values if-item
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-elt spar-push-classified)
- (spar-elt spar-push-classified)
- (spar-or (spar-elt spar-push-classified)
+ (spar-subform spar-push-classified)
+ (spar-subform spar-push-classified)
+ (spar-or (spar-subform spar-push-classified)
(spar-push-value unspecific-item spar-arg:ctx))
(spar-match-null)))))
(spar-classifier->runtime
(delay
(spar-call-with-values constant-item
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-elt (spar-push-value strip-syntactic-closures spar-arg:form))
+ (spar-subform (spar-push-value strip-syntactic-closures spar-arg:form))
(spar-match-null)))))
(define :quote-identifier
(spar-classifier->runtime
(delay
(spar-call-with-values quoted-id-item
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-elt
+ (spar-subform
(spar-match identifier? spar-arg:form)
(spar-push-value lookup-identifier spar-arg:form spar-arg:senv)
(spar-or (spar-match var-item? spar-arg:value)
(access-item-name lhs-item)
(access-item-env lhs-item)
rhs-item)))
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-elt
+ (spar-subform
spar-push-classified
(spar-or (spar-match (lambda (lhs-item)
(or (var-item? lhs-item)
spar-arg:value)
(spar-error "Variable required in this context:"
spar-arg:form)))
- (spar-or (spar-elt spar-push-classified)
+ (spar-or (spar-subform spar-push-classified)
(spar-push-value unassigned-item spar-arg:ctx))
(spar-match-null)))))
(spar-classifier->runtime
(delay
(spar-call-with-values or-item
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar* (spar-elt spar-push-classified))
+ (spar* (spar-subform spar-push-classified))
(spar-match-null)))))
(define :delay
(spar-classifier->runtime
(delay
(spar-call-with-values delay-item
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-elt spar-push-deferred-classified)
+ (spar-subform spar-push-deferred-classified)
(spar-match-null)))))
\f
;;;; Definitions
(spar-classifier->keyword
(delay
(spar-call-with-values defn-item
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-elt
+ (spar-subform
(spar-match identifier? spar-arg:form)
(spar-push-value bind-variable spar-arg:form spar-arg:senv))
- (spar-elt spar-push-classified)
+ (spar-subform spar-push-classified)
(spar-match-null)))))
(define :define-syntax
(senv-top-level? senv))
(syntax-defn-item ctx id (keyword-item-expr item))
(seq-item ctx '()))))
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-push-elt-if identifier? spar-arg:form)
- (spar-elt
+ (spar-push-subform-if identifier? spar-arg:form)
+ (spar-subform
spar-push-classified
(spar-or (spar-match keyword-item? spar-arg:value)
(spar-error "Keyword binding value must be a keyword:"
(lambda (ctx bvl body-ctx body)
(assemble-lambda-item ctx scode-lambda-name:unnamed bvl
body-ctx body))
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-push-elt-if mit-lambda-list? spar-arg:form)
+ (spar-push-subform-if mit-lambda-list? spar-arg:form)
(spar-push-body)))))
(define :named-lambda
(lambda (ctx name bvl body-ctx body)
(assemble-lambda-item ctx (identifier->symbol name) bvl
body-ctx body))
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-elt
- (spar-push-elt-if identifier? spar-arg:form)
+ (spar-subform
+ (spar-push-subform-if identifier? spar-arg:form)
(spar-push-form-if mit-lambda-list? spar-arg:form))
(spar-push-body)))))
(let ((body-senv (make-internal-senv frame-senv)))
(map-in-order (lambda (elt) (elt body-senv))
elts))))
- (spar+ (spar-elt spar-push-open-classified))
+ (spar+ (spar-subform spar-push-open-classified))
(spar-match-null))))
(define (assemble-lambda-item ctx name bvl body-ctx body)
(bind-keyword (car binding) frame-senv (cdr binding)))
bindings)
(seq-item body-ctx (body frame-senv))))
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-elt
+ (spar-subform
(spar-call-with-values list
(spar*
(spar-call-with-values cons
- (spar-elt (spar-push-elt-if identifier? spar-arg:form)
- (spar-elt spar-push-classified)
- (spar-match-null)))))
+ (spar-subform (spar-push-subform-if identifier? spar-arg:form)
+ (spar-subform spar-push-classified)
+ (spar-match-null)))))
(spar-match-null))
(spar-push-body))))
((cdr binding) frame-senv))
bindings))
(seq-item body-ctx (body frame-senv))))
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-elt
+ (spar-subform
(spar-call-with-values list
(spar*
(spar-call-with-values cons
- (spar-elt (spar-push-elt-if identifier? spar-arg:form)
- (spar-elt spar-push-open-classified)
- (spar-match-null)))))
+ (spar-subform (spar-push-subform-if identifier? spar-arg:form)
+ (spar-subform spar-push-open-classified)
+ (spar-match-null)))))
(spar-match-null))
(spar-push-body)))))
\f
(spar-classifier->keyword
(delay
(spar-call-with-values access-item
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
- (spar-push-elt-if identifier? spar-arg:form)
- (spar-elt spar-push-classified)
+ (spar-push-subform-if identifier? spar-arg:form)
+ (spar-subform spar-push-classified)
(spar-match-null)))))
(define-expr-item-compiler access-item?
(spar-or (spar-match senv-top-level? spar-arg:senv)
(spar-error "This form allowed only at top level:"
spar-arg:form spar-arg:senv))
- (spar-elt)
+ (spar-subform)
(spar-match-null)
(spar-push-value the-environment-item spar-arg:ctx)))))
(spar-classifier->keyword
(delay
(spar-and
- (spar-elt)
+ (spar-subform)
(spar-match-null)
(spar-push-value unspecific-item spar-arg:ctx)))))
(spar-classifier->keyword
(delay
(spar-and
- (spar-elt)
+ (spar-subform)
(spar-match-null)
(spar-push-value unassigned-item spar-arg:ctx)))))
\f
decl))
decls
(hist-cadr hist))))))
- (spar-elt)
+ (spar-subform)
(spar-push spar-arg:ctx)
(spar-call-with-values list
(spar*
- (spar-push-elt-if (lambda (form)
- (and (pair? form)
- (identifier? (car form))
- (list? (cdr form))))
- spar-arg:form)))
+ (spar-push-subform-if (lambda (form)
+ (and (pair? form)
+ (identifier? (car form))
+ (list? (cdr form))))
+ spar-arg:form)))
(spar-match-null)))))
(define (classify-id id senv hist)
\f
;;;; Element combinators
-(define (spar-elt . spars)
+(define (spar-subform . spars)
(let ((spar (%and spars)))
(lambda (input senv output success failure)
(if (%input-pair? input)
failure)
(failure)))))
-(define (spar-match-elt predicate . args)
- (spar-elt (apply spar-match predicate args)))
+(define (spar-match-subform predicate . args)
+ (spar-subform (apply spar-match predicate args)))
-(define (spar-push-elt)
- (spar-elt (spar-push spar-arg:form)))
+(define (spar-push-subform)
+ (spar-subform (spar-push spar-arg:form)))
-(define (spar-push-elt-if predicate . args)
- (spar-elt (apply spar-push-form-if predicate args)))
+(define (spar-push-subform-if predicate . args)
+ (spar-subform (apply spar-push-form-if predicate args)))
(define (spar-match-null)
(spar-match null? spar-arg:form))
(define (make-pattern-compiler expr? caller)
(call-with-constructors expr?
- (lambda ($* $+ $and $call $elt $if $match-elt $match-null $not $opt $or
- $push $push-elt $push-elt-if $push-value)
+ (lambda ($* $+ $and $call $if $match-null $match-subform $not $opt $or $push
+ $push-subform $push-subform-if $push-value $subform)
(define (loop pattern)
(let-syntax
,@(cdr rule)))
(cdr form))
(else (bad-pattern pattern)))))))
- (rules (''ignore ($elt))
- (''any ($push-elt))
- (''id ($push-elt-if identifier? spar-arg:form))
- (''symbol ($push-elt-if symbol? spar-arg:form))
- (procedure? ($push-elt-if pattern spar-arg:form))
+ (rules (''ignore ($subform))
+ (''any ($push-subform))
+ (''id ($push-subform-if identifier? spar-arg:form))
+ (''symbol ($push-subform-if symbol? spar-arg:form))
+ (procedure? ($push-subform-if pattern spar-arg:form))
('('spar form) (cadr pattern))
('('* * form) ($call list (apply $* (map loop (cdr pattern)))))
('('+ * form) ($call list (apply $+ (map loop (cdr pattern)))))
('('and * form) (apply $and (map loop (cdr pattern))))
('('not form) ($not (loop (cadr pattern))))
('('noise form)
- ($match-elt eqv? (cadr pattern) spar-arg:form))
+ ($match-subform eqv? (cadr pattern) spar-arg:form))
('('noise-keyword identifier)
- ($match-elt spar-arg:compare (cadr pattern) spar-arg:form))
+ ($match-subform spar-arg:compare
+ (cadr pattern)
+ spar-arg:form))
('('keyword identifier)
- ($and ($match-elt spar-arg:compare
- (cadr pattern)
- spar-arg:form)
+ ($and ($match-subform spar-arg:compare
+ (cadr pattern)
+ spar-arg:form)
($push (cadr pattern))))
('('values * form)
(apply $push (map convert-spar-arg (cdr pattern))))
('('call + form)
(apply $call (cadr pattern) (map loop (cddr pattern))))
('('elt * form)
- ($elt (apply $and (map loop (cdr pattern)))
- ($match-null))))))
+ ($subform (apply $and (map loop (cdr pattern)))
+ ($match-null))))))
(define (convert-spar-arg arg)
(case arg
(flat-proc 'spar+ spar+)
(flat-proc 'spar-and spar-and)
(flat-proc 'spar-call-with-values spar-call-with-values)
- (flat-proc 'spar-elt spar-elt)
(proc 'spar-if spar-if)
- (proc 'spar-match-elt spar-match-elt)
(proc 'spar-match-null spar-match-null)
+ (proc 'spar-match-subform spar-match-subform)
(proc 'spar-not spar-not)
(flat-proc 'spar-opt spar-opt)
(proc 'spar-or spar-or)
(proc 'spar-push spar-push)
- (proc 'spar-push-elt spar-push-elt)
- (proc 'spar-push-elt-if spar-push-elt-if)
- (proc 'spar-push-value spar-push-value)))
+ (proc 'spar-push-subform spar-push-subform)
+ (proc 'spar-push-subform-if spar-push-subform-if)
+ (proc 'spar-push-value spar-push-value)
+ (flat-proc 'spar-subform spar-subform)))
(define-deferred pattern->spar
(make-pattern-compiler #f 'pattern->spar))