Skip to content

Commit

Permalink
Fixed attributes in derived classes.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@942 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Mar 19, 2003
1 parent 82b77f4 commit b956c39
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 22 deletions.
2 changes: 2 additions & 0 deletions modeq/absyn.rml
Expand Up @@ -65,8 +65,10 @@ module Absyn:
* string option (* string comment *)
| DERIVED of Path
* ArrayDim option
* ElementAttributes
* ElementArg list
* Comment option (* comment *)

| ENUMERATION of EnumLiteral list
* Comment option (* comment*)

Expand Down
15 changes: 11 additions & 4 deletions modeq/absyn_builder/walker.g
Expand Up @@ -216,9 +216,11 @@ derived_class returns [void *ast]
void *as = 0;
void *cmod = 0;
void *cmt = 0;
void *attr = 0;
type_prefix_t pfx;
}
:
(
( type_prefix[pfx]
p = name_path
( as = array_subscripts )?
( cmod = class_modification )?
Expand All @@ -227,8 +229,13 @@ derived_class returns [void *ast]
if (as) { as = mk_some(as); }
else { as = mk_none(); }
if (!cmod) { cmod = mk_nil(); }

ast = Absyn__DERIVED(p, as, cmod, cmt? mk_some(cmt) : mk_none());
attr = Absyn__ATTR(
pfx.flow,
pfx.variability,
pfx.direction,
mk_nil());

ast = Absyn__DERIVED(p, as, attr, cmod, cmt? mk_some(cmt) : mk_none());
}
)
;
Expand Down Expand Up @@ -558,7 +565,7 @@ component_clause returns [void* ast]
pfx.flow,
pfx.variability,
pfx.direction,
arr);
arr);

ast = Absyn__COMPONENTS(attr, path, comp_list);
}
Expand Down
17 changes: 9 additions & 8 deletions modeq/dump.rml
Expand Up @@ -146,15 +146,16 @@ relation unparse_class_str: (int, Absyn.Class,string,string,string) => string =
select_string(p, "partial ", "") => s1 &
select_string(f, "final ", "") => s2 &
unparse_restriction_str (r) => s3 &
string_append(s1,s2) => s4 &
Absyn.path_string i => s5 &
get_option_str(dim,print_arraydim_str) => s6 &
unparse_mod1_str m => s7 &
unparse_comment_option(optcmt) => s8 &
Util.string_append_list([is,s1,s2,re,io,s3," ",n,"= ",s4,s5,s6,s7,s8])
unparse_elementattr_str attr => s4 &
string_append(s1,s2) => s5 &
Absyn.path_string i => s6 &
get_option_str(dim,print_arraydim_str) => s7 &
unparse_mod1_str m => s8 &
unparse_comment_option(optcmt) => s9 &
Util.string_append_list([is,s1,s2,re,io,s3," ",n,"= ",s4,s5,s6,s7,s8,s9])
=> str
------------------------------
unparse_class_str(indent,Absyn.CLASS(n,p,f,e,r,Absyn.DERIVED(i,dim,m,optcmt)),fi,re,io) => str
unparse_class_str(indent,Absyn.CLASS(n,p,f,e,r,Absyn.DERIVED(i,dim,attr,m,optcmt)),fi,re,io) => str

rule indent_str(i) => is &
select_string(p, "partial ", "") => s1 &
Expand Down Expand Up @@ -260,7 +261,7 @@ relation print_class: Absyn.Class => () =
Print.print_buf ") = " & print_path(i) &
print_class_modification(m)
----------------------------------------
print_class(Absyn.CLASS(n,p,f,e,r,Absyn.DERIVED(i,_,m,_))) => ()
print_class(Absyn.CLASS(n,p,f,e,r,Absyn.DERIVED(i,_,_,m,_))) => ()

rule print_class_restriction(r) & Print.print_buf "(" &
Print.print_buf n & Print.print_buf "," &
Expand Down
3 changes: 2 additions & 1 deletion modeq/explode.rml
Expand Up @@ -245,8 +245,9 @@ end
relation elab_classdef: Absyn.ClassDef => ClassDef =

rule build_mod(SOME(Absyn.CLASSMOD(a, NONE)), false) => mod
(* TODO: attributes of derived classes *)
------------------------------------------------
elab_classdef(Absyn.DERIVED(p,d,a,cmt)) => DERIVED(p,d,mod)
elab_classdef(Absyn.DERIVED(p,d,attr,a,cmt)) => DERIVED(p,d,mod)


rule elab_classdef_elements parts => els &
Expand Down
18 changes: 9 additions & 9 deletions modeq/interactive.rml
Expand Up @@ -863,7 +863,7 @@ relation is_primitive_class: (Absyn.Class,Absyn.Program) => bool =
lookup_classdef(path,inmodel,p)=> (cdef,_) &
is_primitive_class(cdef,p) => res
-------------------------------
is_primitive_class(Absyn.CLASS(cname,_,_,_,Absyn.R_CLASS,Absyn.DERIVED(path,_,_,_)),p) => res
is_primitive_class(Absyn.CLASS(cname,_,_,_,Absyn.R_CLASS,Absyn.DERIVED(path,_,_,_,_)),p) => res

end

Expand Down Expand Up @@ -1316,7 +1316,7 @@ relation count_public_components: Absyn.Class => int =
count_public_components Absyn.CLASS(a,b,c,d,e,Absyn.PARTS(_::lst,cmt)) => res

axiom count_public_components Absyn.CLASS(a,b,c,d,e,Absyn.PARTS([],_)) => 0
axiom count_public_components Absyn.CLASS(a,b,c,d,e,Absyn.DERIVED(_,_,_,_)) => -1
axiom count_public_components Absyn.CLASS(a,b,c,d,e,Absyn.DERIVED(_,_,_,_,_)) => -1
end

relation count_components: Absyn.ElementItem list => int =
Expand Down Expand Up @@ -1620,7 +1620,7 @@ relation get_packages_in_class:(Absyn.Path, Absyn.Program, Absyn.Class) => strin
rule lookup_classdef(path,inmodel,p) => (cdef,newpath) &
get_packages_in_class(newpath,p,cdef) => res
--------------------------------------------
get_packages_in_class(inmodel,p,Absyn.CLASS(_,_,_,_,_,Absyn.DERIVED(path,_,_,_))) => res
get_packages_in_class(inmodel,p,Absyn.CLASS(_,_,_,_,_,Absyn.DERIVED(path,_,_,_,_))) => res
end


Expand Down Expand Up @@ -1707,7 +1707,7 @@ relation get_classnames_in_class:(Absyn.Path, Absyn.Program, Absyn.Class) => str
rule lookup_classdef(path,inmodel,p) => (cdef,newpath) &
get_classnames_in_class(newpath,p,cdef) => res
--------------------------------------------
get_classnames_in_class(inmodel,p,Absyn.CLASS(_,_,_,_,_,Absyn.DERIVED(path,_,_,_))) => res
get_classnames_in_class(inmodel,p,Absyn.CLASS(_,_,_,_,_,Absyn.DERIVED(path,_,_,_,_))) => res
end


Expand Down Expand Up @@ -1964,7 +1964,7 @@ relation count_public_connectors: (Absyn.Path, Absyn.Program, Absyn.Class) => in
rule lookup_classdef(cname,modelpath,p) => (cdef,newmodelpath) &
count_public_connectors (newmodelpath,p,cdef) => res
--------------------------------------------------
count_public_connectors (modelpath,p,Absyn.CLASS(a,b,c,d,e,Absyn.DERIVED(cname,_,_,_))) => res
count_public_connectors (modelpath,p,Absyn.CLASS(a,b,c,d,e,Absyn.DERIVED(cname,_,_,_,_))) => res
end

(** relation: count_connectors
Expand Down Expand Up @@ -2320,7 +2320,7 @@ relation get_nth_public_component_in_class: (Absyn.Class,int) => Absyn.Element
get_nth_public_component_in_class (Absyn.CLASS(a,b,c,d,e,Absyn.PARTS(_::lst,cmt)),n) => res

axiom get_nth_public_component_in_class (Absyn.CLASS(a,b,c,d,e,Absyn.PARTS([],cmt)),_) => fail
axiom get_nth_public_component_in_class (Absyn.CLASS(a,b,c,d,e,Absyn.DERIVED(_,_,_,_)),_) => fail
axiom get_nth_public_component_in_class (Absyn.CLASS(a,b,c,d,e,Absyn.DERIVED(_,_,_,_,_)),_) => fail

end

Expand Down Expand Up @@ -2404,7 +2404,7 @@ relation add_to_public: (Absyn.Class, Absyn.ElementItem) => Absyn.Class =
add_to_public ( Absyn.CLASS(i,p,f,e,r,Absyn.PARTS(parts,cmt)), eitem)
=> Absyn.CLASS(i,p,f,e,r,Absyn.PARTS(parts2,cmt))

axiom add_to_public ( Absyn.CLASS(i,p,f,e,r,Absyn.DERIVED(_,_,_,_)),eitem) => fail
axiom add_to_public ( Absyn.CLASS(i,p,f,e,r,Absyn.DERIVED(_,_,_,_,_)),eitem) => fail

axiom add_to_public(Absyn.CLASS(i,p,f,e,r,Absyn.PARTS(parts,cmt)),eitem)
=> Absyn.CLASS(i,p,f,e,r,Absyn.PARTS(Absyn.PUBLIC([eitem])::parts,cmt))
Expand All @@ -2424,7 +2424,7 @@ relation add_to_equation: (Absyn.Class, Absyn.EquationItem) => Absyn.Class =
add_to_equation ( Absyn.CLASS(i,p,f,e,r,Absyn.PARTS(parts,cmt)), eitem)
=> Absyn.CLASS(i,p,f,e,r,Absyn.PARTS(parts2,cmt))

axiom add_to_equation ( Absyn.CLASS(i,p,f,e,r,Absyn.DERIVED(_,_,_,_)),eitem) => fail
axiom add_to_equation ( Absyn.CLASS(i,p,f,e,r,Absyn.DERIVED(_,_,_,_,_)),eitem) => fail

rule (* Add the equations last, to make nicer output if public section present *)
list_append(parts,[Absyn.EQUATIONS([eitem])]) => newparts
Expand Down Expand Up @@ -2720,7 +2720,7 @@ relation get_classes_in_class: (Absyn.Path, Absyn.Program,Absyn.Class) => Absyn.
rule lookup_classdef(path, modelpath,p) => (cdef,newpath) &
get_classes_in_class(newpath,p,cdef) => res
--------------------------------------------
get_classes_in_class(modelpath,p,Absyn.CLASS(_,_,_,_,_,Absyn.DERIVED(path,_,_,_))) => res
get_classes_in_class(modelpath,p,Absyn.CLASS(_,_,_,_,_,Absyn.DERIVED(path,_,_,_,_))) => res
end

relation get_classes_in_parts: Absyn.ClassPart list => Absyn.Class list =
Expand Down

0 comments on commit b956c39

Please sign in to comment.