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.

Commit 270541b5 authored by Auguston, Mikhail's avatar Auguston, Mikhail

Initial commit

parents
Pipeline #3000 failed with stages
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
-- MP4_attributes.rig
-- to generate attribute assignments, aggregate operations.
-- created 06/08/2018
--
-- last updated 10/31/2018
-------------------------------------------
#gen_attribute_assignment
<. operation: attribute_assignment,
assignment_op: ( 'max=' /$comparison_op:= '< '/ !
'min=' /$comparison_op:= '> '/ ),
source: ( <. comp: 'THIS' .> /$var1:= '[0]'/ !
<. comp: 'GLOBAL' .> / $var1:= NULL;
$node_prefix:= 'GLOBAL_'/ !
<. comp: $Id .> /$var1:= #IMPLODE( '[Root_table[Event_' $Id ']]')/ !
<. var: $v .> /$var1:= #IMPLODE('[' $v ']')/ !
<. node_var: $work_node_var .>
/$var1:= #IMPLODE('[' $work_node_var ']');
$node_prefix:= 'NODE_'/
),
attribute_name: $attribute_name,
type: $attr_type,
rhp: $expr
.>
/$temp_var:= #IMPLODE( 'temp_' #rand_num());
GEN<< ' float' $temp_var '=';
#generate_expr($expr);
GEN<] ';';
GEN<< ' if(';
GEN<] @ $node_prefix $attribute_name '_' $attr_type '_attribute'
$var1 ' ' $comparison_op;
GEN<] $temp_var ')';
GEN<< ' ' @ $node_prefix $attribute_name '_' $attr_type '_attribute'
$var1 ' = ' $temp_var ';'/
;;
<. operation: attribute_assignment,
assignment_op: $assignment_op, -- for :=, +=, -=, *=, /=, AND=, OR=
source: ( <. comp: 'THIS' .> /$var1:= '[0]'/ !
<. comp: GLOBAL .> /$var1:= NULL;
$node_prefix:= 'GLOBAL_'/ !
<. comp: $Id .> /$var1:= #IMPLODE('[Root_table[Event_' $Id ']]')/ !
<. var: $v .> /$var1:= #IMPLODE('[' $v ']')/ !
<. node_var: $work_node_var .>
/$var1:= #IMPLODE('[' $work_node_var ']');
$node_prefix:= 'NODE_'/
),
attribute_name: $attribute_name,
type: $attr_type,
rhp: $expr
.>
/GEN<< ' // attribute' $attribute_name assignment;
GEN<< ' ' @ $node_prefix $attribute_name '_' $attr_type '_attribute'
$var1 $assignment_op ;
#generate_expr($expr);
GEN<] ';'/
##
#gen_SET_timing_attribute
<. operation: timing_attribute_set,
source: ( <. comp: 'THIS' .> /$var1:= '0'/ !
<. comp: $Id .> /$var1:= #IMPLODE( 'Root_table[Event_' $Id ']')/ !
<. var: $v .> /$var1:= $v/ ),
attribute_name: $attribute_name,
rhp: $expr
.>
/GEN<< ' ' @ 'SET_' $attribute_name '(' $var1 ',';
#generate_expr($expr);
GEN<] ');'/
##
----------------------------------------------------------------------------------
#generate_IF_or_simple_action_class
-- MARK, SAY are simplest cases, when no throw 'failed' is needed, but ...
<* $work_name:
/GEN<< '//----' #class_counter() '----';
GEN<< class @ $work_name '_ob: public Coordinate {';
GEN<< 'public:' '//' constructor;
GEN<< ' ' @ $work_name '_ob(int n): Coordinate(n){type = simple_or_IF_op;}';
GEN<<;
GEN<< ' Traversal_result traverse(){';
GEN<< ' try{ create_matrices();';/
#generate_operation
-- create_matrices() inside operation may throw 'failed'
/GEN<< ' } // end of try';
GEN<< ' catch(Traversal_result t){';
GEN<< ' return failed;';
GEN<< ' }';
GEN<< ' return success_and_completed;';
GEN<< ' } // end traverse()';
GEN<< '}; // end' @ $work_name '_ob class';
GEN<</
*>
##
-------------------------------------------------------------------------------------
#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 *>
##
#generate_aggregate_function
<. op: $op
/GEN<<;
GEN<<'//----' #class_counter() '----' for aggregate operation $op /,
op: ( ( 'AND' ! 'OR') /$result_type:= bool/ !
'aggregate_#' /$result_type:= int/ !
$any /$result_type:= float/ )
/GEN<< $result_type/,
result: $work
/GEN<] @ $work '(Coordinate * current_host, int pivot'/,
[ list_of_visible_variables: /GEN<< ' '/
(. (* $var /GEN<] @ ', int ' $var/ *) .) ],
thread: <. variable: $var .>
/GEN<] '){';
GEN<< ' int' $var ';';
GEN<< ' ' $result_type temp '='/,
op: ( ( 'SUM' ! 'aggregate_#' ! 'MAX' ! 'MIN') /GEN<] 0/ !
'TIMES' /GEN<] 1/ !
'AND' /GEN<] true/ !
'OR' /GEN<] false/ )
/GEN<] ';';
GEN<<'// #event' traversal performed with respect to the pivot event;
GEN<<' vector<int>' selected_list '; //' list of selected events;
GEN<<' bool first = true;';
GEN<<;
-- at least eq_matrix matrix is needed for filtering out shared events
GEN<<' current_host->create_matrices();';
GEN<<' int len = current_host->len;';
GEN<<' //' create list of selected events ;
GEN<<' for(' $var '= 0;' $var '< len;' $var '++){';
GEN<<' if(current_host->in_matrix[' $var '* len + pivot]){'/,
thread: <. selection_pattern:
/GEN<<' if(';
$or_op:= ' ' /
(. (+ /GEN<] $or_op/
('$$EVENT' /GEN<] 'Stack[' $var ']->type == Atom ||';
GEN<< ' Stack[' $var ']->type == ROOT_node ||';
GEN<< ' Stack[' $var ']->type == Composite_event_instance_node ||';
GEN<< ' Stack[' $var ']->type == Schema_node'/ !
'$$ATOM' /GEN<] 'Stack[' $var ']->type == Atom'/ !
'$$ROOT' /GEN<] 'Stack[' $var ']->type == ROOT_node'/ !
'$$COMPOSITE' /GEN<] 'Stack[' $var ']->type == Composite_event_instance_node'/ !
$Id
/GEN<] @ 'Stack[' $var ']->name == Event_' $Id/
)
/$or_op:= '||'/
+)
.)
.>
/GEN<] '){';
GEN<<' //' make sure this is fresh event not yet shared;
GEN<<' int found = 0;';
GEN<<' for(vector<int>::' iterator 's = selected_list.begin();';
GEN<<' s != selected_list.end(); s++){';
GEN<<' if((found = current_host->eq_matrix[' $var '* len + *s]))' 'break;';
GEN<<' }; //' end of search for shared events;
GEN<<' if(!found'/,
thread: <. [ such_that: /GEN<] '&&'/ #generate_expr ] .>,
expr: $expr,
-- perform the aggregate operation
op: /GEN<< ' ) {selected_list.push_back(' $var ');'/
( ( 'SUM' ! 'aggregate_#' ) /GEN<< ' temp = temp +';
#generate_expr($expr)/ !
'TIMES' /GEN<< 'temp = temp *';
#generate_expr($expr)/ !
'MAX' /GEN<< ' if(first) temp =';
#generate_expr($expr); GEN<]';';
GEN<< ' else temp = max(temp,';
#generate_expr($expr);
GEN<]');';
GEN<<' first = false'/ !
'MIN' /GEN<< ' if(first) temp =';
#generate_expr($expr); GEN<]';';
GEN<< ' else temp = min(temp,';
#generate_expr($expr);
GEN<]');';
GEN<<' first = false'/ !
'AND' /GEN<< 'temp = temp &&';
#generate_expr($expr)/ !
'OR' /GEN<< 'temp = temp ||';
#generate_expr($expr)/ )
/GEN<] ';};'/
.>
/GEN<<' }; //' end if for selection;
GEN<<' }; //' end if for matrix;
GEN<<' }; //' end for;
GEN<< ;
GEN<< ' return temp;';
GEN<< '}'/
##
-----------------------------------------------------------------
#rand_num
/LAST #AG $rand_num +:=1;
RETURN COPY(LAST #AG $rand_num)/
##
-- MP4_parse_view_objects.rig
-- Created by Mikhail Auguston on 12/3/18.
-- last updated 02/13/2019
--------------------------------------------
---- parsing view objects and commands -----
--------------------------------------------
#global_view
GLOBAL
/LAST #MP $mode := global;
LAST #MP $global_flag := 'true'/
(*
$elt_list !.:=
( #VIEW_description !
#global_composition_operation !
$x /#error( $x err67 ); FAIL/ ) -- undefined operation in GLOBAL
#semicolon
*)
/RETURN $elt_list/
##
#VIEW_description
$res:= #report_or_graph_description
/IF LAST #MP $mode = block ->
#error( $res.operation err69 ); FAIL
FI;
RETURN $res ++ <. mode: LAST #MP $mode .>/
##
#report_or_graph_description
$object:= ( REPORT ! GRAPH)
$object_name:= $Id
/IF LAST #MP $view_objects.$object_name ->
#error( $object_name err66 ); FAIL
FI/
( '{' ! $a /#error( $a err21 ); FAIL/)
/$title:= (. ' ' .)/ -- default title
[ TITLE $title:= #string_constructor
(';' ! $a /#error( $a err4 ); FAIL/) ]
( '}' ! $a /#error( $a err22 ); FAIL/)
/$work:= #IMPLODE( $object '_' #unique_number() '_' #unique_number());
-- for class name
$un := #unique_number();
$res:= <. operation: #IMPLODE( $object '_description'),
type: $object,
name: $object_name,
-- for container name
work2: #IMPLODE( $object '_' #unique_number() '_' $object_name),
work: $work,
unique_num: $un,
list: $title,
mode: LAST #MP $mode .> ;
LAST #MP $view_objects ++:= <. $object_name: $res .>;
RETURN $res/
##
#global_composition_operation
$res:= (#view_construction_operation ! -- need to preempt SAY
#SAY_clause !
MARK
/RETURN <. operation: MARK,
work: #IMPLODE( 'MARK_' #unique_number()
'_' #unique_number()),
mode: LAST #MP $mode
.>/ !
$res:= #limited_conditional_composition !
$res:= #attribute_assignment !
$res:= #FOR_loop
)
/RETURN $res ++ <. mode: LAST #MP $mode .>/
##
#limited_conditional_composition
('ELSE' ! 'FI') /FAIL/;;
'IF'
$condition := #bool_expr
( 'THEN' ! $x /#error( $x err25 ); FAIL/)
(* $then_list !.:= #global_composition_operation #semicolon *)
[ 'ELSE' (* $else_list !.:= #global_composition_operation #semicolon *) ]
('FI' ! $x /#error( $x err23 ); FAIL/ )
/$work:= #IMPLODE( 'Conditional_' #unique_number());
RETURN <. operation: 'IF',
work: $work,
condition: $condition,
then_list: $then_list,
else_list: $else_list .>/
##
#view_construction_operation
$res:=
( #increment_report_command !
#clear_or_show_command !
#graph_processing
)
/RETURN $res ++ <. mode: LAST #MP $mode .>/
##
#increment_report_command
$say:= #SAY_clause '=' '>' $Id
/IF NOT LAST #MP $view_objects.$Id ->
#error( $Id err67 ); FAIL
FI;
RETURN <. operation: increment_report,
report: $Id,
-- for class name
work: #IMPLODE( 'INCR_REPORT_' #unique_number() ),
-- container name
work2: LAST #MP $view_objects.$Id.work2,
say: $say .> /
##
#clear_or_show_command
SHOW $res:= #activity_diagram_description
/RETURN $res/;;
$op:= ( CLEAR ! SHOW )
$Id
/$type:= LAST #MP $view_objects.$Id.operation;
IF NOT $type ->
#error( $Id err67 ); FAIL
FI;
RETURN <. operation: $op,
name: $Id,
object_type: $type,
work: #IMPLODE( $op '_' #unique_number() '_'
#unique_number()),
work2: LAST #MP $view_objects.$Id.work2
.>/
##
#activity_diagram_description
'ACTIVITY' 'DIAGRAM'
(+
$Id -- event name
/IF LAST #MP $roots.$Id ->
$type := 'ROOT'
ELSIF LAST #MP $composites.$Id ->
$type := 'composite'
ELSIF T ->
#error( $Id err68 ); FAIL
FI;
LAST #MP $AD_list ++:= <. $Id: $type .>;
$list ++:= <. $Id: $type .> /
+',')
/RETURN <. operation: Show_Activity_Diagram,
event_names: $list .>/
##
#graph_processing
-- global:
-- $graph_name
-- uses
-- $node_variables: <* variable_name: #unique_number() *> defined in #MP
WITHIN
$graph_name:= $Id
/IF LAST #MP $view_objects.$graph_name.type <> GRAPH ->
#error($graph_name err71); FAIL
FI;
IF LAST #MP $processing_WITHIN ->
#error($graph_name err72); FAIL
ELSIF T ->
LAST #MP $processing_WITHIN:= $graph_name
FI;
LAST #MP $node_variables := NULL/
( '{' ! $x /#error( $x err21 ); FAIL/ )
(* V'($$<>'}') $op_list!.:= #simple_action *)
( '}' ! $x /#error( $x err22 ); FAIL/ )
/$work:= #IMPLODE( 'WITHIN_' $graph_name '_' #unique_number() );
LAST #MP $processing_WITHIN:= NULL;
RETURN <. operation: WITHIN,
graph_name: $graph_name,
node_variabes: LAST #MP $node_variables,
op_list: $op_list,
work: $work .>/
##
#graph_operation
$res:= ( #find_last_or_create_new_node !
#add_edge )
/RETURN $res/
##
#find_last_or_create_new_node
$node_var:= #node_variable ':' -- node variable, receives "abc"
/$work_node_var:= LAST #MP $node_variables.$node_var;
IF NOT $work_node_var ->
$work_node_var:= #IMPLODE($node_var '_' #unique_number() '_node_var');
LAST #MP $node_variables ++:= <. $node_var: $work_node_var .>
FI/
$op:= ( 'LAST' ! 'NEW' )
$label:= #node_constructor -- returns list of expressions
/$work:= #IMPLODE( 'NODE_constr_' #unique_number() );
RETURN <. operation: #IMPLODE($op '_NODE' ),
work_node_variable: $work_node_var,
string: $label,
work_graph_name: LAST #MP $view_objects.
(LAST #graph_processing $graph_name).work2,
work: $work .>/
##
#node_variable
$a:= #IDENT
/IF #keyword($a) -> FAIL FI;
-- look for 'Node$abc'
$b:= #EXPLODE($a);
IF #LEN($b) < 6 -> FAIL FI;
IF $b[1] <> 'N' OR
$b[2] <> 'o' OR
$b[3] <> 'd' OR
$b[4] <> 'e' OR
$b[5] <> '$' -> FAIL
FI;
$b[1]:= NULL;
$b[2]:= NULL;
$b[3]:= NULL;
$b[4]:= NULL;
$b[5]:= NULL;
$v:= #IMPLODE($b);
RETURN $v/ -- returns 'abc'
##
#node_constructor
$s:= #string_constructor -- defined in MP2-parse-comp-op.rig
/RETURN $s/
##
#add_edge
'ADD'
( $node_var1:= #node_variable -- node variable, receives "abc"
/$work_node_var1:= LAST #MP $node_variables.$node_var1;
IF NOT $work_node_var1 ->
#error($node_var1 err73); FAIL
FI/ !
( ( 'LAST' /$op1:= find_or_create_new_node/ !
'NEW' /$op1:= create_new_node/ )
$label1:= #node_constructor ) ) -- returns list of expressions
-- edge parsing
( ARROW /$edge_op:= add_arrow/ !
LINE /$edge_op:= add_line/ )
$e:= #string_constructor -- returns list of expressions
( $node_var2:= #node_variable
/$work_node_var2:= LAST #MP $node_variables.$node_var2;
IF NOT $work_node_var2 ->
#error($node_var2 err73); FAIL
FI/ !
( ( 'LAST' /$op2:= find_or_create_new_node/ !
'NEW' /$op2:= create_new_node/ )
$label2:= #node_constructor ) ) -- returns list of expressions
/$work:= #IMPLODE( 'edge_construction_' #unique_number() );
RETURN <. operation: $edge_op,
node1_var: $work_node_var1,
node1_label: $label1,
node1_op: $op1,
node2_var: $work_node_var2,
node2_label: $label2,
node2_op: $op2,
edge_label: $e,
work_graph_name: LAST #MP $view_objects.
(LAST #graph_processing $graph_name).work2,
work: $work
.>/
##
#loop_over_graph
'FOR'
$node_var:= #node_variable -- node variable, receives "abc"
/IF LAST #MP $node_variables.$node_var ->
#error( $ err76 ); FAIL
FI;
$work_node_var:= #IMPLODE($node_var '_' #unique_number() '_node_var');
LAST #MP $node_variables ++:= <. $node_var: $work_node_var .>/
('DO' ! $x /#error( $x err9 ); FAIL/ )
(* $body !.:= #simple_action *)
('OD' ! $x /#error( $x err10 ); FAIL/ )
/LAST #MP $node_variables.$node_var := NULL;
RETURN <. operation: loop_over_graph,
work: #IMPLODE( 'graph_loop_' #unique_number()),
body: $body,
work_node_variable: $work_node_var,
work_graph_name: LAST #MP $view_objects.
(LAST #graph_processing $graph_name).work2
.> /
##
This diff is collapsed.