Parsing grammars using OCaml -


I have a task to write a (toy) parser for a (toy) grammar using OCaml and it is not certain how to start (

[[The [[T =" $ "; N XPR]] | Inkrop - T ["+" "]; [T" - "] | Binop-1"]; [T "2"]; [T "3"]; [T "4"]; [T "5"]; [T "6"]; [T "7"]; [T "8"]; [T "9"]];;

And here pars There are some pieces to do:

  let's frag1 = ["4"; "+"; "3"] ;; let's frag2 = ["9"; "+"; "$"; "1"; "+"] ;;   

What I see is a rule list that is the result of parsing a piece, such as frag1 [">

  [[Xp, [n term; n binop; n XPR]); (Period, [n new]); (Number, [t "3"]); (Binop, [t "+"]); (Xp, [n term]); (Period, [n new]); (Num, [T "4"]]]  

No OCaml libraries except the restriction list are to be used ...: /

  Excerpt Barrotrack parse L = Rule = SD in awksub_grammar REC descend the village L = REC loop = function. [] - & Gt; Increase Background | X :: xs - & gt; Try Back with Effort - -> Loop Xs in Loop (Rule Village) and Effort Branch (Path, Token) = Match Branch, with Token. X :: Branch ', H: Token' when H = X -> Attempt Branch '(T x :: Path), Token') | NN :: Branch ', _ - & gt; ', Token) = n (nn :: path), token) in the effort branch (' path ', token) | [], _ - - gt; path, token | _, _ - & gt; look ( Path, tail) = descend down (fst awksub_grammar) ([], l) in tail, list.rev path  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -