Please review any and all PUBLIC repositories, groups and associate files. These allow anyone on the Internet to access without authentication. Repository and group owners are responsible for their content and permission settings. Go to your project(s), click on Settings > General and expand the "Visibility, project features, permissions" to change this setting.

Introduction of SORT option for SHOW Table and SHOW Chart operation

parent d92d9483
This diff is collapsed.
......@@ -39,7 +39,7 @@
##
#thread
-- called from #coordinate_composition, Quantified_bool_expr in #bool_expr3,
-- called from #coordination_source, Quantified_bool_expr in #bool_expr3,
-- and aggregate operations
( $var:= #variable ! -- returns 'abc_variable'
......@@ -54,7 +54,7 @@
!
$a /#error( $a err2 ); FAIL/ )
[ 'FROM' $source:= #event_instance ]
[ $f:= 'FROM' $source:= #event_instance ]
-- the default for source is FROM THIS
/IF NOT $source ->
......@@ -129,8 +129,9 @@
-- maintain the $source_list
$old_source_list:= COPY(LAST #MP $source_list)/
(+ $coord++:= #coordination_source
/LAST #MP $source_list ++:= $coord/ -- adjust variable list
(+ $cs:= #coordination_source
/$coord++:= $cs;
LAST #MP $source_list ++:= $coord/ -- adjust variable list
-- also calculates LAST #top_composition_operation $asynchronous_source_count for <!>
+',')
......@@ -199,7 +200,7 @@
#event_reshuffling_option
'<' '!' [ $chain:= CHAIN ] '>'
-- asynchronous reshufflinh is detected
-- asynchronous reshuffling is detected
/IF LAST #MP $coordination_nesting > 1 ->
#error( $ err43 ); FAIL
FI;
......@@ -514,7 +515,8 @@
#graph_processing !
#graph_operation !
#loop_over_graph !
#FOR_loop )
#FOR_loop !
#add_tuple_command )
)
#semicolon
+)
......
......@@ -64,7 +64,6 @@
-- +) .)
-- .>
-- *>
-- used by #prepare_share_all in second_pass.rig to check whether shared events have been defined
-- $share_all_ops: <* work_name: <. operation: SHARE_ALL,
-- work: work_name,
......@@ -101,6 +100,8 @@
--
-- requested for Activity Diagrams
-- $AD_list: <* event_name: (ROOT ! composite) *> go to the event trace screen
-- $TABLE_list: <. table_name: table_description -- see $res in #VIEW_description
-- $CHART_list: <. chart_name: chart_description -- see $res in #VIEW_description
-- $global_SAY_present: (T ! NULL) to create global_SAY list in the .cpp file
--
-- $node_variables: <* variable_name: #unique_number() *>
......@@ -155,7 +156,7 @@
--
------------- VIEW object descriptions -----------------------------
-- $global_flag: (true ! false) if GLOBAL section is present
-- $view_objects: <* object_name: ( <. type: ( REPORT ! GRAPH ),
-- $view_objects: <* object_name: ( <. type: ( REPORT ! GRAPH ! TABLE),
-- name: $report_name,
-- work: work_name, -- for class generation
-- work2: $work2 -- for container name
......@@ -230,7 +231,9 @@
-- plain_attributes: $BUILD_block.plain_attributes,
-- global: $global -- list of operations
-- .>
IF NOT $roots ->
#error( $input_file err90 ); FAIL
FI;
--*********** 2nd pass, insert/expand composite events,
-- create $new_root_table, $new_composites
......@@ -274,6 +277,8 @@
view_objects: $view_objects,
global_flag: $global_flag, -- (true ! false)
AD_list: $AD_list,
TABLE_list: $TABLE_list,
CHART_list: $CHART_list,
global_SAY_present: $global_SAY_present
.>;
......@@ -427,7 +432,7 @@
'PRECEDES' !
'REJECT' ! 'REPORT' ! 'RESET' ! 'ROOT' !
'SAY' ! 'SET' ! 'SHARE' ! 'SHOW' ! 'SUCH' ! 'SUM' ! 'start' ! 'STEP' !
'THAT' ! 'THEN' ! 'THIS' ! 'TIMES' ! trace_id ! 'true' !
'TABLE' ! 'TABS' ! 'THAT' ! 'THEN' ! 'THIS' ! 'TIMES' ! trace_id ! 'true' !
'WHEN' ! 'WITHIN' !
'$$scope'
)
......
......@@ -99,31 +99,6 @@ assignment_op: $assignment_op, -- for :=, +=, -=, *=, /=, AND=, OR=
-------------------------------------------------------------------------------------
#check_selected_lists_for_same_length
$source_list
/GEN<<;
IF #LEN($source_list) > 1 ->
GEN<< ' //' check that selected lists are of the same length;
GEN<< @ ' if(';
$first_arg:= #IMPLODE($source_list[1][1] '_list.size()!= ');
$i:= 2;
$or_op:= ' ';
LOOP
IF $i > #LEN($source_list) -> BREAK FI;
GEN<] $or_op @ $first_arg $source_list[$i][1] '_list.size() ';
$i +:= 1;
$or_op:= '||';
END;
GEN<] ')';
GEN<< ' { throw failed;};';
GEN<<;
ELSIF T ->
GEN<< ' // single source, no list length check needed'
FI/
##
----------------------------------------------------------------
#generate_aggregate_functions
<* $work_name: #generate_aggregate_function *>
##
......
-- MP4_parse_view_objects.rig
-- Created by Mikhail Auguston on 12/3/18.
-- last updated 02/13/2019
-- last updated 11/11/2019
--------------------------------------------
---- parsing view objects and commands -----
--------------------------------------------
......@@ -10,24 +10,22 @@
LAST #MP $global_flag := 'true'/
(*
$elt_list !.:=
( #VIEW_description !
( #VIEW_description ! -- add to operations,
-- since title may be recalculated
#global_composition_operation !
$x /#error( $x err67 ); FAIL/ ) -- undefined operation in GLOBAL
#semicolon
( #semicolon ! / #error( $x err4); FAIL/ )
*)
/RETURN $elt_list/
##
#VIEW_description
$res:= #report_or_graph_description
$object:= ( REPORT ! GRAPH ! TABLE ! (BAR CHART))
-- $object = CHART for BAR CHART
/IF LAST #MP $mode = block ->
#error( $res.operation err69 ); FAIL
FI;
RETURN $res ++ <. mode: LAST #MP $mode .>/
##
#error( $object err80 ); FAIL
FI/
#report_or_graph_description
$object:= ( REPORT ! GRAPH)
$object_name:= $Id
/IF LAST #MP $view_objects.$object_name ->
#error( $object_name err66 ); FAIL
......@@ -36,10 +34,21 @@
/$title:= (. ' ' .)/ -- default title
[ TITLE $title:= #string_constructor
(';' ! $a /#error( $a err4 ); FAIL/) ]
[ V'($object = TABLE)
TABS
$tab_list := #tab_list
#semicolon
]
[ V'($object = CHART)
$chart:= #process_CHART
]
( '}' ! $a /#error( $a err22 ); FAIL/)
/$work:= #IMPLODE( $object '_' #unique_number() '_' #unique_number());
/$work:= #IMPLODE( $object '_' #unique_number() );
-- for class name
$un := #unique_number();
IF $object = TABLE AND NOT $tab_list ->
#error( $object err83); FAIL FI;
$res:= <. operation: #IMPLODE( $object '_description'),
type: $object,
name: $object_name,
......@@ -48,11 +57,86 @@
work: $work,
unique_num: $un,
list: $title,
mode: LAST #MP $mode .> ;
mode: LAST #MP $mode,
-- specific for Table
tab_list: $tab_list -- for TABLE
.> ;
-- add specific for CHART fields, if any
$res ++:= $chart;
-- add tis Chart to the Table on which it is based
IF $chart ->
$charts:= LAST #MP $TABLE_list.($chart.source_table_name).chart_list;
$charts ++:= <. $object_name: $res.work2 .>;
LAST #MP $TABLE_list.($chart.source_table_name) ++:=
<. chart_list: $charts .>;
LAST #MP $view_objects.($chart.source_table_name) ++:=
<. chart_list: $charts .>
FI;
LAST #MP $view_objects ++:= <. $object_name: $res .>;
IF $object = TABLE ->
LAST #MP $TABLE_list ++:= <. $object_name: $res .>;
FI;
IF $object = CHART ->
LAST #MP $CHART_list ++:= <. $object_name: $res .>;
FI;
RETURN $res/
##
#tab_list
-- tab declarations
(+
$type:= ( number ! string !
$x:= S'($$ <> ';') /#error( $x err81 ); FAIL/ )
$tab_name := $Id
/IF $list.$tab_name ->
#error( $type err86); FAIL -- double defined tab
FI;
$list ++:= <. $tab_name: $type .> /
+',')
/RETURN $list/
##
#process_CHART
( 'FROM' ! $a /#error( $a err87); FAIL/ )
$table_name:= $Id
/IF NOT LAST #MP $TABLE_list.$table_name ->
#error( $table_name err82); FAIL -- table not defined
FI/
(';' ! $a /#error( $a err4 ); FAIL/)
( 'X_AXIS' ! $a /#error( $a err88); FAIL/ )
$x_tab_name := $Id
/IF NOT LAST #MP $TABLE_list.$table_name.tab_list.$x_tab_name ->
#error( $x_tab_name err84); FAIL -- x_tab not defined in Table
FI;
$list ++:= <. $x_tab_name:
LAST #MP $TABLE_list.$table_name.tab_list.$x_tab_name .>/
(';' ! $a /#error( $a err4 ); FAIL/)
( ('TABS'
(+ $tab_name := $Id
/IF NOT LAST #MP $TABLE_list.$table_name.tab_list.$tab_name ->
#error( $tab_name err84); FAIL -- tab not defined in Table
FI;
$list ++:= <. $tab_name:
LAST #MP $TABLE_list.$table_name.tab_list.$tab_name .> /
+',')
(';' ! $a /#error( $a err4 ); FAIL/) ) !
( V'($$<> TABS) -- copy all tabs from table, by default
/$list ++:= LAST #MP $TABLE_list.$table_name.tab_list/ )
)
[ $rotate:= ROTATE
(';' ! $a /#error( $a err4 ); FAIL/) ]
/RETURN <. source_table_name: $table_name,
x_axis_tab: $x_tab_name,
chart_tab_list: $list, -- includes also x_tab
rotate: $rotate .>/
##
#global_composition_operation
$res:= (#view_construction_operation ! -- need to preempt SAY
......@@ -98,8 +182,8 @@
$res:=
( #increment_report_command !
#clear_or_show_command !
#graph_processing
)
#graph_processing !
#add_tuple_command )
/RETURN $res ++ <. mode: LAST #MP $mode .>/
##
......@@ -127,12 +211,23 @@
IF NOT $type ->
#error( $Id err67 ); FAIL
FI;
RETURN <. operation: $op,
IF $op = CLEAR AND
LAST #MP $view_objects.$Id.operation = CHART_description ->
#error( $Id err89 ); FAIL
FI;/
[ $sorted:= SORT
/IF NOT( LAST #MP $view_objects.$Id.operation = CHART_description OR
LAST #MP $view_objects.$Id.operation = TABLE_description) ->
#error( $Id err91 ); FAIL
FI/ ]
/RETURN <. operation: $op,
name: $Id,
object_type: $type,
work: #IMPLODE( $op '_' #unique_number() '_'
#unique_number()),
work2: LAST #MP $view_objects.$Id.work2
work2: LAST #MP $view_objects.$Id.work2,
sorted: $sorted -- only for TABLE and CHART
.>/
##
......@@ -301,3 +396,35 @@
(LAST #graph_processing $graph_name).work2
.> /
##
#add_tuple_command
$table_name:= $Id '<' '|' $tuple:= #tuple
/IF NOT LAST #MP $TABLE_list.$table_name ->
#error($table_name err82); FAIL FI; -- TABLE name not found
$work:= #IMPLODE( 'add_tuple_command_' #unique_number() );
RETURN <. operation: add_tuple,
tuple: $tuple,
work_table_name: LAST #MP $view_objects.$table_name.work2,
work: $work,
table_name: $table_name
.>/
##
#tuple
(+ $tab_name := $Id
/IF NOT LAST #MP $TABLE_list.(LAST #add_tuple_command $table_name).tab_list.$tab_name ->
#error($tab_name err84); FAIL FI/ -- tab not defined
':'
( $e:= #expression !
( 'SAY' $t:= #string_constructor /$e:= <. type: string,
body: $t .>/) )
-- tab value may be numeric expression or string
/IF LAST #MP $TABLE_list.(LAST #add_tuple_command $table_name).tab_list.$tab_name <> $e.type ->
#error($tab_name err85); FAIL FI; -- inconsistent tab type
$res !.:= (. $tab_name $e .) /
+',')
/RETURN $res/
##
......@@ -29,11 +29,14 @@
#generate_global_composition_operation
(#generate_view_object_title_update !
#generate_report_increment !
#generate_add_tuple !
#generate_global_SAY_message !
#generate_view_object_SHOW ! -- unique item number has been added
#generate_view_object_CLEAR_op !
#generate_WITHIN !
#generate_limited_simple_action_list !
#generate_find_last_or_create_new_node !
#generate_add_edge !
<.operation: Activity_Diagram_description .> !
......@@ -75,10 +78,17 @@
/GEN<<'//*****' VIEW object containers '*****'/
<* $object_name: ( <. name: $report_name,
work2: $work_name,
[tab_list: $tab_list
/#generate_tuple_class($work_name $tab_list)/
], -- for TABLE only
type: ( REPORT
/GEN<< report_object @ $work_name ';'/ !
GRAPH
/GEN<< graph_object @ $work_name ';'/ )
/GEN<< graph_object @ $work_name ';'/ !
TABLE
/GEN<< table_object @ $work_name ';'/ !
CHART
/GEN<< chart_object @ $work_name ';'/ )
.> !
<. AD: $a .> !
......@@ -86,12 +96,36 @@
$a /GEN<< '//' view object $object_name not yet implemented/
)
*>
/GEN<< 'vector<string> global_SAY_list_999999;';
/GEN<<;
GEN<< 'vector<string> global_SAY_list_999999;';
GEN<</
##
#generate_tuple_class
$work_name
/GEN<<;
GEN<< @ 'class tuple_type_' $work_name '{ public: '/
$tab_tree:=
<* $tab_name: (number /GEN<< ' float'/ !
string /GEN<< ' string'/ )
/GEN<] @ 'tab_' $tab_name ';'/
*>
/#generate_tuple_class_constructor($work_name $tab_tree);
GEN<<'};'/
##
#generate_tuple_class_constructor
$work_name / GEN<< @ ' tuple_type_' $work_name '(){'/
<* $tab_name: ( number /GEN<< @ ' tab_' $tab_name '= 0;'/ !
string /GEN<< @ ' tab_' $tab_name '= "";'/ )
*>
/GEN<] '};'/
##
#generate_view_object_title_update
<. operation: (REPORT_description ! GRAPH_description),
<. operation: (REPORT_description ! GRAPH_description ! TABLE_description ! CHART_description),
name: $object_name
/GEN<< ' { //' $object_name title generation/,
work2: $work2, -- object #unique_number() '_' $object_name
......@@ -112,12 +146,32 @@
<. operation: SHOW,
work2: $work2, -- object's work name
name: $object_name /GEN<< ' // SHOW' $object_name/,
[ sorted: $s ], -- for TABLE and CHART only
object_type: ( REPORT_description
/GEN<< ' report_container.insert(pair<int, report_object>(' @
#unique_number() ',' $work2 '));' / !
GRAPH_description
/GEN<< ' graph_container.insert(pair<int, graph_object>(' @
#unique_number() ',' $work2 '));' / !
TABLE_description
/IF $s ->
GEN<< ' //' sort it by rows before printing;
GEN<< ' sort(' @ $work2 '.table_rows.begin(),'
$work2 '.table_rows.end());'
FI;
GEN<< ' table_container.insert(pair<int, table_object>(' @
#unique_number() ',' $work2 '));' / !
CHART_description
/IF $s ->
GEN<< ' //' sort it by X_AXIS before printing;
GEN<< ' sort(' @ $work2 '.chart_rows.begin(),'
$work2 '.chart_rows.end());'
FI;
GEN<< ' chart_container.insert(pair<int, chart_object>(' @
#unique_number() ',' $work2 '));' / !
$a
......@@ -130,7 +184,11 @@
<. operation: CLEAR,
work2: $work2,
name: $object_name /GEN<< ' // CLEAR' $object_name/,
object_type: ( (REPORT_description ! GRAPH_description)
object_type: ( (REPORT_description !
GRAPH_description !
TABLE_description
/#clear_charts(LAST #AG $TABLE_list.$object_name.chart_list)/
)
/GEN<< ' ' @ $work2 '.clean();' / !
$a
......@@ -139,6 +197,13 @@
.>
##
#clear_charts
<* $chart_name: $work2
/GEN<< ' ' @ $work2 '.clean(); // clear chart for the table '
LAST #AG $CHART_list.$chart_name.source_table_name/
*>
##
#generate_Graph_description_processing
-- when control passes through GRAPH description re-assign the title
-- called in #generate_operation
......@@ -232,9 +297,88 @@
.>
##
#add_tab_names_to_table_objects
/GEN<< ' //' add tab names to table objects/
<* $table_name: <. work2: $work_name,
tab_list: <* $tab_name: $type
/GEN<< @ ' ' $work_name '.tab_names.push_back("' $tab_name '");'/
*>
.>
*>
##
#add_tab_names_to_chart_objects
/GEN<< ' //' add tab names to chart objects/
<* $chart_name: <. source_table_name: $table_name
/GEN<< ' //' bar chart for table $table_name/,
work2: $work_name,
x_axis_tab: $x_tab_name
/GEN<< @ ' ' $work_name '.x_axis_tab_name= "' $x_tab_name '";'/,
chart_tab_list: <* $tab_name: $t
/GEN<< @ ' ' $work_name '.tab_names.push_back("' $tab_name '");'/
*>,
[ rotate: $rotate /GEN<< @ ' ' $work_name '.rotate= true;'/ ]
.>
*>
##
#generate_add_tuple
<. table_name: $table_name,
operation: add_tuple
/GEN<< ' { // add tuple to table' $table_name/,
work_table_name: $work2
/GEN<< @ ' tuple_type_' $work2 ' temp;'/ ,
tuple: (. (+
(. $tuple_name
( <. type: string
/GEN<< ' { //' string tab assignment/,
body: #string_construction_gen .>
/GEN<< @ ' temp.tab_' $tuple_name '= convert.str();}'/ !
/GEN<< @ ' temp.tab_' $tuple_name '= '/
#generate_expr
/GEN<] ';'/ )
.)
+) .)
.>
/-- create the string row and add to table_rows
GEN<< ' ostringstream row; char comma= 32;';
#create_row_as_string(LAST #AG $TABLE_list.$table_name.tab_list);
GEN<< @ ' ' $work2 '.table_rows.push_back(row.str());';
$chart_list:= LAST #AG $TABLE_list.$table_name.chart_list;
IF $chart_list ->
GEN<< ' //' add tab strings for charts in table $table_name;
#create_chart_row_as_string($chart_list);
FI;
GEN<< ' } // end of add tuple'/
##
#create_row_as_string
-- put each tab in the string separated by commas
-- in preparation for .json generation
<* $tab_name: ( number /GEN<< @ ' row << comma << temp.tab_' $tab_name ';';
GEN<] ' comma= 44;'/ !
string /GEN<< @ ' row << comma <<"\""<< temp.tab_' $tab_name '<<"\"";';
GEN<] ' comma= 44;'/ )
*>
##
#create_chart_row_as_string
<* $chart_name: $work2
/GEN<< ' //' add string to chart $chart_name;
GEN<< ' { ostringstream row; char comma= 32;';
#create_row_as_string(LAST #AG $CHART_list.$chart_name.chart_tab_list);
GEN<< @ ' ' $work2 '.chart_rows.push_back(row.str()); } // end adding to chart ' $chart_name/
*>
##
#generate_global_SAY_message
<. operation: 'SAY'
/GEN<< ' { // SAY' message/,
/GEN<< ' { //' global SAY message/,
list: #string_construction_gen
.>
/GEN<< @ ' global_SAY_list_999999.push_back(convert.str());}'/
......@@ -320,6 +464,18 @@
GEN<< ' JSON<< ",";';
GEN<< ' (p2 -> second).print_graph_json();} }';
GEN<< '//***' generate all global Tables ;
GEN<< ' {map<int, table_object>::iterator p3;';
GEN<< ' for(p3 = table_container.begin(); p3 != table_container.end(); p3++){';
GEN<< ' JSON<< ",";';
GEN<< ' (p3 -> second).print_table_json();} }';
GEN<< '//***' generate all global Charts ;
GEN<< ' {map<int, chart_object>::iterator p4;';
GEN<< ' for(p4 = chart_container.begin(); p4 != chart_container.end(); p4++){';
GEN<< ' JSON<< ",";';
GEN<< ' (p4 -> second).print_chart_json();} }';
GEN<< '//***' generate all requested ADs ;
GEN<<' comma = 44;';
GEN<<' generate_AD_json_list(comma, AD_flags);'
......
// global_objects.h
//
// Created by Mikhail Auguston on 2/8/19.
//
// last updated 11/13/2019
//***** VIEW object infrastructure for trace list ******
using namespace std;
......@@ -143,25 +143,71 @@ public:
}
};// end graph_object class
//====================================================================
template <class tuple_class> class table_object {
class table_object {
public:
string title;
vector <tuple_class> table_contents;
vector <string> table_rows;
vector <string> tab_names;
// constructor
table_object(){ title = " "; }
void clean(){
table_contents.clear();
table_rows.clear();
}
//--- print json for Table objects
void print_table_json(){
/*
JSON<< endl<< "{\"REPORT\":["<< "\""<< title<< "\"";
// printing table_rows
JSON<< endl<< "{\"TABLE\": { \"title\": "<< "\""<< title<< "\", \n\"tabs\": [";
vector<string>::iterator p;
for(p = report_contents.begin(); p != report_contents.end(); p++){
JSON<<",\"" << *p<< "\"";
char comma= 32;
for(p = tab_names.begin(); p != tab_names.end(); p++){
JSON<<comma<< "\"" << *p<< "\""; comma= 44;
}
JSON<<"]}"<< endl;
*/
JSON<<"],\n \"rows\": [";
comma= 32;
for(p = table_rows.begin(); p != table_rows.end(); p++){
JSON<<comma<< "["<< *p << "]"; comma= 44;
}
JSON<<"] } }"<< endl;
}
}; // end table_object class
//====================================================================
class chart_object {
public:
string title;
vector <string> chart_rows;
vector <string> tab_names;
string x_axis_tab_name;
bool rotate;
// constructor
chart_object(){
title = " ";
rotate = false;
}
void clean(){
chart_rows.clear();
}
//--- print json for Chart objects
void print_chart_json(){
// printing table_rows
JSON<< endl<< "{\"BAR_CHART\": { \"title\": "<< "\""<< title<< "\", \n\"tabs\": [";
vector<string>::iterator p;
char comma= 32;
for(p = tab_names.begin(); p != tab_names.end(); p++){
JSON<<comma<< "\"" << *p<< "\""; comma= 44;