Advanced Functional Prog.

back - up - cont


Parsing expressions

This preliminary example can now be improved to other grammars.

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

exp "12";;
exp "12+34";;

12 - 18