Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion goldfish/guenchi/json.scm
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
(+ (* (- code-point #xD800) #x400)
(- next-code-point #xDC00) #x10000) ; 计算码点
) ;+
) ;
) ;surrogate-code-point
(values (utf8->string (codepoint->utf8 surrogate-code-point)) 12)
) ;let
;; 不满足代理对条件,仅对第一个 \u 进行转换
Expand Down
65 changes: 33 additions & 32 deletions goldfish/liii/argparse.scm
Original file line number Diff line number Diff line change
Expand Up @@ -118,40 +118,41 @@
(if (null? args)
args-ht
(let ((arg (car args)))
(cond ((long-form? arg)
(let* ((name (substring arg 2))
(found (hash-table-ref args-ht name)))
(if found
(if (null? (cdr args))
(error "Missing value for argument" name)
(begin
(let ((value (convert-value (cadr args) (cadr found))))
(set-car! (cddddr found) value)
) ;let
(loop (cddr args))
) ;begin
) ;if
(value-error (string-append "Unknown option: --" name)))
(cond
((long-form? arg)
(let* ((name (substring arg 2))
(found (hash-table-ref args-ht name)))
(if found
(if (null? (cdr args))
(error "Missing value for argument" name)
(begin
(let ((value (convert-value (cadr args) (cadr found))))
(set-car! (cddddr found) value)
) ;let
(loop (cddr args))
) ;begin
) ;if
) ;let*
((short-form? arg)
(let* ((name (substring arg 1))
(found (hash-table-ref args-ht name)))
(if found
(if (null? (cdr args))
(error "Missing value for argument" name)
(begin
(let ((value (convert-value (cadr args) (cadr found))))
(set-car! (cddddr found) value)
) ;let
(loop (cddr args))
) ;begin
) ;if
(value-error (string-append "Unknown option: -" name))
(value-error (string-append "Unknown option: --" name)))
) ;if
) ;let*
((short-form? arg)
(let* ((name (substring arg 1))
(found (hash-table-ref args-ht name)))
(if found
(if (null? (cdr args))
(error "Missing value for argument" name)
(begin
(let ((value (convert-value (cadr args) (cadr found))))
(set-car! (cddddr found) value)
) ;let
(loop (cddr args))
) ;begin
) ;if
) ;let*
) ;
(else (loop (cdr args)))
(value-error (string-append "Unknown option: -" name))
) ;if
) ;let*
) ;
(else (loop (cdr args)))
) ;cond
) ;let
) ;if
Expand Down
58 changes: 31 additions & 27 deletions goldfish/liii/case.scm
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
(let
((case*-labels (lambda (label)
(let ((labels ((funclet ((funclet 'case*) 'case*-helper)) 'labels)))
(labels (symbol->string label)))) ; if ellipsis, this has been quoted by case*
(labels (symbol->string label))) ; if ellipsis, this has been quoted by case*
) ;let
) ;case*-labels

(case*-match?
(lambda* (matchee pattern (e (curlet)))
Expand Down Expand Up @@ -156,50 +157,51 @@
) ;else
) ;cond

(cond ((= pos 0)
(if ellipsis-label
(set! (labels ellipsis-label)
(list 'quote (copy sel (make-list (- sel-len new-pat-len))))
) ;set!
) ;if
(values (subvector sel (max 0 (- sel-len new-pat-len)) sel-len) ; was new-pat-len (max 0 (- sel-len new-pat-len))
(subvector pat 1 (+ new-pat-len 1)) ; new-pat-len 1
(or (not func)
(func (cadr (labels ellipsis-label))))
) ;or
) ;values
(cond
((= pos 0)
(if ellipsis-label
(set! (labels ellipsis-label)
(list 'quote (copy sel (make-list (- sel-len new-pat-len))))
) ;set!
) ;if
(values (subvector sel (max 0 (- sel-len new-pat-len)) sel-len) ; was new-pat-len (max 0 (- sel-len new-pat-len))
(subvector pat 1 (+ new-pat-len 1)) ; new-pat-len 1
(or (not func)
(func (cadr (labels ellipsis-label))))
) ;or
) ;values

((= pos new-pat-len)
(if ellipsis-label
(set! (labels ellipsis-label)
(list 'quote (copy sel (make-list (- sel-len new-pat-len)) pos))
(list 'quote (copy sel (make-list (- sel-len new-pat-len)) pos))
) ;set!
) ;if
(values (subvector sel 0 new-pat-len)
(subvector pat 0 new-pat-len)
(or (not func)
(func (cadr (labels ellipsis-label)))
(func (cadr (labels ellipsis-label)))
) ;or
) ;values
) ;

(else
(let ((new-pat (make-vector new-pat-len))
(new-sel (make-vector new-pat-len)))
(new-sel (make-vector new-pat-len)))
(if ellipsis-label
(set! (labels ellipsis-label)
(list 'quote (copy sel (make-list (- sel-len new-pat-len)) pos))
) ;set!
(set! (labels ellipsis-label)
(list 'quote (copy sel (make-list (- sel-len new-pat-len)) pos))
) ;set!
) ;if
(copy pat new-pat 0 pos)
(copy pat (subvector new-pat pos new-pat-len) (+ pos 1)) ; (- new-pat-len pos) pos) copy: (+ pos 1))
(copy sel new-sel 0 pos)
(copy sel (subvector new-sel pos new-pat-len) (- sel-len pos))
; (- new-pat-len pos) pos) copy: (- sel-len pos))
(values new-sel new-pat
(or (not func)
(cadr (func (labels ellipsis-label)))
) ;or
(or (not func)
(cadr (func (labels ellipsis-label)))
) ;or
) ;values
) ;let
) ;else
Expand Down Expand Up @@ -410,11 +412,13 @@

(when (find-labelled-pattern body) ; if labelled, remake the body substituting the labelled-exprs for the labels
(set! body (let pair-builder ((tree body))
(cond ((undefined? tree)
(let ((label (let ((str (object->string tree)))
(substring str 2 (- (length str) 1)))))
(or (labels label) tree))
) ;let
(cond
((undefined? tree)
(let ((label (let ((str (object->string tree)))
(substring str 2 (- (length str) 1)))))
(or (labels label) tree)
) ;let
) ;

((pair? tree)
(cons (pair-builder (car tree))
Expand Down
Loading
Loading