open SExpr let get_url se_lst = match se_lst with | Expr [Atom ("url"); Atom (url)] -> Some (url) | _ -> None let search_url se_lst = let rec aux se_lst = match se_lst with | [] -> None | hd::tl -> match get_url hd with | Some v -> Some v | None -> aux tl in aux se_lst let match_se se = match se with | Expr (Atom ("gfx") :: se_lst) -> Printf.printf "one gfx found,\n"; begin match search_url se_lst with | Some found -> Printf.printf " found-url: %s\n" found; | None -> Printf.printf " url-not-found\n"; end | _ -> Printf.printf ".\n"; ;; let () = let filename = "./file.se" in let se_lst = SExpr.parse_file filename in let rec aux se_lst = match se_lst with | se::se_tl -> match_se se; aux se_tl | [] -> () in aux se_lst