Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@282 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x97davka committed Apr 23, 1998
1 parent f1f35c8 commit 2370bd4
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 43 deletions.
12 changes: 8 additions & 4 deletions modeq/Makefile
Expand Up @@ -26,6 +26,7 @@ SRCRML= exp.rml \
connect.rml \
classinf.rml \
staticexp.rml \
values.rml \
inst.rml \
main.rml

Expand All @@ -36,12 +37,15 @@ SRCO= $(SRCC:.c=.o)
SUBDIRS = ast

.SUFFIXES:
.SUFFIXES: .o .rml
.SUFFIXES: .o .rml .h
.PHONY: all subdirs report

.rml.o:
$(RML) -c $<

.rml.h:
$(RML) -c $<

all : $(SRCO) subdirs $(PROG)

test:
Expand All @@ -52,16 +56,16 @@ $(PROG): $(SRCO) ast/libast.a

absyn.o: absyn.rml
exp.o: exp.rml
env.o: env.rml
env.o: env.rml exp.h values.h
explode.o: explode.rml
inst.o: inst.rml env.rml
inst.o: inst.rml env.rml values.h
mod.o: mod.rml exp.rml absyn.h dae.h prefix.h env.h
main.o: main.rml
dump.o: dump.rml
package.o: env.h
lookup.o: env.h
builtin.o: builtin.rml env.h
staticexp.o: staticexp.rml env.h
staticexp.o: staticexp.rml env.h values.h

#main.o: main.rml absyn.rml parse.rml dump.rml \
# lform.rml dae.rml inst.rml
Expand Down
2 changes: 1 addition & 1 deletion modeq/main.rml
Expand Up @@ -24,7 +24,7 @@ relation main =

print "\n = Instantiating\n\n" &
Inst.instantiate(p') => d &
print "\n" &
print "\nEquations:\n\n" &
DAE.dump d &

print "\n[slut]\n"
Expand Down
83 changes: 69 additions & 14 deletions modeq/report/report.tex
Expand Up @@ -19,7 +19,7 @@

\makeatletter

% See the verbatim package
% See the verbatim package for info about this
\def\boxedverbatim{\begingroup%
\parskip=0pt\topsep=0pt\partopsep=0pt%
\def\verbatim@processline{%
Expand Down Expand Up @@ -118,6 +118,12 @@ \section{The report}
text. This program is a quick'n'dirty Pike\note{ref} hack, and is
provided in appendix\note{ref}.


\chapter{System overview}
\label{cha:system}



\chapter{Informal semantics}
\label{cha:semantics}

Expand Down Expand Up @@ -451,6 +457,25 @@ \section{Class restriction inference}

\note{Skriv nåt om \code{ClassInf.valid}}


\chapter{Target language}
\label{cha:target}

The formal semantic specification in chapter \ref{cha:formsem}
specifies the semantics of Modelica by showing how it is translated
into another, simpler, language. The translation is a sort of
flattening of the object-oriented structure of the model. This
chapter describes the format of the output of the translator.

\section{Requirements}

The target language needs to be able to express everything that can be
expressed by the Modelica language, but it may do so in a much less
structured way. The major part of the translator output consists of a
flat list of equations which are the result of instantiating the main
model of the source file and its subcomponents. Thus


\chapter{Annotated formal semantics}
\label{cha:formsem}

Expand All @@ -460,23 +485,53 @@ \chapter{Annotated formal semantics}

\section{Overview}

The specification is separated into a number of files, to modularize
it and to make it easier to maintain and to make the structure
clearer.

\begin{table}[htbp]
\begin{center}
\begin{tabular}{llp{8cm}}
\hline
\ref{src:exp} & \code{exp.tex} & Expressions \\
\ref{src:classinf} & \code{classinf.tex} & Class inference \\
\ref{src:dae} & \code{dae.tex} & Output \\
\ref{src:types} & \code{types.tex} & \\
\ref{src:absyn} & \code{absyn.tex} & Abstract syntax \\
\ref{src:explode} & \code{explode.tex} & \\
\ref{src:dump} & \code{dump.tex} & \\
\ref{src:prefix} & \code{prefix.tex} & \\
\ref{src:mod} & \code{mod.tex} & \\
\ref{src:env} & \code{env.tex} & \\
\ref{src:lookup} & \code{lookup.tex} & \\
\ref{src:builtin} & \code{builtin.tex} & \\
\ref{src:connect} & \code{connect.tex} & \\
\ref{src:staticexp} & \code{staticexp.tex}& \\
\ref{src:inst} & \code{inst.tex} & \\
\ref{src:main} & \code{main.tex} & \\
\hline
\end{tabular}
\caption{Files in the specification}
\label{tab:files}
\end{center}
\end{table}

\input{exp.tex}
\input{classinf.tex}
\input{dae.tex}
\input{types.tex}
\input{absyn.tex}
\input{explode.tex}
\input{dump.tex}
\input{prefix.tex}
\input{mod.tex}
\input{env.tex}
\input{lookup.tex}
\input{builtin.tex}
\input{connect.tex}
\input{staticexp.tex}
\input{inst.tex}
\input{main.tex}
%\input{types.tex}
%\input{absyn.tex}
%\input{explode.tex}
%\input{dump.tex}
%\input{prefix.tex}
%\input{mod.tex}
%\input{env.tex}
%\input{lookup.tex}
%\input{builtin.tex}
%\input{connect.tex}
%\input{staticexp.tex}
%\input{inst.tex}
%\input{main.tex}


\chapter{rmldoc \note{appendix}}
Expand Down
62 changes: 62 additions & 0 deletions modeq/report/semantik
Expand Up @@ -44,6 +44,8 @@ when the programmer forgot about the variable shadowing rules.
In this case b1.x will be 1 and b2.x will be 100, but the modification
of b1 is lost, so I can't see the need for it.

Status: This seems to be actually needed.

* Types in equations

Vilka variabler f�r man ha i ekvationer? Bara Real(Type) och
Expand All @@ -57,6 +59,8 @@ Exakt hur fungerar connect()?

Beskrivningen av connect-semantiken (B.2) m�ste vara fel.

Status: Being rewritten.

* Kvalificerade identifierare

What can `foo' be in "foo.bar"? Different things if looking for a
Expand Down Expand Up @@ -121,6 +125,8 @@ the same as
x = y;
end M;

This is almost true, but not completely.

* Allt �r ekvationer

Tydligen s� ska tilldelningar vid variabeldeklarationer betraktas som
Expand Down Expand Up @@ -278,3 +284,59 @@ possible.
...

This is not explained either, as far as I can tell.

* Type equality(?) in equations

What are the requirements on two components that are "=" in an
equation?

class A
...
end A;

class B
...
end B;

class C
A a;
B b1;
B b2 = a
equation
a = b1;
end C;

According to an example in the report ther might be enough with a
subtype relation.

* Recursive equations

From the report:

transpose(a) * [1; x; x^2; ... x^n]

if we could form the vector of increasing powers of x. A recursive formulation is possible.

xpowers[1] = 1;
xpowers[2:n+1] = xpowers[1:n]*x;
y = transpose(a) * xpowers;

The recursive formulation would be expanded to

xpowers[1] = 1;
xpowers[2] = xpowers[1]*x;
xpowers[3] = xpowers[2]*x;
...
xpowers[n+1] = xpowers[n]*x;
y = transpose(a) * xpowers;

Thinking about this I see that there is no problem at all. The array
equation is unrolled in the normal fashion.

* while

How are while loops treated in equation sections?

* enable

What are the semantics of the enable attribute?
35 changes: 11 additions & 24 deletions modeq/report/syntax
Expand Up @@ -10,10 +10,12 @@ and not

"=" IDENT [ array_dimensions ] [ class_modification ] )

Status: fixed

* Redeclare of array elements

This is currently allowed by the grammar, but seems to me to be
obviously wrong.
obviously wrong. And it seems that others agree.

class Foo
Int x;
Expand Down Expand Up @@ -49,6 +51,7 @@ Trouble: This disallows the following (correct) example:
Foo y(x[17] = 123.0);
end Bar;

Status: Unresolved. Maybe a semantic rule to prohibit this is needed.

* Double modifiers

Expand Down Expand Up @@ -90,41 +93,19 @@ modifications simultaneously, as in the following example:
constant Real N_A (final unit="mol-1")
= 6.0221367e23 "Avogadro constant";

There are two obvious solutions that I can see.

I. Rewrite the Standard Library to say

constant Real N_A (final unit="mol-1",
value = 6.0221367e23) "Avogadro constant";

II. Change the modification rule to something like
Solution: Change the modification rule to something like

modification :
class_modification [ "=" expression ]
| "=" expression

I think that the latter is preferrable, and after reading design
meeting minutes, I am sure of it.

* final

Appendix B.5 contains a note that says that a class declaration can be
prefixed with "final", but that is not described by the grammar.

Suggestion: Change the production rule for class_definition.

Previously:

class_definition :
[ partial ]
( class | model | record | block | connector | type |
package | function )
IDENT comment
( composition end IDENT |
"=" IDENT [ array_dimensions ] [ class_modification ] )

New:

class_definition :
[ partial | final ]
( class | model | record | block | connector | type |
Expand All @@ -133,6 +114,8 @@ New:
( composition end IDENT |
"=" IDENT [ array_dimensions ] [ class_modification ] )

Status: fixed

* connect

Connect statements in the equation part of a class definition can not
Expand All @@ -149,7 +132,11 @@ component_reference, as the can only be one dot in them (ref. Dag).
| while_clause )
comment

Status: fixed in a similar way

* File name suffix

The file name suffix should be standardized. I have seen both .mdc,
.mod and .mo. I vote for .mdc.

Status: The preferred is ".mo".

0 comments on commit 2370bd4

Please sign in to comment.