ocaml: phase 4 'M.(expr)' local-open expression form (+3 tests, 481 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
In parse-atom-postfix, after consuming '.', if the next token is '(',
parse the inner expression and emit (:let-open M EXPR) instead of
:field. Cleanly composes with the existing :let-open evaluator and
loops to allow chained dot postfixes.
List.(length [1;2;3]) = 3
List.(map (fun x -> x + 1) [1;2;3]) = [2;3;4]
Option.(map (fun x -> x * 10) (Some 4)) = Some 40
This commit is contained in:
@@ -562,11 +562,22 @@
|
||||
(when (at-op? ".")
|
||||
(begin
|
||||
(advance-tok!)
|
||||
(let ((tok (peek-tok)))
|
||||
(begin
|
||||
(advance-tok!)
|
||||
(set! head (list :field head (ocaml-tok-value tok)))
|
||||
(loop)))))))
|
||||
(cond
|
||||
((at-op? "(")
|
||||
(begin
|
||||
(advance-tok!)
|
||||
(let ((inner (parse-expr)))
|
||||
(begin
|
||||
(consume! "op" ")")
|
||||
(set! head (list :let-open head inner))
|
||||
(loop)))))
|
||||
(else
|
||||
(let ((tok (peek-tok)))
|
||||
(begin
|
||||
(advance-tok!)
|
||||
(set! head (list :field head
|
||||
(ocaml-tok-value tok)))
|
||||
(loop)))))))))
|
||||
(loop)
|
||||
head))))
|
||||
(set!
|
||||
|
||||
Reference in New Issue
Block a user