Add M.{ ... } syntax in both patterns and expressions
This commit is contained in:
parent
8bfbae5673
commit
46b9b934a8
@ -353,6 +353,8 @@
|
||||
(LPAREN RPAREN) : (list 'PInt 0)
|
||||
(LPAREN pattern RPAREN) : $2
|
||||
(LBRACE record_list_pattern option_semicolon RBRACE) : (list 'PRecord (reverse $2))
|
||||
(longident_uident DOT LBRACE record_list_pattern option_semicolon RBRACE) :
|
||||
(list 'POpen $1 (list 'PRecord (reverse $4)))
|
||||
(INT) : (list 'PInt $1)
|
||||
(STRING) : (list 'PString $1)
|
||||
)
|
||||
@ -365,6 +367,10 @@
|
||||
(BEGIN expr END) : $2
|
||||
(LPAREN expr COLON type_ignore RPAREN) : $2
|
||||
(simple_expr DOT longident_field) : (list 'EGetfield $1 $3)
|
||||
(longident_uident DOT LBRACE record_list_expr option_semicolon RBRACE) :
|
||||
(list 'ELetOpen $1 (list 'ERecord (reverse $4)))
|
||||
(longident_uident DOT LBRACE simple_expr WITH record_list_expr option_semicolon RBRACE) :
|
||||
(list 'ELetOpen $1 (list 'ERecordwith $4 (reverse $6)))
|
||||
(LBRACE record_list_expr option_semicolon RBRACE) : (list 'ERecord (reverse $2))
|
||||
(LBRACE simple_expr WITH record_list_expr option_semicolon RBRACE) : (list 'ERecordwith $2 (reverse $4))
|
||||
(LBRACK RBRACK) : (lid->econstr "[]" #nil)
|
||||
@ -1503,6 +1509,7 @@
|
||||
(fold-right loop acc (map cdr field-defs)))
|
||||
(('PFullRecord field-pats)
|
||||
(fold-right loop acc field-pats))
|
||||
(('POpen _ p) (loop p acc))
|
||||
)))
|
||||
|
||||
(define (match-decompose-matrix env guarded? args m)
|
||||
@ -1576,6 +1583,9 @@
|
||||
(append
|
||||
(simplify-row env arg (list p1 ps bindings e))
|
||||
(simplify-row env arg (list p2 ps bindings e))))
|
||||
(('POpen m p)
|
||||
(let* ((menv (env-get-module env m)))
|
||||
(simplify-row (env-open env menv) arg (list p ps bindings e))))
|
||||
)))
|
||||
|
||||
(define (pattern-head-arity h)
|
||||
|
@ -1 +1 @@
|
||||
Bytecode size: 4637 bytes
|
||||
Bytecode size: 5129 bytes
|
||||
|
@ -19,4 +19,16 @@ let () =
|
||||
let open N in
|
||||
f ~x:21 show_int
|
||||
|
||||
module R = struct
|
||||
type r = { a : int; b : int }
|
||||
end
|
||||
|
||||
let () =
|
||||
let mk a b = R.{ a; b } in
|
||||
let unmk R.{ a; b } = (a, b) in
|
||||
let r = mk 42 21 in
|
||||
let u = snd (unmk r) in
|
||||
show_int r.R.a;
|
||||
show_int (u + u)
|
||||
|
||||
let () = print_newline ()
|
||||
|
@ -1,2 +1,2 @@
|
||||
Let open:
|
||||
42 42 42 42
|
||||
42 42 42 42 42 42
|
||||
|
Loading…
x
Reference in New Issue
Block a user