SHARE
TWEET

Untitled

a guest Feb 27th, 2020 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. open Common
  2. let pEBind msg = Some (None, Error msg)
  3. type Token = TVar of string
  4. let pMap f inp =
  5.     match inp with
  6.     | Error msg -> (Some << Error) <|  msg
  7.     | Ok inp -> Some <| f inp
  8.    
  9. let rec (|VARLIST|_|) lst =
  10.     match lst with
  11.     | Error token -> Some (None, Error token)
  12.     | VAR (Some ast, (VARLIST (Some ast2, rest))) -> Some( Some(FuncApp(ast, ast2)), rest)
  13.     | VAR (Some(ast), rest) -> Some(Some ast, rest)
  14.     | Ok lst -> pEBind <| lst
  15.  
  16. and (|VAR|_|) lst =
  17.     match lst with
  18.     | Error token -> Some (None, Error token)
  19.     | Ok ((TVar x)::rest) -> Some(Some(Var x), Ok rest)
  20.     | Ok lst -> pEBind <| lst
  21.    
  22. let var = (|VARLIST|_|)
  23. [<EntryPoint>] //*
  24. let main argv =
  25.     //----------------------------------
  26.     let tokenl = [TVar "x"; TVar "y"]
  27.     Ok tokenl |> var |> printfn "%A"
  28.     0
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