smalltalk: Conway Life + dynamic-array literal {…}; classic corpus complete
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -287,6 +287,7 @@
|
||||
((e (parse-expression)))
|
||||
(begin (consume! "rparen" nil) e))))
|
||||
((= ty "lbracket") (parse-block))
|
||||
((= ty "lbrace") (parse-dynamic-array))
|
||||
((= ty "ident")
|
||||
(begin
|
||||
(advance-tok!)
|
||||
@@ -346,6 +347,37 @@
|
||||
(arr-loop)
|
||||
{:type "lit-array" :elements items}))))
|
||||
|
||||
;; { expr. expr. expr } — Pharo dynamic array literal. Each element
|
||||
;; is a *full expression* evaluated at runtime; the result is a
|
||||
;; fresh mutable array. Empty `{}` is a 0-length array.
|
||||
(define
|
||||
parse-dynamic-array
|
||||
(fn
|
||||
()
|
||||
(let ((items (list)))
|
||||
(begin
|
||||
(consume! "lbrace" nil)
|
||||
(define
|
||||
da-loop
|
||||
(fn
|
||||
()
|
||||
(cond
|
||||
((at? "rbrace" nil) (advance-tok!))
|
||||
(else
|
||||
(begin
|
||||
(append! items (parse-expression))
|
||||
(define
|
||||
dot-loop
|
||||
(fn
|
||||
()
|
||||
(when
|
||||
(at? "period" nil)
|
||||
(begin (advance-tok!) (dot-loop)))))
|
||||
(dot-loop)
|
||||
(da-loop))))))
|
||||
(da-loop)
|
||||
{:type "dynamic-array" :elements items}))))
|
||||
|
||||
;; #[1 2 3]
|
||||
(define
|
||||
parse-byte-array
|
||||
|
||||
Reference in New Issue
Block a user