Advanced Functional Prog.

back - up - cont


Parsing expressions

The code can be improved again with recursion:

EXP = NUM ('+' EXP | epsilon)
let rec exp = 
  num'       && fun n1 -> 
  ((sym '+') && fun _  -> 
   exp       && fun n2 -> 
   ret (n1+n2)) 
  || (ret n1);;

exp "12+34+56";;

13 - 18