--- /dev/null
+(* To be cleaned up - prototype version *)
+
+open Globals
+open Xpath_syntax
+open Printf
+
+type sql = Select of command_spec
+ | Insert of command_spec
+ | Update of command_spec
+ | Delete of command_spec
+and
+ command_spec = string list * string * expr option
+
+let rec str_of_expr = function
+ | String_literal(s)->sprintf "\"%s\"" s
+ | Number_literal(f)->if (f=1.0) then "true" else if (f=0.0) then "false" else sprintf "%f" f
+ | Var(s)->s
+ | Equal(e1,e2) -> (str_of_expr e1) ^ "=" ^ (str_of_expr e2)
+ | NotEqual(e1,e2) -> (str_of_expr e1) ^ "!=" ^ (str_of_expr e2)
+ | Lower(e1,e2) -> (str_of_expr e1) ^ "<" ^ (str_of_expr e2)
+ | Greater(e1,e2) -> (str_of_expr e1) ^ ">" ^ (str_of_expr e2)
+ | LowerEqual(e1,e2) -> (str_of_expr e1) ^ "<=" ^ (str_of_expr e2)
+ | GreaterEqual(e1,e2) -> (str_of_expr e1) ^ ">=" ^ (str_of_expr e2)
+ | _ -> print "Expression type not supported yet";raise AftError
+ | Or(e1,e2) -> (str_of_expr e1) ^ " or " ^ (str_of_expr e2)
+ | And(e1,e2) -> (str_of_expr e1) ^ " and " ^ (str_of_expr e2)
+
+
+let rec pretty_print_statement = function
+ | Select(colspec, tabspec, rowspec) ->
+ let s_colspec = String.concat "," colspec in
+ let part1 = sprintf "Select %s from WHERE %s" s_colspec tabspec in
+ let part2 = match rowspec with
+ | None -> ""
+ | Some(expr) -> (str_of_expr(expr))
+ in
+ part1 ^ part2
+ | _ -> print "Statement type not supported yet";raise AftError