Source

hello / sql / sql.ml

Full commit

type query = Select of string list * string (* columns, table *)

let pp_query = function
  | Select(columns, table) ->
    Printf.printf "select: %s from %s\n" (String.concat "," columns) table;;

let parse q =
  let lexbuf = Lexing.from_string q in
  try
    Parser.input Lexer.token lexbuf
  with
    | exn ->
      print_endline (Printexc.to_string exn);
      raise exn;;

let sample_query = "select * from mytable";;

let _ =
  print_endline sample_query;
  pp_query (Select(["hoge"; "hage"], "tttttttttttttt"));
  let _ = parse sample_query in
  print_endline " => hello";;