SHARE
TWEET

Untitled

a guest Feb 18th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- a/parsing/parser.mly
  2. +++ b/parsing/parser.mly
  3. @@ -146,6 +146,10 @@ let mkexp_constraint e (t1, t2) =
  4.    | _, Some t -> ghexp(Pexp_coerce(e, t1, t))
  5.    | None, None -> assert false
  6.  
  7. +let mkexp_opt_constraint e = function
  8. +  | None -> e
  9. +  | Some constraint_ -> mkexp_constraint e constraint_
  10. +
  11.  let array_function par assign=
  12.    let op = if assign then par^"<-" else par in
  13.    ghloc ( Lident op )
  14. @@ -1419,10 +1423,10 @@ lbl_expr_list:
  15.    |  lbl_expr SEMI { [$1] }
  16.  ;
  17.  lbl_expr:
  18. -    label_longident EQUAL expr
  19. -      { (mkrhs $1 1,$3) }
  20. -  | label_longident
  21. -      { (mkrhs $1 1, exp_of_label $1 1) }
  22. +   label_longident opt_type_constraint EQUAL expr
  23. +     { (mkrhs $1 1, mkexp_opt_constraint $4 $2) }
  24. + | label_longident opt_type_constraint
  25. +     { (mkrhs $1 1, mkexp_opt_constraint (exp_of_label $1 1) $2) }
  26.  ;
  27.  field_expr_list:
  28.      field_expr opt_semi { [$1] }
  29. @@ -1445,6 +1449,10 @@ type_constraint:
  30.    | COLON error                                 { syntax_error() }
  31.    | COLONGREATER error                          { syntax_error() }
  32.  ;
  33. +opt_type_constraint:
  34. +    type_constraint { Some $1 }
  35. +  | /* empty */ { None }
  36. +;
  37.  
  38.  /* Patterns */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top