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 @@ ...@@ -39,7 +39,7 @@
## ##
#thread #thread
-- called from #coordinate_composition, Quantified_bool_expr in #bool_expr3, -- called from #coordination_source, Quantified_bool_expr in #bool_expr3,
-- and aggregate operations -- and aggregate operations
( $var:= #variable ! -- returns 'abc_variable' ( $var:= #variable ! -- returns 'abc_variable'
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
! !
$a /#error( $a err2 ); FAIL/ ) $a /#error( $a err2 ); FAIL/ )
[ 'FROM' $source:= #event_instance ] [ $f:= 'FROM' $source:= #event_instance ]
-- the default for source is FROM THIS -- the default for source is FROM THIS
/IF NOT $source -> /IF NOT $source ->
...@@ -127,10 +127,11 @@ ...@@ -127,10 +127,11 @@
/LAST #MP $coordination_nesting +:=1; /LAST #MP $coordination_nesting +:=1;
$asynchronous_source_count := NULL; $asynchronous_source_count := NULL;
-- maintain the $source_list -- maintain the $source_list
$old_source_list:= COPY(LAST #MP $source_list)/ $old_source_list:= COPY(LAST #MP $source_list)/
(+ $coord++:= #coordination_source (+ $cs:= #coordination_source
/LAST #MP $source_list ++:= $coord/ -- adjust variable list /$coord++:= $cs;
LAST #MP $source_list ++:= $coord/ -- adjust variable list
-- also calculates LAST #top_composition_operation $asynchronous_source_count for <!> -- also calculates LAST #top_composition_operation $asynchronous_source_count for <!>
+',') +',')
...@@ -199,7 +200,7 @@ ...@@ -199,7 +200,7 @@
#event_reshuffling_option #event_reshuffling_option
'<' '!' [ $chain:= CHAIN ] '>' '<' '!' [ $chain:= CHAIN ] '>'
-- asynchronous reshufflinh is detected -- asynchronous reshuffling is detected
/IF LAST #MP $coordination_nesting > 1 -> /IF LAST #MP $coordination_nesting > 1 ->
#error( $ err43 ); FAIL #error( $ err43 ); FAIL
FI; FI;
...@@ -514,7 +515,8 @@ ...@@ -514,7 +515,8 @@
#graph_processing ! #graph_processing !
#graph_operation ! #graph_operation !
#loop_over_graph ! #loop_over_graph !
#FOR_loop ) #FOR_loop !
#add_tuple_command )
) )
#semicolon #semicolon
+) +)
......
...@@ -64,7 +64,6 @@ ...@@ -64,7 +64,6 @@
-- +) .) -- +) .)
-- .> -- .>
-- *> -- *>
-- used by #prepare_share_all in second_pass.rig to check whether shared events have been defined -- 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, -- $share_all_ops: <* work_name: <. operation: SHARE_ALL,
-- work: work_name, -- work: work_name,
...@@ -101,6 +100,8 @@ ...@@ -101,6 +100,8 @@
-- --
-- requested for Activity Diagrams -- requested for Activity Diagrams
-- $AD_list: <* event_name: (ROOT ! composite) *> go to the event trace screen -- $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 -- $global_SAY_present: (T ! NULL) to create global_SAY list in the .cpp file
-- --
-- $node_variables: <* variable_name: #unique_number() *> -- $node_variables: <* variable_name: #unique_number() *>
...@@ -155,7 +156,7 @@ ...@@ -155,7 +156,7 @@
-- --
------------- VIEW object descriptions ----------------------------- ------------- VIEW object descriptions -----------------------------
-- $global_flag: (true ! false) if GLOBAL section is present -- $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, -- name: $report_name,
-- work: work_name, -- for class generation -- work: work_name, -- for class generation
-- work2: $work2 -- for container name -- work2: $work2 -- for container name
...@@ -230,7 +231,9 @@ ...@@ -230,7 +231,9 @@
-- plain_attributes: $BUILD_block.plain_attributes, -- plain_attributes: $BUILD_block.plain_attributes,
-- global: $global -- list of operations -- global: $global -- list of operations
-- .> -- .>
IF NOT $roots ->
#error( $input_file err90 ); FAIL
FI;
--*********** 2nd pass, insert/expand composite events, --*********** 2nd pass, insert/expand composite events,
-- create $new_root_table, $new_composites -- create $new_root_table, $new_composites
...@@ -274,6 +277,8 @@ ...@@ -274,6 +277,8 @@
view_objects: $view_objects, view_objects: $view_objects,
global_flag: $global_flag, -- (true ! false) global_flag: $global_flag, -- (true ! false)
AD_list: $AD_list, AD_list: $AD_list,
TABLE_list: $TABLE_list,
CHART_list: $CHART_list,
global_SAY_present: $global_SAY_present global_SAY_present: $global_SAY_present
.>; .>;
...@@ -427,7 +432,7 @@ ...@@ -427,7 +432,7 @@
'PRECEDES' ! 'PRECEDES' !
'REJECT' ! 'REPORT' ! 'RESET' ! 'ROOT' ! 'REJECT' ! 'REPORT' ! 'RESET' ! 'ROOT' !
'SAY' ! 'SET' ! 'SHARE' ! 'SHOW' ! 'SUCH' ! 'SUM' ! 'start' ! 'STEP' ! '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' ! 'WHEN' ! 'WITHIN' !
'$$scope' '$$scope'
) )
......
...@@ -99,31 +99,6 @@ assignment_op: $assignment_op, -- for :=, +=, -=, *=, /=, AND=, OR= ...@@ -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 #generate_aggregate_functions
<* $work_name: #generate_aggregate_function *> <* $work_name: #generate_aggregate_function *>
## ##
......
-- MP4_parse_view_objects.rig -- MP4_parse_view_objects.rig
-- Created by Mikhail Auguston on 12/3/18. -- Created by Mikhail Auguston on 12/3/18.
-- last updated 02/13/2019 -- last updated 11/11/2019
-------------------------------------------- --------------------------------------------
---- parsing view objects and commands ----- ---- parsing view objects and commands -----
-------------------------------------------- --------------------------------------------
...@@ -10,36 +10,45 @@ ...@@ -10,36 +10,45 @@
LAST #MP $global_flag := 'true'/ LAST #MP $global_flag := 'true'/
(* (*
$elt_list !.:= $elt_list !.:=
( #VIEW_description ! ( #VIEW_description ! -- add to operations,
-- since title may be recalculated
#global_composition_operation ! #global_composition_operation !
$x /#error( $x err67 ); FAIL/ ) -- undefined operation in GLOBAL $x /#error( $x err67 ); FAIL/ ) -- undefined operation in GLOBAL
#semicolon ( #semicolon ! / #error( $x err4); FAIL/ )
*) *)
/RETURN $elt_list/ /RETURN $elt_list/
## ##
#VIEW_description #VIEW_description
$res:= #report_or_graph_description $object:= ( REPORT ! GRAPH ! TABLE ! (BAR CHART))
-- $object = CHART for BAR CHART
/IF LAST #MP $mode = block -> /IF LAST #MP $mode = block ->
#error( $res.operation err69 ); FAIL #error( $object err80 ); FAIL
FI; FI/
RETURN $res ++ <. mode: LAST #MP $mode .>/
##
#report_or_graph_description
$object:= ( REPORT ! GRAPH)
$object_name:= $Id $object_name:= $Id
/IF LAST #MP $view_objects.$object_name -> /IF LAST #MP $view_objects.$object_name ->
#error( $object_name err66 ); FAIL #error( $object_name err66 ); FAIL
FI/ FI/
( '{' ! $a /#error( $a err21 ); FAIL/) ( '{' ! $a /#error( $a err21 ); FAIL/)
/$title:= (. ' ' .)/ -- default title /$title:= (. ' ' .)/ -- default title
[ TITLE $title:= #string_constructor [ TITLE $title:= #string_constructor
(';' ! $a /#error( $a err4 ); FAIL/) ] (';' ! $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/) ( '}' ! $a /#error( $a err22 ); FAIL/)
/$work:= #IMPLODE( $object '_' #unique_number() '_' #unique_number()); /$work:= #IMPLODE( $object '_' #unique_number() );
-- for class name -- for class name
$un := #unique_number(); $un := #unique_number();
IF $object = TABLE AND NOT $tab_list ->
#error( $object err83); FAIL FI;
$res:= <. operation: #IMPLODE( $object '_description'), $res:= <. operation: #IMPLODE( $object '_description'),
type: $object, type: $object,
name: $object_name, name: $object_name,
...@@ -48,11 +57,86 @@ ...@@ -48,11 +57,86 @@
work: $work, work: $work,
unique_num: $un, unique_num: $un,
list: $title, 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 .>; 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/ 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 #global_composition_operation
$res:= (#view_construction_operation ! -- need to preempt SAY $res:= (#view_construction_operation ! -- need to preempt SAY
...@@ -98,8 +182,8 @@ ...@@ -98,8 +182,8 @@
$res:= $res:=
( #increment_report_command ! ( #increment_report_command !
#clear_or_show_command ! #clear_or_show_command !
#graph_processing #graph_processing !
) #add_tuple_command )
/RETURN $res ++ <. mode: LAST #MP $mode .>/ /RETURN $res ++ <. mode: LAST #MP $mode .>/
## ##
...@@ -127,12 +211,23 @@ ...@@ -127,12 +211,23 @@
IF NOT $type -> IF NOT $type ->
#error( $Id err67 ); FAIL #error( $Id err67 ); FAIL
FI; 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, name: $Id,
object_type: $type, object_type: $type,
work: #IMPLODE( $op '_' #unique_number() '_' work: #IMPLODE( $op '_' #unique_number() '_'
#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 @@ ...@@ -301,3 +396,35 @@
(LAST #graph_processing $graph_name).work2 (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 @@ ...@@ -29,11 +29,14 @@
#generate_global_composition_operation #generate_global_composition_operation
(#generate_view_object_title_update ! (#generate_view_object_title_update !
#generate_report_increment ! #generate_report_increment !
#generate_add_tuple !
#generate_global_SAY_message ! #generate_global_SAY_message !
#generate_view_object_SHOW ! -- unique item number has been added #generate_view_object_SHOW ! -- unique item number has been added
#generate_view_object_CLEAR_op ! #generate_view_object_CLEAR_op !
#generate_WITHIN ! #generate_WITHIN !
#generate_limited_simple_action_list ! #generate_limited_simple_action_list !
#generate_find_last_or_create_new_node !
#generate_add_edge !
<.operation: Activity_Diagram_description .> ! <.operation: Activity_Diagram_description .> !
...@@ -75,23 +78,54 @@ ...@@ -75,23 +78,54 @@
/GEN<<'//*****' VIEW object containers '*****'/ /GEN<<'//*****' VIEW object containers '*****'/
<* $object_name: ( <. name: $report_name, <* $object_name: ( <. name: $report_name,
work2: $work_name, work2: $work_name,
[tab_list: $tab_list
/#generate_tuple_class($work_name $tab_list)/
], -- for TABLE only
type: ( REPORT type: ( REPORT
/GEN<< report_object @ $work_name ';'/ ! /GEN<< report_object @ $work_name ';'/ !
GRAPH 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 .> ! <. AD: $a .> !
$a /GEN<< '//' view object $object_name not yet implemented/ $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<</ 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 #generate_view_object_title_update
<. operation: (REPORT_description ! GRAPH_description), <. operation: (REPORT_description ! GRAPH_description ! TABLE_description ! CHART_description),
name: $object_name name: $object_name
/GEN<< ' { //' $object_name title generation/, /GEN<< ' { //' $object_name title generation/,
work2: $work2, -- object #unique_number() '_' $object_name work2: $work2, -- object #unique_number() '_' $object_name
...@@ -111,13 +145,33 @@ ...@@ -111,13 +145,33 @@
<. operation: SHOW, <. operation: SHOW,
work2: $work2, -- object's work name work2: $work2, -- object's work name
name: $object_name /GEN<< ' // SHOW' $object_name/, name: $object_name /GEN<< ' // SHOW' $object_name/,
[ sorted: $s ], -- for TABLE and CHART only
object_type: ( REPORT_description object_type: ( REPORT_description
/GEN<< ' report_container.insert(pair<int, report_object>(' @ /GEN<< ' report_container.insert(pair<int, report_object>(' @
#unique_number() ',' $work2 '));' / ! #unique_number() ',' $work2 '));' / !
GRAPH_description GRAPH_description
/GEN<< ' graph_container.insert(pair<int, graph_object>(' @ /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 '));' / ! #unique_number() ',' $work2 '));' / !
$a $a
...@@ -130,7 +184,11 @@ ...@@ -130,7 +184,11 @@
<. operation: CLEAR, <. operation: CLEAR,
work2: $work2, work2: $work2,
name: $object_name /GEN<< ' // CLEAR' $object_name/, 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();' / ! /GEN<< ' ' @ $work2 '.clean();' / !
$a $a
...@@ -139,6 +197,13 @@ ...@@ -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 #generate_Graph_description_processing
-- when control passes through GRAPH description re-assign the title -- when control passes through GRAPH description re-assign the title
-- called in #generate_operation -- called in #generate_operation
...@@ -232,9 +297,88 @@ ...@@ -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