I have a problem with this:
How to quickly print a tree structure in a row in Ocaml?
But on the contrary, I already have a string and you want to parse it to be a tree.
For example, I have
type expr = Number of int |Plus of expr*expr |Prod of expr*expr
and I have a line like 1 + 2 * 3 + 4 (slightly different from the link above, suppose * has a higher procedure than + )
Then I want my result to be an expression like Prod(Plus(1,2), Plus(3, 4))
I found another link that could talk about this, but not sure if this is the way to make my problem:
Parsing grammars using OCaml
Please share some ideas, thanks.
Allan jiang
source share