Skip to content

Commit

Permalink
2005-10-31 adrpo@ida
Browse files Browse the repository at this point in the history
- added Info datatype INFO(filename, lineno, columnno)
- changed so that CLASS and ELEMENT uses the Info datatype
- fixed everything in the other rml files
- tested on the standard tests and passed



git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1939 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Oct 31, 2005
1 parent 9becb65 commit a2c788f
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 234 deletions.
19 changes: 12 additions & 7 deletions Compiler/Absyn.rml
Expand Up @@ -92,6 +92,12 @@ module Absyn:
(** Within statements *)
datatype Within = WITHIN of Path | TOP


(** adrpo added 2005-10-29 **)
datatype Info = INFO of string * (* filename where the class is defined in *)
int * (* line number *)
int (* column number *)

(** - Classes *)
(** A class definition consists of a name, a flag to indicate if this *)
(** class is declared as `partial', the declared class restriction, *)
Expand All @@ -100,9 +106,9 @@ module Absyn:
* bool (* Partial *)
* bool (* Final *)
* bool (* Encapsulated *)
* Restriction (* Restricion *)
* ClassDef (* Body *)
* string (* File name class is defined in*)
* Restriction (* Restricion *)
* ClassDef (* Body *)
* Info (* File name the class is defined in + line no + column no *)


(** The `ClassDef' type contains the definition part of a class *)
Expand Down Expand Up @@ -167,8 +173,7 @@ module Absyn:
* InnerOuter (* inner/outer *)
* Ident (* Element name *)
* ElementSpec (* Actual element specification*)
* string (* Source code file *)
* int (* Line number *)
* Info (* File name the class is defined in + line no + column no *)
* ConstrainClass option (* only valid for classdef and component*)


Expand Down Expand Up @@ -800,7 +805,7 @@ end

relation class_filename: Class => string =

axiom class_filename (CLASS(_,_,_,_,_,_,filename)) => filename
axiom class_filename (CLASS(_,_,_,_,_,_,INFO(filename,_,_))) => filename
end

(** relation class_filename
Expand All @@ -813,7 +818,7 @@ relation set_class_filename: (Class,string) => Class =


axiom set_class_filename(CLASS(n,p,f,e,r,body,_),filename)
=> CLASS(n,p,f,e,r,body,filename)
=> CLASS(n,p,f,e,r,body,INFO(filename,0,0))
end


Expand Down
4 changes: 2 additions & 2 deletions Compiler/Ceval.rml
Expand Up @@ -940,9 +940,9 @@ relation ceval_ast_elt: (Env.Env, Absyn.Element,

rule ceval_ast_citems(env,citems,impl,st,msg) => citems'
-----------------------------------------------
ceval_ast_elt (env, Absyn.ELEMENT(f,r,io,id,Absyn.COMPONENTS(attr,tp,citems),file,line,c),
ceval_ast_elt (env, Absyn.ELEMENT(f,r,io,id,Absyn.COMPONENTS(attr,tp,citems),Absyn.INFO(file,line,column),c),
impl,st,msg)
=> (Absyn.ELEMENT(f,r,io,id,Absyn.COMPONENTS(attr,tp,citems'),file,line,c))
=> (Absyn.ELEMENT(f,r,io,id,Absyn.COMPONENTS(attr,tp,citems'),Absyn.INFO(file,line,column),c))
end

(** relation: ceval_ast_citems
Expand Down
34 changes: 23 additions & 11 deletions Compiler/Dump.rml
Expand Up @@ -501,11 +501,17 @@ relation print_class: Absyn.Class => () =
print_class_restriction(r) &
Print.print_buf(", ") &
print_classdef(cdef) &
Print.print_buf(",\"") &
Print.print_buf(",Absyn.INFO(\"") &
Print.print_buf filename &
Print.print_buf("\")\n")
Print.print_buf("\", ") &
int_string line => s1 &
Print.print_buf s1 &
Print.print_buf(", ") &
int_string col => s2 &
Print.print_buf s2 &
Print.print_buf("))\n")
----------------------------------------
print_class(Absyn.CLASS(n,p,f,e,r,cdef,filename)) => ()
print_class(Absyn.CLASS(n,p,f,e,r,cdef,Absyn.INFO(filename,line,col))) => ()
end

(** relation: print_classdef
Expand Down Expand Up @@ -1114,14 +1120,17 @@ relation print_element: Absyn.Element => () =
Print.print_buf name &
Print.print_buf "\", " &
print_elementspec spec &
Print.print_buf ", \"" &
Print.print_buf ", Absyn.INFO(\"" &
Print.print_buf filename &
Print.print_buf "\", " &
int_string lineno => s1 &
Print.print_buf s1 &
Print.print_buf ",NONE)"
Print.print_buf ", " &
int_string colno => s2 &
Print.print_buf s2 &
Print.print_buf "), NONE)"
---------------------------
print_element (Absyn.ELEMENT(final,repl,inout,name,spec,filename,lineno,NONE))
print_element (Absyn.ELEMENT(final,repl,inout,name,spec,Absyn.INFO(filename,lineno,colno),NONE))

rule Print.print_buf "Absyn.ELEMENT(" &
print_bool(final) &
Expand All @@ -1132,14 +1141,17 @@ relation print_element: Absyn.Element => () =
Print.print_buf name &
Print.print_buf "\", " &
print_elementspec spec &
Print.print_buf ", \"" &
Print.print_buf ", Absyn.INFO(\"" &
Print.print_buf filename &
Print.print_buf "\", " &
int_string lineno => s1 &
Print.print_buf s1 &
Print.print_buf "SOME(...))"
Print.print_buf ", " &
int_string colno => s2 &
Print.print_buf s2 &
Print.print_buf "), SOME(...))"
---------------------------
print_element (Absyn.ELEMENT(final,repl,inout,name,spec,filename,lineno,SOME(_)))
print_element (Absyn.ELEMENT(final,repl,inout,name,spec,Absyn.INFO(filename,lineno,colno),SOME(_)))

end

Expand All @@ -1157,15 +1169,15 @@ relation unparse_element_str: (int, Absyn.Element) => string =
unparse_constrainclass_opt_str(constr) => s5 &
Util.string_append_list([s4, s5, ";"]) => str
----------------------------
unparse_element_str(i, Absyn.ELEMENT(final,SOME(repl),inout,_,spec,filename,lineno,constr)) => str
unparse_element_str(i, Absyn.ELEMENT(final,SOME(repl),inout,_,spec,Absyn.INFO(filename,lineno,colno),constr)) => str

rule select_string(final, "final ", "") => s1 &
unparse_innerouter_str inout => s3 &
unparse_elementspec_str(i, spec,s1,"",s3) => s4 &
unparse_constrainclass_opt_str(constr) => s5 &
Util.string_append_list([s4,s5, ";"]) => str
----------------------------
unparse_element_str(i, Absyn.ELEMENT(final,NONE,inout,_,spec,filename,lineno,constr)) => str
unparse_element_str(i, Absyn.ELEMENT(final,NONE,inout,_,spec,Absyn.INFO(filename,lineno,colno),constr)) => str
end

(** relation: unparse_constrainclass_opt_str
Expand Down
2 changes: 1 addition & 1 deletion Compiler/DumpGraphviz.rml
Expand Up @@ -240,7 +240,7 @@ relation print_element: Absyn.Element => Node =
print_elementspec spec => elsp
(* & print "> End of rule print_element\n" *)
------------------
print_element (Absyn.ELEMENT(final,_,_,_,spec,_,_,_)) => Graphviz.NODE("ELEMENT",[fa],[elsp])
print_element (Absyn.ELEMENT(final,_,_,_,spec,_,_)) => Graphviz.NODE("ELEMENT",[fa],[elsp])

end

Expand Down

0 comments on commit a2c788f

Please sign in to comment.