Skip to content

Commit

Permalink
в процессе
Browse files Browse the repository at this point in the history
  • Loading branch information
voidlizard committed Mar 22, 2011
1 parent 2029bab commit 0f930b9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/parser.mly
Expand Up @@ -191,6 +191,7 @@ filt_bin_arg:
filt_arg: filt_arg:
| NUMBER { B.number_constant $1 } | NUMBER { B.number_constant $1 }
| STRING { B.string_constant $1 } | STRING { B.string_constant $1 }
// | source { B.var_filt_arg $1 }


filt_like_arg: filt_like_arg:
| OBR STRING CBR { B.string_constant $2 } | OBR STRING CBR { B.string_constant $2 }
Expand Down
4 changes: 3 additions & 1 deletion src/report.ml
Expand Up @@ -49,7 +49,7 @@ and fun_call_t = { fun_ns: fun_ns_t; fun_name: string; fun_args: fun_arg_t list
and field_t = { field_alias: string; field_source: field_src_t; field_flt: (filt_op_t * string) list} and field_t = { field_alias: string; field_source: field_src_t; field_flt: (filt_op_t * string) list}
and field_src_t = FIELD_FUN_CALL of fun_call_t and field_src_t = FIELD_FUN_CALL of fun_call_t


and val_t = STR_CONST of string | NUM_CONST of string | VAR_REF of string and val_t = STR_CONST of string | NUM_CONST of string | VAR_REF of string | SRC of source_t


let ident i s = P.sprintf "%s %s" i s let ident i s = P.sprintf "%s %s" i s


Expand Down Expand Up @@ -207,6 +207,7 @@ let str_of_val = function
| NUM_CONST(s) -> s | NUM_CONST(s) -> s
| STR_CONST(s) -> s | STR_CONST(s) -> s
| VAR_REF(s) -> P.sprintf "${%s}" s | VAR_REF(s) -> P.sprintf "${%s}" s
| SRC _ -> failwith "Unsupported yet filter arg (var)"


let rec emit_sql_fun fn args = let rec emit_sql_fun fn args =
let argz = List.map (fun a -> emit_sql_fun_arg a) args |> String.join "," let argz = List.map (fun a -> emit_sql_fun_arg a) args |> String.join ","
Expand Down Expand Up @@ -240,6 +241,7 @@ and quote = function
| STR_CONST(s) -> P.sprintf "'%s'" s | STR_CONST(s) -> P.sprintf "'%s'" s
| NUM_CONST(v) -> v | NUM_CONST(v) -> v
| VAR_REF(n) -> P.sprintf "${%s}" n | VAR_REF(n) -> P.sprintf "${%s}" n
| SRC(x) -> failwith "Unsupported yet filter arg (var)"
and val_of = function and val_of = function
| LIKE(v) | GT(v) | LT(v) | GE(v) | LIKE(v) | GT(v) | LT(v) | GE(v)
| LE(v) | LE(v) | NE(v) | EQ(v) -> v | LE(v) | LE(v) | NE(v) | EQ(v) -> v
Expand Down
2 changes: 2 additions & 0 deletions src/report_builder.ml
Expand Up @@ -61,6 +61,8 @@ let string_constant s = STR_CONST(s)


let number_constant v = NUM_CONST(v) let number_constant v = NUM_CONST(v)


let var_filt_arg x = SRC x

let with_column cattr report = let with_column cattr report =
let col = List.fold_left (fun c f -> f c) let col = List.fold_left (fun c f -> f c)
{ col_name = None; { col_name = None;
Expand Down
10 changes: 9 additions & 1 deletion src/t/busreport.rep
@@ -1,6 +1,6 @@
%% ТЕСТОВЫЙ ОТЧЕТ 3 %% ТЕСТОВЫЙ ОТЧЕТ 3


CONNECTION db1 "dbname=mososm2" CONNECTION db1 "dbname=tambov_prod"


TEMPLATE_DIRS "t:/home/dmz/templates" TEMPLATE_DIRS "t:/home/dmz/templates"


Expand Down Expand Up @@ -40,3 +40,11 @@ COLUMN
%% FOLD YES %% FOLD YES
END END


COLUMN
SOURCE SQL.bus_mileage(v.gos_number, "2010-11-01", "2010-12-31")
ALIAS mileage
NAME "пробег"
%% SORT ASC
%% FOLD YES
END

2 changes: 1 addition & 1 deletion src/t/busreport.tmpl
Expand Up @@ -3,7 +3,7 @@ Report column: ${header.busn}
Report column: ${header.driver} Report column: ${header.driver}


#foreach (row in rows) #foreach (row in rows)
${row.busn} : ${row.year} : ${row.driver} : ${row.speeding} ${row.obj.busn} : ${row.obj.year} : ${row.obj.driver} : ${row.obj.speeding} : ${row.obj.mileage}
#end #end


${SQL} ${SQL}

0 comments on commit 0f930b9

Please sign in to comment.