Advanced Functional Prog.

back - up - cont


Parsing expressions

Now, all the piece of code can be used to parse mathematical expressions.
As a start point, if a expression is simply the sum of two numbers:

EXP = NUM '+' NUM

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

exp "12+23";;

11 - 18