I'm doing a uni course on OCaml and need to parse an s-expr into it's proper AST representation, using the Containers library
I need to extend the parser to include boolean values but I can't find an elegant way to pattern match the string over just nesting more pattern matches.
So I wonder if there's a prettier way to do it.
So far if the parser detects an `Atomic string "s" it "opens" a nested match case to see if it's an int or a variable name.
...| `Atomic s -> begin match int_of_string_opt s with | Some n -> Num n | None -> begin match bool_of_string_opt s with | Some b -> Bool b | None -> Var s end end...
This solution works but just by looking I can tell it could be designed better but I'm not familiar enough with OCaml to know how to make it better.