/* ===================================================================== Source: report.rule ===================================================================== */ start_cmd : START_REPORT rep_name atline TO_PRINTER op_with_dim { struct expr_str *p; $$=$5; $$->towhat='|'; set_cmdlineno($3); p=A4GL_new_expr_simple(ET_EXPR_REPORT_PRINTER); add_feature("USE_REPORT"); ADDMAP("Start Report",$2); map_start_report($2); $$->s1=chk_expr(p); $$=new_start_cmd($2, $$); } | START_REPORT rep_name atline TO_EMAIL op_with_dim { struct expr_str *p; set_cmdlineno($3); $$=$5; $$->towhat='M'; p=A4GL_new_expr_email_report($2,NULL); $$->s1=chk_expr(p); add_feature("USE_REPORT"); ADDMAP("Start Report",$2); map_start_report($2); $$=new_start_cmd($2, $$); } | START_REPORT rep_name atline TO_EMAIL fgl_expr_c op_with_dim { struct expr_str *p; set_cmdlineno($3); $$=$6; $$->towhat='M'; p=A4GL_new_expr_email_report($2,$5); $$->s1=chk_expr(p); add_feature("USE_REPORT"); ADDMAP("Start Report",$2); map_start_report($2); $$=new_start_cmd($2, $$); } | START_REPORT rep_name atline KW_TO rout op_with_dim { set_cmdlineno($3); $$=$6; $$->towhat='F'; $$->s1=chk_expr($5); add_feature("USE_REPORT"); ADDMAP("Start Report",$2); map_start_report($2); $$=new_start_cmd($2, $$); } | START_REPORT rep_name atline TO_FILE rout op_with_dim { set_cmdlineno($3); $$=$6; $$->towhat='F'; $$->s1=chk_expr($5); add_feature("USE_REPORT"); ADDMAP("Start Report",$2); map_start_report($2); $$=new_start_cmd($2, $$); } | START_REPORT rep_name atline TO_PIPE rout op_with_dim { set_cmdlineno($3); $$=$6; $$->towhat='|'; $$->s1=chk_expr($5); add_feature("USE_REPORT"); ADDMAP("Start Report",$2); map_start_report($2); $$=new_start_cmd($2, $$); } | START_REPORT rep_name atline TO_UI op_with_dim { set_cmdlineno($3); $$=$5; $$->towhat='U'; $$->s1=chk_expr( A4GL_new_expr_simple_string($2,ET_EXPR_REPORT_UI)); add_feature("USE_REPORT"); ADDMAP("Start Report",$2); map_start_report($2); $$=new_start_cmd($2, $$); } | START_REPORT rep_name atline TO_SCREEN op_with_dim { set_cmdlineno($3); $$=$5; $$->towhat='S'; $$->s1=0; add_feature("USE_REPORT"); ADDMAP("Start Report",$2); map_start_report($2); $$=new_start_cmd($2, $$); } | START_REPORT rep_name atline AS_CONVERTIBLE op_with_dim { set_cmdlineno($3); $$=$5; $$->towhat='C'; $$->s1=0; add_feature("USE_REPORT"); ADDMAP("Start Report",$2); map_start_report($2); $$=new_start_cmd($2, $$); } | START_REPORT rep_name atline op_with_dim { set_cmdlineno($3); $$=$4; $$->towhat=0; $$->s1=0; add_feature("USE_REPORT"); ADDMAP("Start Report",$2); map_start_report($2); $$=new_start_cmd($2, $$); } ; op_with_dim: { $$=malloc(sizeof(startrep)); $$->with_page_length=-1; /*$$->with_page_width=-1; */ $$->with_left_margin=-1; $$->with_right_margin= -1; $$->with_top_margin= -1; $$->with_bottom_margin= -1; $$->with_top_of_page= strdup(""); with_page_length=-1; /* with_page_width=-1; */ with_left_margin=-1; with_right_margin=-1; with_top_margin=-1; with_bottom_margin=-1; with_top_of_page=""; } | WITH with_list { $$=malloc(sizeof(startrep)); $$->with_page_length=with_page_length; /*$$->with_page_width=with_page_width; */ $$->with_left_margin= with_left_margin; $$->with_right_margin= with_right_margin; $$->with_top_margin= with_top_margin; $$->with_bottom_margin= with_bottom_margin; $$->with_top_of_page= strdup(with_top_of_page); with_page_length=-1; /*with_page_width=-1; */ with_left_margin=-1; with_right_margin=-1; with_top_margin=-1; with_bottom_margin=-1; with_top_of_page=""; } ; op_comma: | KW_COMMA ; with_list: with_entry | with_list op_comma with_entry ; with_entry: PAGE_LENGTH op_equal INT_VALUE {with_page_length=atoi($3);} | TOP_MARGIN op_equal INT_VALUE {with_top_margin=atoi($3);} | BOTTOM_MARGIN op_equal INT_VALUE {with_bottom_margin=atoi($3);} | LEFT_MARGIN op_equal INT_VALUE {with_left_margin=atoi($3);} | RIGHT_MARGIN op_equal INT_VALUE {with_right_margin=atoi($3);} | TOP_OF_PAGE op_equal CHAR_VALUE {with_top_of_page=acl_strdup($3);} | PAGE_LENGTH OPEN_BRACKET INT_VALUE CLOSE_BRACKET {with_page_length=atoi($2);} | TOP_MARGIN OPEN_BRACKET INT_VALUE CLOSE_BRACKET {with_top_margin=atoi($2);} | BOTTOM_MARGIN OPEN_BRACKET INT_VALUE CLOSE_BRACKET {with_bottom_margin=atoi($2);} | LEFT_MARGIN OPEN_BRACKET INT_VALUE CLOSE_BRACKET {with_left_margin=atoi($2);} | RIGHT_MARGIN OPEN_BRACKET INT_VALUE CLOSE_BRACKET {with_right_margin=atoi($2);} | TOP_OF_PAGE OPEN_BRACKET CHAR_VALUE CLOSE_BRACKET {with_top_of_page=acl_strdup($2);} ; conv_rep_conv: { $$=0; } | KW_TO char_or_var_vl KW_AS char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='F'; $$->s1=$2; $$->filter=0; $$->emailAddress=0; $$->conv_type=$4; } | VIA via_functionname { $$=malloc(sizeof(struct convert)); $$->towhat='f'; $$->s1=$2; $$->filter=0; $$->conv_type=0; $$->emailAddress=0; } | TO_PIPE char_or_var_vl KW_AS char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='|'; $$->s1=$2; $$->filter=0; $$->conv_type=$4; $$->emailAddress=0; } | TO_PRINTER KW_AS char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='P'; $$->conv_type=$2; $$->s1=0; $$->filter=0; $$->emailAddress=0; } | TO_EMAIL KW_AS char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='@'; $$->conv_type=$3; $$->s1=0; $$->filter=0; $$->emailAddress=0; } | TO_EMAIL char_or_var_vl KW_AS char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='@'; $$->conv_type=$4; $$->s1=0; $$->filter=0; $$->emailAddress=$2; } | TO_FILE char_or_var_vl KW_AS char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='F'; $$->s1=$2; $$->conv_type=$4; $$->filter=0; $$->emailAddress=0; } | KW_TO char_or_var_vl KW_AS char_or_var_vl KW_USING char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='F'; $$->s1=$2; $$->conv_type=$4; $$->filter=$6; $$->emailAddress=0; } | TO_FILE char_or_var_vl KW_AS char_or_var_vl KW_USING char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='F'; $$->s1=$2; $$->conv_type=$4; $$->filter=$6; $$->emailAddress=0; } | TO_PIPE char_or_var_vl KW_AS char_or_var_vl KW_USING char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='|'; $$->s1=$2; $$->filter=$6; $$->conv_type=$4; $$->emailAddress=0; } | TO_PRINTER KW_AS char_or_var_vl KW_USING char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='P'; $$->s1=0; $$->filter=$5; $$->conv_type=$3; $$->emailAddress=0; } | TO_EMAIL KW_AS char_or_var_vl KW_USING char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='@'; $$->s1=0; $$->filter=$5; $$->conv_type=$3; $$->emailAddress=0; } | TO_EMAIL char_or_var_vl KW_AS char_or_var_vl KW_USING char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='@'; $$->s1=0; $$->filter=$6; $$->conv_type=$4; $$->emailAddress=$2; } ; convert_cmd : CONVERT_REPORT rep_name conv_rep_conv { $$=new_convert_cmd($2, $3); } ; via_functionname: identifier { char buff[256]; SPRINTF2(buff,"%s%s", get_namespace($1),$1); $$=A4GL_new_literal_string(buff); } ; rout : fgl_expr_c { $$=$1; } ; free_rep_cmd : FREE_REPORT rep_name { $$=new_free_rep_cmd($2); } ; rep_name : identifier; op_values : | VALUES ; /* This isn't standard - but it looks pretty OUTPUT TO REPORT VALUES (...)... */ op_fgl_expr_list_ptr: {$$=0;} | fgl_expr_list_ptr {$$=$1;} ; output_cmd : OUTPUT_TO_REPORT atline rep_name op_values OPEN_BRACKET op_fgl_expr_list_ptr CLOSE_BRACKET { struct expr_str_list *l; set_cmdlineno($2); l=expand_variables_in_expr_str_list($6,0,1); $$=new_output_cmd($3,l); add_feature("USE_REPORT"); output_to_report_definition($3, l); ADDMAP("Output to report",$3); } ; finish_cmd : FINISH_REPORT atline rep_name rep_conv { set_cmdlineno($2); ADDMAP("Finish Report",$3); add_feature("USE_REPORT"); $$=new_finish_cmd($3,$4); } ; rep_conv: { $$=0; } | CONVERTING_TO_MANY { $$=malloc(sizeof(struct convert)); $$->towhat='M'; $$->s1=0; $$->conv_type=0; $$->filter=0; } | CONVERTING_TO char_or_var_vl KW_AS char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='F'; $$->s1=$2; $$->filter=0; $$->conv_type=$4; } | CONVERTING_VIA via_functionname { $$=malloc(sizeof(struct convert)); $$->towhat='f'; $$->s1=$2; $$->filter=0; $$->conv_type=0; } | CONVERTING_TO_PIPE char_or_var_vl KW_AS char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='|'; $$->s1=$2; $$->filter=0; $$->conv_type=$4; } | CONVERTING_TO_PRINTER KW_AS char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='P'; $$->conv_type=$3; $$->s1=0; $$->filter=0; } | CONVERTING_TO_EMAIL KW_AS char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='@'; $$->conv_type=$3; $$->s1=0; $$->filter=0; } | CONVERTING_TO_FILE char_or_var_vl KW_AS char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='F'; $$->s1=$2; $$->conv_type=$4; $$->filter=0; } | CONVERTING_TO char_or_var_vl KW_AS char_or_var_vl KW_USING char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='F'; $$->s1=$2; $$->conv_type=$4; $$->filter=$6; } | CONVERTING_TO_FILE char_or_var_vl KW_AS char_or_var_vl KW_USING char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='F'; $$->s1=$2; $$->conv_type=$4; $$->filter=$6; } | CONVERTING_TO_PIPE char_or_var_vl KW_AS char_or_var_vl KW_USING char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='|'; $$->s1=$2; $$->filter=$6; $$->conv_type=$4; } | CONVERTING_TO_PRINTER KW_AS char_or_var_vl KW_USING char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='P'; $$->s1=0; $$->filter=$5; $$->conv_type=$3; } | CONVERTING_TO_EMAIL KW_AS char_or_var_vl KW_USING char_or_var_vl { $$=malloc(sizeof(struct convert)); $$->towhat='@'; $$->s1=0; $$->filter=$5; $$->conv_type=$3; } ; term_rep_cmd : TERMINATE_REPORT rep_name { add_feature("USE_REPORT"); ADDMAP("Terminate Report",$2); $$=new_term_rep_cmd($2); } ; format_section: FORMAT EVERY_ROW { $$=malloc(sizeof(report_format_section)); $$->entries.entries_len=1; $$->entries.entries_val=malloc(sizeof($$->entries.entries_val[0]) * $$->entries.entries_len); $$->entries.entries_val[$$->entries.entries_len-1]=new_report_format_section_entry(RB_FORMAT_EVERY_ROW,0, NULL,0, yylineno); $$->lines_in_header=rep_struct.lines_in_header; $$->lines_in_first_header=rep_struct.lines_in_first_header; $$->lines_in_trailer=rep_struct.lines_in_trailer; } | FORMAT format_actions {$$=$2; $$->lines_in_header=rep_struct.lines_in_header; $$->lines_in_first_header=rep_struct.lines_in_first_header; $$->lines_in_trailer=rep_struct.lines_in_trailer; } ; format_actions : format_action { $$=malloc(sizeof(report_format_section)); $$->entries.entries_len=1; $$->entries.entries_val=malloc(sizeof($$->entries.entries_val[0]) * $$->entries.entries_len); $$->entries.entries_val[$$->entries.entries_len-1]=$1; } | format_actions format_action { $$=$1; $$->entries.entries_len=$1->entries.entries_len+1; $$->entries.entries_val=realloc($1->entries.entries_val, sizeof($$->entries.entries_val[0]) * $$->entries.entries_len); $$->entries.entries_val[$$->entries.entries_len-1]=$2; } ; format_action : FIRST_PAGE_HEADER { push_report_block("FIRST",'P',""); } atline commands_as_list { int lineno; char errmsg[256]; add_feature("REPORT_FIRST_PAGE_HEADER"); set_cmdlineno($3); rep_struct.lines_in_first_header=A4GL_check_lines_for_prints($4,&lineno,errmsg); pdf_rep_struct.lines_in_first_header=rep_struct.lines_in_first_header; $$=new_report_format_section_entry(RB_FIRST_PAGE_HEADER,NULL, $4,0,$3); } | PAGE_TRAILER { add_feature("REPORT_PAGE_TRAILER"); push_report_block("TRAILER",'T',""); } atline commands_as_list { int lineno; char errmsg[256]; set_cmdlineno($3); rep_struct.lines_in_trailer=A4GL_check_lines_for_prints($4,&lineno,errmsg); pdf_rep_struct.lines_in_trailer=rep_struct.lines_in_trailer; if (rep_struct.lines_in_trailer==-1) { yylineno=lineno; posterror=1; /* Ensure the error file is reread - because the linenumber here will be after the PAGE TRAILER - not at the IF statement */ a4gl_yyerror(errmsg); YYERROR; } $$=new_report_format_section_entry(RB_PAGE_TRAILER,NULL, $4,0,$3); } | PAGE_HEADER { push_report_block("HEADER",'p',""); } atline commands_as_list { int lineno; char errmsg[256]; add_feature("REPORT_PAGE_HEADER"); set_cmdlineno($3); rep_struct.lines_in_header=A4GL_check_lines_for_prints($4,&lineno,errmsg); pdf_rep_struct.lines_in_header=rep_struct.lines_in_header; $$=new_report_format_section_entry(RB_PAGE_HEADER,NULL, $4,0,$3); } | ON_EVERY_ROW { push_report_block("EVERY",'E',""); add_feature("ON_EVERY_ROW"); } atline commands_as_list { set_cmdlineno($3); $$=new_report_format_section_entry(RB_ON_EVERY_ROW,NULL, $4,0,$3); } | ON_LAST_ROW { push_report_block("LAST",'L',""); add_feature("ON_LAST_ROW"); } atline commands_as_list { set_cmdlineno($3); $$=new_report_format_section_entry(RB_ON_LAST_ROW,NULL, $4,0,$3); } | BEFGROUP variable_usage_expression { int a; char buff[80]; a=scan_orderby(current_orderby, $2); if (a<0) { SPRINTF1(buff,"%s is not in the order by list",get_variable_as_string_from_variable_usage_expression($2)); //@FIXME a4gl_yyerror(buff); YYERROR; } inc_var_usage($2); add_feature("REPORT_BEFORE_GROUP"); SPRINTF1(buff,"%d",a+1); push_report_block(buff,'B',$2); set_curr_block(a+1); } atline commands_as_list { int a; a=scan_orderby(current_orderby, $2)+1; set_cmdlineno($4); $$=new_report_format_section_entry(RB_BEFORE_GROUP_OF,$2, $5,a,$4); } | AFTGROUP variable_usage_expression { int a; char buff[80]; add_feature("REPORT_AFTER_GROUP"); inc_var_usage($2); a=scan_orderby(current_orderby, $2); if (a<0) { SPRINTF1(buff,"%s is not in the order by list",get_variable_as_string_from_variable_usage_expression($2)); a4gl_yyerror(buff); YYERROR; } SPRINTF1(buff,"%d",a+1); push_report_block(buff,'A',$2); set_curr_block(a+1); } atline commands_as_list { int a; set_cmdlineno($4); a=scan_orderby(current_orderby, $2)+1; $$=new_report_format_section_entry(RB_AFTER_GROUP_OF,$2, $5, a,$4); } ; need_cmd : NEED fgl_expr_c KWLINE { $$=new_need_cmd(chk_expr($2)); } ; op_lines : {strcpy($$,"0");} | KWLINE {strcpy($$,"1");} ; skip_cmd : SKIP atline fgl_expr_c op_lines { char buff[256]; strcpy(buff,$4); set_cmdlineno($2); if (buff[0]=='1') { $$=new_skip_cmd($3); } else { if (rep_type!=REP_TYPE_PDF) { a4gl_yyerror("SKIP BY is only in PDF reports"); YYERROR; } $$=new_skip_by_cmd($3); } } ; skip_to_top_cmd : SKIP_TO_TOP { $$=new_command(E_CMD_SKIP_TO_TOP_CMD);} ; skip_by_cmd : SKIP_BY pdf_expr { //double n; //n=atof($2); if (rep_type!=REP_TYPE_PDF) { a4gl_yyerror("SKIP BY is only in PDF reports"); YYERROR; } $$=new_skip_by_cmd($2); } ; skip_to_cmd : SKIP_TO pdf_expr { //double n; //n=atof($2); if (rep_type!=REP_TYPE_PDF) { a4gl_yyerror("SKIP TO is only in PDF reports"); YYERROR; } $$=new_skip_to_cmd($2); } ; opt_rep_expr_list : {$$=0;} | xrep_expr_list {$$=$1;} ; xrep_expr_list: rep_expr_list opt_print_at { $$=$1; } ; opt_print_at : | KW_AT nval { print_niy("PRINT AT..."); } ; print_cmd : PRINT atline opt_rep_expr_list opt_semi_b { char wt; doing_a_print=0; set_cmdlineno($2); $$=new_print_cmd( make_fgl_expr_list($3), $4); if (!isin_command("REPORT")) { a4gl_yyerror("PRINT can only be used in a report. Did you mean DISPLAY ?"); YYERROR; } wt=get_curr_report_stack_whytype_1(); if ($4==0) { if (wt=='P'||wt=='p'||wt=='T') { /* Page header or trailer */ if (isin_command("WHILE")||isin_command("FOR")) { a4gl_yyerror("You can't print within a loop in a PAGE HEADER or PAGE TRAILER"); YYERROR; } } } } ; pf_char_or_var: char_or_var_vl {$$=$1;} | OPEN_BRACKET char_or_var_vl CLOSE_BRACKET { $$=$2; } ; print_file_cmd : PRINT_FILE pf_char_or_var opt_semi_b { add_feature("PRINT_FILE"); if (!isin_command("REPORT")) { a4gl_yyerror("PRINT can only be used in a report. Did you mean DISPLAY ?"); YYERROR; } $$=new_print_file_cmd($2, $3); } ; print_img_cmd : PRINT_IMAGE blob_var_or_char_var_or_char_literal img_types opt_scaling opt_semi_b { if (!isin_command("REPORT")) { a4gl_yyerror("PRINT can only be used in a report. Did you mean DISPLAY ?"); YYERROR; } $$=new_print_img_cmd($2, chk_expr($4.s2), chk_expr($4.s1),$3,$5); } ; opt_scaling : { $$.s1=A4GL_new_literal_double_str("1.0"); $$.s2=A4GL_new_literal_double_str("1.0"); } | SCALED_BY fgl_expr_c { $$.s1=$2; $$.s2=$2; } | SCALED_BY fgl_expr_c KW_COMMA fgl_expr_c { $$.s1=$2; $$.s2=$4; } ; img_types : AS_TIFF {strcpy($$,"tiff");} | AS_GIF {strcpy($$,"gif");} | AS_PNG {strcpy($$,"png");} | AS_JPEG {strcpy($$,"jpeg");} ; blob_var_or_char_var_or_char_literal : variable_usage_expression { int vtype; char errbuff[256]; vtype=get_variable_dtype_from_variable_usage_expression(errbuff,$1) ; if (vtype==-1) { a4gl_yyerror(errbuff); YYERROR; } else { vtype=vtype&DTYPE_MASK; if (vtype!=DTYPE_BYTE&&vtype!=DTYPE_TEXT && vtype!=DTYPE_CHAR && vtype!=DTYPE_VCHAR) { a4gl_yyerror("Only Blobs and character strings (containing a path) may be printed..."); YYERROR; } } $$=$1; inc_var_usage($$); } | CHAR_VALUE { if (strcmp($1,"\"\"")==0) { a4gl_yyerror("You can't use an empty character string here."); YYERROR; } else { $$=A4GL_new_literal_string(A4GL_strip_quotes($1)); } } ; opt_semi_b : { $$=EB_FALSE; } | SEMICOLON { $$=EB_TRUE; }; rep_expr_list : rep_expr_p { $$=A4GL_new_ptr_list($1); } | rep_expr_list KW_COMMA rep_expr_p { $$=A4GL_new_append_ptr_list($1,$3); } ; rep_expr_p : fgl_expr_c op_wordwrap { if ($2==0) { $$=$1; } else { $$=A4GL_new_expr_wordwrap($1,$2); } } ; rep_agg : KW_SUM atline OPEN_BRACKET fgl_expr_c CLOSE_BRACKET rep_where { long a; $$=add_report_agg('S',$4,$6,racnt,&a,$2); racnt+=a; } | COUNT_MULTIPLY atline rep_where { long a; $$=add_report_agg('C',0,$3,racnt,&a,$2); racnt+=a; } | COUNT atline OPEN_BRACKET KW_MULTIPLY CLOSE_BRACKET rep_where { long a; $$=add_report_agg('C',0,$6,racnt,&a,$2); racnt+=a; } | PERCENT atline OPEN_BRACKET KW_MULTIPLY CLOSE_BRACKET rep_where { long a; $$=add_report_agg('P',$4,$6,racnt,&a,$2); racnt+=a; } | AVERAGE atline OPEN_BRACKET fgl_expr_c CLOSE_BRACKET rep_where { long a; $$=add_report_agg('A',$4,$6,racnt,&a,$2); racnt+=a; } | AVG atline OPEN_BRACKET fgl_expr_c CLOSE_BRACKET rep_where { long a; $$=add_report_agg('A',$4,$6,racnt,&a,$2); racnt+=a; } | XMIN atline OPEN_BRACKET fgl_expr_c CLOSE_BRACKET rep_where { long a; $$=add_report_agg('N',$4,$6,racnt,&a,$2); racnt+=a; } | XMAX atline OPEN_BRACKET fgl_expr_c CLOSE_BRACKET rep_where { long a; $$=add_report_agg('X',$4,$6,racnt,&a,$2); racnt+=a; } ; op_output_section : {$$=0;} | OUTPUT output_commands { $$=malloc(sizeof(startrep)); $$->with_page_length=rep_struct.page_length; $$->with_left_margin=rep_struct.left_margin; $$->with_right_margin= rep_struct.right_margin; $$->with_top_margin= rep_struct.top_margin; $$->with_bottom_margin= rep_struct.bottom_margin; $$->with_top_of_page= strdup(rep_struct.top_of_page); $$->towhat=rep_struct.output_mode; $$->s1=rep_struct.output_loc; } ; output_commands : output_command | output_commands output_command; output_command : LEFT_MARGIN INT_VALUE {rep_struct.left_margin=atoi($2);} | RIGHT_MARGIN INT_VALUE {rep_struct.right_margin=atoi($2);} | TOP_MARGIN INT_VALUE {rep_struct.top_margin=atoi($2);} | BOTTOM_MARGIN INT_VALUE {rep_struct.bottom_margin=atoi($2);} | PAGE_LENGTH INT_VALUE {rep_struct.page_length=atoi($2);} | REPORT_TO_PRINTER {rep_struct.output_mode='R';rep_struct.output_loc=A4GL_new_expr_simple(ET_EXPR_REPORT_PRINTER);} | REPORT_TO_FILE CHAR_VALUE {rep_struct.output_mode='F';rep_struct.output_loc=A4GL_new_literal_string(A4GL_strip_quotes($2)); } | REPORT_TO CHAR_VALUE {rep_struct.output_mode='F';rep_struct.output_loc=A4GL_new_literal_string(A4GL_strip_quotes($2)); } | REPORT_TO ensured_variable_usage_expression {rep_struct.output_mode='F';rep_struct.output_loc=$2; } | REPORT_TO_PIPE CHAR_VALUE {rep_struct.output_mode='P';rep_struct.output_loc=A4GL_new_literal_string(A4GL_strip_quotes($2));} | REPORT_TO_UI {rep_struct.output_mode='U';rep_struct.output_loc=A4GL_new_expr_simple(ET_EXPR_REPORT_UI);} | REPORT_TO_PIPE ensured_variable_usage_expression {rep_struct.output_mode='P';rep_struct.output_loc=$2;} | TOP_OF_PAGE CHAR_VALUE {strcpy(rep_struct.top_of_page,$2);} ; pdf_output_commands : pdf_output_command | pdf_output_commands pdf_output_command; nval: nval_number KW_POINTS {SPRINTF1($$,"-%f",atof($1));} | nval_number INCHES {SPRINTF1($$,"-%f",atof($1)*72.0); } | nval_number CM {SPRINTF1($$,"-%f",atof($1)*28.3465); } | nval_number MM {SPRINTF1($$,"-%f",atof($1)*2.83465);} | nval_number {SPRINTF1($$,"%f",atof($1));} ; nval_number: real_number | INT_VALUE ; pdf_op_output_section : {$$=0;} | OUTPUT pdf_output_commands { resize_paper(&pdf_rep_struct); $$=malloc(sizeof(pdf_startrep)); $$->towhat=pdf_rep_struct.output_mode; $$->s1=pdf_rep_struct.output_loc; $$->with_page_length=pdf_rep_struct.page_length; $$->with_page_width=pdf_rep_struct.page_width; $$->with_left_margin=pdf_rep_struct.left_margin; $$->with_right_margin=pdf_rep_struct.right_margin; $$->with_top_margin=pdf_rep_struct.top_margin; $$->with_bottom_margin=pdf_rep_struct.bottom_margin; $$->fontname=strdup(pdf_rep_struct.font_name); $$->fontsize=pdf_rep_struct.font_size; $$->papersize=pdf_rep_struct.paper_size; $$->bluebar.style=pdf_rep_struct.bluebar_style; $$->bluebar.r=pdf_rep_struct.bluebar_r; $$->bluebar.g=pdf_rep_struct.bluebar_g; $$->bluebar.b=pdf_rep_struct.bluebar_b; $$->pageheadersize=0.0; $$->firstpageheadersize=0.0; $$->pagetrailersize=0.0; $$->isdefault=EB_NOTSET; $$->ascii_height=EB_NOTSET; $$->ascii_width=EB_NOTSET; } ; pdf_output_command : LEFT_MARGIN nval {pdf_rep_struct.left_margin=atof($2); #ifdef DEBUG A4GL_debug("Left margin=%s\n",$2); #endif } | RIGHT_MARGIN nval {pdf_rep_struct.right_margin=atof($2);} | TOP_MARGIN nval {pdf_rep_struct.top_margin=atof($2);} | BOTTOM_MARGIN nval {pdf_rep_struct.bottom_margin=atof($2);} | PAGE_LENGTH nval {pdf_rep_struct.page_length=atof($2);} | PAGE_WIDTH nval {pdf_rep_struct.page_width=atof($2);} | FONT_NAME CHAR_VALUE {strcpy(pdf_rep_struct.font_name,$2);} | FONT_SIZE nval {pdf_rep_struct.font_size=atof($2);} | PAPER_SIZE_IS_A4 {pdf_rep_struct.paper_size=1;} | PAPER_SIZE_IS_LETTER {pdf_rep_struct.paper_size=2;} | PAPER_SIZE_IS_LEGAL {pdf_rep_struct.paper_size=3;} | PAPER_SIZE_IS_A5 {pdf_rep_struct.paper_size=5;} | PAPER_SIZE_IS_A4_L {pdf_rep_struct.paper_size=-1;} | PAPER_SIZE_IS_LETTER_L {pdf_rep_struct.paper_size=-2;} | PAPER_SIZE_IS_LEGAL_L {pdf_rep_struct.paper_size=-3;} | PAPER_SIZE_IS_A5_L {pdf_rep_struct.paper_size=-5;} | PAGE_TRAILER_SIZE nval | PAGE_HEADER_SIZE nval | FIRST_PAGE_HEADER_SIZE nval | REPORT_TO CHAR_VALUE {pdf_rep_struct.output_mode='F';pdf_rep_struct.output_loc=A4GL_new_literal_string(A4GL_strip_quotes($2));} | REPORT_TO_PIPE CHAR_VALUE {pdf_rep_struct.output_mode='P';pdf_rep_struct.output_loc=A4GL_new_literal_string(A4GL_strip_quotes($2));} | KW_DEFAULT | ASCII_HEIGHT_ALL | ASCII_WIDTH_ALL | BLUEBAR { pdf_rep_struct.bluebar_style=E_BLUEBAR_RECTANGLE; } | BLUEBAR_STYLE_EQUAL_RECTANGLE { pdf_rep_struct.bluebar_style=E_BLUEBAR_RECTANGLE; } | BLUEBAR_STYLE_EQUAL_LINE { pdf_rep_struct.bluebar_style=E_BLUEBAR_5LINE; } | BLUEBAR_COLOR_EQUAL NUMBER_VALUE KW_COMMA NUMBER_VALUE KW_COMMA NUMBER_VALUE { pdf_rep_struct.bluebar_style=E_BLUEBAR_RECTANGLE; pdf_rep_struct.bluebar_r=atof($2); pdf_rep_struct.bluebar_g=atof($4); pdf_rep_struct.bluebar_b=atof($6); } | BLUEBAR_STYLE_EQUAL_RECTANGLE_COLOR_EQUAL NUMBER_VALUE KW_COMMA NUMBER_VALUE KW_COMMA NUMBER_VALUE { pdf_rep_struct.bluebar_style=E_BLUEBAR_RECTANGLE; pdf_rep_struct.bluebar_r=atof($2); pdf_rep_struct.bluebar_g=atof($4); pdf_rep_struct.bluebar_b=atof($6); } | BLUEBAR_STYLE_EQUAL_LINE_COLOR_EQUAL NUMBER_VALUE KW_COMMA NUMBER_VALUE KW_COMMA NUMBER_VALUE { pdf_rep_struct.bluebar_style=E_BLUEBAR_5LINE; pdf_rep_struct.bluebar_r=atof($2); pdf_rep_struct.bluebar_g=atof($4); pdf_rep_struct.bluebar_b=atof($6); } ; op_rep_order_by : { $$=new_report_orderby_section(REPORT_ORDERBY_IMPLICIT, NULL); } | rep_order_by ; rep_order_by : ORDER KW_BY obind_var_list_ord { add_feature("REPORT_ORDER_BY"); $$=new_report_orderby_section(REPORT_ORDERBY, $3); /* We are marking the variables as being used *just* for ORDER BY, not ORDER EXTERNAL BY as the variables are not *really* used for the ORDER EXTERNAL - its just indicative of the order */ inc_var_assigned_from_binding_list($3); inc_var_usage_from_binding_list($3); } | ORDER_EXTERNAL_BY obind_var_list_ord { $$=new_report_orderby_section(REPORT_ORDERBY_EXTERNAL, $2); } ; rep_or_localrep: REPORT {$$=EB_FALSE;} | LOCAL_REPORT {$$=EB_TRUE;} ; report_def : op_doc4gl_comment rep_or_localrep { add_feature("USE_REPORT"); A4GL_clr_extra_warnings(); //if (class_cnt>1) { a4gl_yyerror("You've already defined a class - you can't do any more now"); } rep_type=REP_TYPE_NORMAL; clr_function_constants (); clr_variable(); clr_call_list(); lastlineno=yylineno; init_report_structure(&rep_struct); } identifier atline OPEN_BRACKET { inc_report_cnt(); SPRINTF1(curr_func,"%s",$4); ADDMAP_MODULE("Define Report",curr_func); map_report_start(curr_func); //variable_action(-1,$4,"","","add_function"); set_curr_rep_name($4); push_blockcommand("REPORT"); } op_param_var_list CLOSE_BRACKET define_section { if (check_for_bad_report_variables($10)) { a4gl_yyerror("Invalid variable name - you can't use PAGENO or LINENO for your own variables in a repor"); YYERROR; } } op_output_section op_rep_order_by { char errbuff[256]; expr_str_list *expanded_parameters; add_report_definition($4,$8); if (!check_parameters(errbuff,$10, $8)) { a4gl_yyerror(errbuff); YYERROR; } expanded_parameters=expand_parameters($10,$8); inc_var_assigned_from_binding_list(expanded_parameters); set_report_orderby($10, $8, $13); } format_section END_REPORT { pop_blockcommand("REPORT"); A4GL_chk_and_clr_labels(); map_report_end(); $$=new_report_definition($4, $2,$8, $12, $13, $15 ,$5,$1) ; //set_variables(&$$->module_entry_u.report_definition.variables,'L'); merge_variable_list(&$$->module_entry_u.report_definition.variables, $10); sort_variables_v(&$$->module_entry_u.report_definition.variables); clr_function_constants(); A4GL_chk_and_clr_labels(); rep_type=REP_TYPE_NOTSET; //variable_add_function($$); $$->module_entry_u.report_definition.expanded_parameters=expand_parameters( &$$->module_entry_u.report_definition.variables, $$->module_entry_u.report_definition.parameters); } ; rep_where : { strcpy($$,""); $$=0; } | WHERE fgl_expr_c { $$=$2; } ; pdf_specific_cmd : SET_COLOR fgl_expr_c KW_COMMA fgl_expr_c KW_COMMA fgl_expr_c { $$=new_pdf_specific_cmd("setcolor",NULL, $2,$4,$6,NULL); } | SET_STROKE_COLOR fgl_expr_c KW_COMMA fgl_expr_c KW_COMMA fgl_expr_c { $$=new_pdf_specific_cmd("setstrokecolor",NULL, $2,$4,$6,NULL); } | SET_FILL_COLOR fgl_expr_c KW_COMMA fgl_expr_c KW_COMMA fgl_expr_c { $$=new_pdf_specific_cmd("setfillcolor",NULL, $2,$4,$6,NULL); } | STROKE { $$=new_pdf_specific_cmd("stroke",NULL, NULL); } | SET_PARAMETER fgl_expr_c KW_COMMA fgl_expr_c { $$=new_pdf_specific_cmd("set_parameter",NULL, $2,$4,NULL); } | MOVE_TO fgl_expr_c KW_COMMA fgl_expr_c { $$=new_pdf_specific_cmd("moveto",NULL, report_position_expr_x($4) , report_position_expr_y($2),NULL); } | MOVE_TO_TOP fgl_expr_c KW_COMMA fgl_expr_c { $$=new_pdf_specific_cmd("moveto_top",NULL, report_position_expr_x($4), report_position_expr_y($2),NULL); } | LINE_TO fgl_expr_c KW_COMMA fgl_expr_c { $$=new_pdf_specific_cmd("lineto",NULL, report_position_expr_x($4), report_position_expr_y($2),NULL); } | LINETO_TOP fgl_expr_c KW_COMMA fgl_expr_c { $$=new_pdf_specific_cmd("lineto_top",NULL, report_position_expr_x($4), report_position_expr_y($2),NULL); } | BOOKMARK fgl_expr_c KW_COMMA fgl_expr_c opt_return { if ($5==NULL) { $$=new_pdf_specific_cmd("add_bookmark_no_ret",$5, $4,$2,NULL); } else { $$=new_pdf_specific_cmd("add_bookmark",$5, $4,$2,NULL); } } | BOOKMARK fgl_expr_c opt_return { struct expr_str *p; p=A4GL_new_literal_long_long(0); if ($3==NULL) { $$=new_pdf_specific_cmd("add_bookmark_no_ret",$3, $2,p,NULL); } else { $$=new_pdf_specific_cmd("add_bookmark",$3, $2,p,NULL); } } | BARCODETYPE fgl_expr_c { $$=new_pdf_specific_cmd("barcode_type",NULL, $2,NULL); } | BARCODE fgl_expr_c KW_WIDTH fgl_expr_c KW_HEIGHT fgl_expr_c { $$=new_pdf_specific_cmd("barcode",NULL, report_position_current_x(), report_position_current_y(), $4, $6, $2, NULL); } | BARCODE_NO_TEXT fgl_expr_c KW_WIDTH fgl_expr_c KW_HEIGHT fgl_expr_c { $$=new_pdf_specific_cmd("barcode_no_text",NULL, report_position_current_x(), report_position_current_y(), $4, $6, $2, NULL); } | BARCODE fgl_expr_c KW_AT fgl_expr_c KW_COMMA fgl_expr_c KW_WIDTH fgl_expr_c KW_HEIGHT fgl_expr_c { $$=new_pdf_specific_cmd("barcode",NULL, report_position_expr_x($6), report_position_expr_y($4), $8, $10, $2, NULL); } | BARCODE_NO_TEXT fgl_expr_c KW_AT fgl_expr_c KW_COMMA fgl_expr_c KW_WIDTH fgl_expr_c KW_HEIGHT fgl_expr_c { $$=new_pdf_specific_cmd("barcode_no_text",NULL, report_position_expr_x($6), report_position_expr_y($4), $8, $10, $2, NULL); } | FILL_STROKE { $$=new_pdf_specific_cmd("fill_stroke",NULL, NULL); } | KW_FILL { $$=new_pdf_specific_cmd("fill",NULL, NULL); } | SET_TEXT_FORMAT fgl_expr_c { $$=new_pdf_specific_cmd("set_text_format",NULL, $2,NULL); } | SET_FONT_SIZE fgl_expr_c { $$=new_pdf_specific_cmd("set_font_size",NULL, $2,NULL); } | SET_FONT_NAME fgl_expr_c { $$=new_pdf_specific_cmd("set_font_name",NULL, $2,NULL); } ; pause_cmd : PAUSE pause_msg { if (!in_command("REPORT")) { a4gl_yyerror("PAUSE can only be used in reportes"); YYERROR; } $$=new_pause_cmd($2); } ; pause_msg : {$$=0;} | char_or_var_vl {$$=$1;} ; pdf_rep_or_localrep: PDF_REPORT {$$=EB_FALSE;} | LOCAL_PDF_REPORT {$$=EB_TRUE;} ; pdf_report_def : op_doc4gl_comment pdf_rep_or_localrep { A4GL_clr_extra_warnings(); //if (class_cnt>1) { a4gl_yyerror("You've already defined a class - you can't do any more now"); } rep_type=REP_TYPE_PDF; clr_function_constants(); clr_variable(); clr_call_list(); lastlineno=yylineno; pdf_init_report_structure(&pdf_rep_struct); } identifier atline OPEN_BRACKET { inc_report_cnt(); SPRINTF1(curr_func,"%s",$4); ADDMAP_MODULE("Define PDF Report",curr_func); set_curr_rep_name($4); push_blockcommand("REPORT"); } op_param_var_list CLOSE_BRACKET define_section { //set_local_variables($10); if (check_for_bad_report_variables($10)) { a4gl_yyerror("Invalid variable name - you can't use PAGENO or LINENO for your own variables in a report"); YYERROR; } } pdf_op_output_section op_rep_order_by { char errbuff[256]; if (!check_parameters(errbuff,$10, $8)) { a4gl_yyerror(errbuff); YYERROR; } set_report_orderby($10, $8, $13); } format_section END_REPORT { pop_blockcommand("REPORT"); $$=new_pdf_report_definition($4, $2,$8, $12, $13, $15,$5 ,$1) ; //set_variables(&$$->module_entry_u.pdf_report_definition.variables,'L'); merge_variable_list(&$$->module_entry_u.pdf_report_definition.variables, $10); sort_variables_v(&$$->module_entry_u.pdf_report_definition.variables); $$->module_entry_u.pdf_report_definition.expanded_parameters=expand_parameters( &$$->module_entry_u.pdf_report_definition.variables, $$->module_entry_u.pdf_report_definition.parameters); clr_function_constants(); A4GL_chk_and_clr_labels(); rep_type=REP_TYPE_NOTSET; //variable_add_function($$); } ; pdf_functions_expr : PDF_FUNCTION OPEN_BRACKET CHAR_VALUE KW_COMMA opt_func_call_args CLOSE_BRACKET { if (rep_type==REP_TYPE_NORMAL) { a4gl_yyerror("You can't use a pdf function in a non-pdf report"); $$=0; } else { // REP_TYPE_PDF or REP_TYPE_NOTSET(a function) ADDMAP("CALL",$3); $$=A4GL_new_expr_pdf_fcall($3,$5,A4GL_compiling_module_basename(),lastlineno,get_namespace($3)); } } ; op_wordwrap: {$$=0;} | KW_WORDWRAP { $$=A4GL_new_literal_long_long(0);} /* @ FIXME - use default right margin */ | KW_WORDWRAP RIGHT_MARGIN fgl_expr_c { $$=$3; } ; /* ============================ report.rule ========================== */