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.
This diff is collapsed.
-- 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.
-- attribute_parsing.rig
-- separated from MP2-parse-comp-op.rig
-- 08/30/2018
----------------------------------------
#attribute_assignment
/$source:= <. comp: THIS .>/
[
( ( $node_variable:= #node_variable
V'($$ = '.') -- next should be '.attribute_name'
V'(LAST #MP $processing_WITHIN) -- proceed only if node var table exists
/$work_node_var:= LAST #MP $node_variables.$node_variable;
IF NOT $work_node_var ->
#error($node_variable err73); FAIL
FI;
$source:= <. node_var: $work_node_var .>/ ) !
'THIS' !
'GLOBAL' /$source:= <. comp: GLOBAL .>/ !
( $v:= #variable -- returns 'abc_variable'
V'($$ = '.') -- next should be '.attribute_name'
/IF NOT LAST #MP $source_list.$v ->
#error( $ err17 ); FAIL -- variable undefined
FI;
$source:= <. var: $v .>/ ) !
-- root name?
( V'(NOT #keyword($$))
$Id:= #IDENT
/IF LAST #MP $roots.$Id OR
( LAST #rule $event_name = $Id AND LAST #rule $rule_type = ROOT) OR
$Id = LAST #MP $input_schema_name ->
$source:= <. comp: $Id .>;
$got_root:= T
FI/
V'( $got_root )
-- check if this root/composite name is available
-- (THIS is this root, or schema)
/$r:= $source.comp;
IF NOT( LAST #MP $this = LAST #MP $input_schema_name OR
$r = LAST #MP $this) ->
#error( $r err35 ); FAIL;
FI/
)
)
'.' ]
V'(#predefined_attribute($$) OR NOT #keyword($$))
$attribute_name:= #IDENT
/IF $attribute_name = start OR
$attribute_name = duration OR $attribute_name = end ->
#error( $attribute_name err62 ); FAIL;
ELSIF $attribute_name = trace_id ->
#error( $attribute_name err63 ); FAIL;
FI/
V'(NOT #keyword($attribute_name) AND NOT #node_variable($attribute_name))
( (':' '=' /$assignment_op:= '='/) !
('+' ':' '=' /$assignment_op:= '+='/) !
('-' ':' '=' /$assignment_op:= '-='/) !
('*' ':' '=' /$assignment_op:= '*='/) !
('/' ':' '=' /$assignment_op:= '/='/) !
( $m:= ( 'max' ! 'min') ':' '='
/$assignment_op:= #IMPLODE($m '=')/ ) !
('AND' ':' '=' /$assignment_op:= '&&=';
$bool:= T/ ) !
('OR' ':' '=' /$assignment_op:= '||=';
$bool:= T/ )
)
/$attr_type:= LAST #MP $event_attributes.$attribute_name;
IF NOT $attr_type ->
#error( $attribute_name err53 ); FAIL;
FI/
$e:= #bool_expr
/IF $attr_type = interval AND $e.type = bool ->
#error( $attribute_name err52 ); FAIL
ELSIF $attr_type = number AND $e.type <> number ->
#error( $attribute_name err52 ); FAIL
ELSIF $attr_type = bool AND $e.type <> bool ->
#error( $attribute_name err52 ); FAIL
ELSIF $attr_type <> bool AND $bool ->
#error( $attribute_name err54 ); FAIL
ELSIF $attr_type = bool AND NOT ($bool OR $assignment_op = '=') ->
#error( $attribute_name err56 ); FAIL
ELSIF $attr_type = interval AND
($assignment_op = 'max=' OR $assignment_op = 'max=') ->
#error( $attribute_name err51 ); FAIL
FI;
IF $node_variable ->
LAST #MP $node_attributes ++:= <. $attribute_name: $attr_type .>
FI;
IF $source.comp = THIS AND LAST #MP $mode = global ->
$source:= <. comp: GLOBAL .>
FI;
IF $source.comp = GLOBAL ->
LAST #MP $GLOBAL_attributes ++:= <. $attribute_name: $attr_type .>
FI;
RETURN <. operation: attribute_assignment,
assignment_op: $assignment_op,
source: $source,
attribute_name: $attribute_name,
type: $attr_type,
rhp: $e,
work: #IMPLODE( 'ATTR_ASSGNMT_' #unique_number() '_' #unique_number())
.>/
##
#SET_timing_attribute
-- SET event_instance . (start ! end ! duration) AT LEAST (expression ! interval_expression)
'SET'
/$source:= <. comp: THIS .>/
( 'THIS' !
( $v:= #variable -- returns 'abc_variable'
V'($$ = '.') -- next should be '.attribute_name'
/IF NOT LAST #MP $source_list.$v ->
#error( $ err17 ); FAIL -- variable undefined
FI/ ) !
-- root name?
( V'(NOT #keyword($$))
$Id:= #IDENT
/IF LAST #MP $roots.$Id OR
( LAST #rule $event_name = $Id AND LAST #rule $rule_type = ROOT) OR
$Id = LAST #MP $input_schema_name ->
$source:= <. comp: $Id .>;
$got_root:= T
FI/
V'( $got_root )
) !
$attribute_name:= (start ! end ! duration ! $x /#error( $x err60 ); FAIL/)
)
/IF $v ->
$source:= <. var: $v .>
ELSIF $got_root ->
-- check if this root/composite name is available
-- (THIS is this root, or schema)
$r:= $source.comp;
IF NOT( LAST #MP $this = LAST #MP $input_schema_name OR
$r = LAST #MP $this) ->
#error( $r err35 ); FAIL;
FI;
FI/
-- $source== (<. comp: root_name .> ! <. comp: THIS .> ! <. var: $v .>)
( V'($attribute_name) !
( '.'
$attribute_name:= (start ! end ! duration ! $x /#error( $x err60 ); FAIL/) ) !
$x /#error( $x err59 ); FAIL/ )
( ( 'AT' 'LEAST' ) ! $x /#error( $x err61 ); FAIL/)
$e:= #bool_expr
/IF NOT($e.type = number OR $e.type = interval) ->
#error( $ err55 ); FAIL
FI;
RETURN <. operation: timing_attribute_set,
source: $source,
attribute_name: $attribute_name,
rhp: $e,
work: #IMPLODE( 'ATTR_ASSGNMT_' #unique_number() '_' #unique_number())
.>/
##
This diff is collapsed.
This diff is collapsed.
#!/bin/csh -f
# $1 - schema name, $2 - scope
set rig='~/mikeauguston//rigal/rigsc.446/bin'
$rig/rc MP2-parser
$rig/ic MP2-parser $1 tree $2> temp.txt
$rig/rc MP2-generator
$rig/ic MP2-generator tree> temp2.txt
rm tree *.rsc
echo "C++ compiler: g++ $1.cpp -o $1 -fast"
#time /Developer/usr/bin/g++ "$1.cpp" -o $1 -fast
time g++ "$1.cpp" -o $1 -Ofast
echo "$1 run: ./$1>$1.txt"
time ./$1>"$1.txt"
echo "Completed $1 for scope $2"
rm $1 xd RIGCOMP.TMP
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
MP compiler/trace generator architecture model
run for
scope 1, 4 event traces in approx. 0.2 sec.
scope 2, 48 event traces in approx. 11 sec.
===================================================*/
SCHEMA MP_architecture
ATTRIBUTES {bool is_file;};
/*------------------------------------------------*/
ROOT User:
( load_MP_file |
MP_model_editing )
(+ press_RUN_button
( browse_event_trace |
syntax_errors_detected )
[ load_MP_file ]
[ MP_model_editing ]
+)
end_of_session
BUILD{
/* syntax error may result only from a loaded file or after editing */
ENSURE FOREACH $a: browse_event_trace, $b: syntax_errors_detected
$a BEFORE $b ->
EXISTS $c: (load_MP_file | MP_model_editing)
($a BEFORE $c AND $c BEFORE $b);
/* successful run after syntax error requires either
a loaded file or editing in between */
ENSURE FOREACH $a: syntax_errors_detected, $b: browse_event_trace
$a BEFORE $b ->
EXISTS $c: (load_MP_file | MP_model_editing)
($a BEFORE $c AND $c BEFORE $b);
}
;