Skip to content

Commit

Permalink
- replaceable type Type_x; is now replaceable type Type_x subtypeof Any;
Browse files Browse the repository at this point in the history
- The ALG_ASSIGN_TUPLE is gone! use ALG_ASSIGN(exp, exp) instead and check if first exp is Absyn.TUPLE
- MetaModelica parsing now works.
- all the tests (except those already failing) are working.
- a new OMDev is required to be able to compile this: http://www.ida.liu.se/~adrpo/omc/omdev/mingw
- in order to get the compiler out of infinite loop some changes were made to SCode.mo
- changes to modelica and flat_modelica parser and lexer were made.
- imports were changed, I removed to OpenModelica.Compiler from them to make MDT completion work.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2587 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Nov 2, 2006
1 parent 4905100 commit eb09eb8
Show file tree
Hide file tree
Showing 42 changed files with 1,555 additions and 966 deletions.
33 changes: 15 additions & 18 deletions Compiler/Absyn.mo
Expand Up @@ -497,15 +497,10 @@ uniontype Algorithm "The `Algorithm\' type describes one algorithm statement in
reason this type is named like this is that the name of the
grammar rule for algorithm statements is `algorithm\'."
record ALG_ASSIGN
ComponentRef assignComponent "assignComponent" ;
Exp assignComponent "assignComponent" ;
Exp value "value" ;
end ALG_ASSIGN;

record ALG_TUPLE_ASSIGN
Exp tuple_ "tuple" ;
Exp value "value" ;
end ALG_TUPLE_ASSIGN;

record ALG_IF
Exp ifExp "ifExp" ;
list<AlgorithmItem> trueBranch "trueBranch" ;
Expand Down Expand Up @@ -726,11 +721,10 @@ uniontype Exp "The `Exp\' datatype is the container of a Modelica expression.
CodeNode code "code ; Modelica AST Code constructors" ;
end CODE;

record NIL end NIL;

// MetaModelica expression follows!
record AS
ComponentRef id " component reference (actually only an id) " ;
Exp exp " expression to bind to the id ";
Ident id " only an id " ;
Exp exp " expression to bind to the id ";
end AS;

record CONS
Expand All @@ -740,7 +734,7 @@ uniontype Exp "The `Exp\' datatype is the container of a Modelica expression.

record MATCHEXP
MatchType matchTy " match or matchcontinue ";
Exp inputExps " match expression of ";
Exp inputExp " match expression of ";
list<ElementItem> localDecls " local declarations ";
list<Case> cases " case list + else in the end ";
Option<String> comment " match expr comment_optional ";
Expand All @@ -751,16 +745,16 @@ end Exp;
public
uniontype Case
record CASE
list<Exp> pattern " patterns to be matched ";
Exp pattern " patterns to be matched ";
list<ElementItem> localDecls " local decls ";
list<Equation> equations " equations [] for no equations ";
list<EquationItem> equations " equations [] for no equations ";
Exp result " result ";
Option<String> comment " comment after case like: case pattern string_comment ";
end CASE;

record ELSE
list<ElementItem> localDecls " local decls ";
list<Equation> equations " equations [] for no equations ";
list<EquationItem> equations " equations [] for no equations ";
Exp result " result ";
Option<String> comment " comment after case like: case pattern string_comment ";
end ELSE;
Expand Down Expand Up @@ -996,10 +990,10 @@ end ExternalDecl;
/* "From here down, only absyn helper functions should be present.
Thus, no actual absyn datatype definitions." */

protected import OpenModelica.Compiler.Debug;
protected import OpenModelica.Compiler.Util;
protected import OpenModelica.Compiler.Print;
protected import OpenModelica.Compiler.ModUtil;
protected import Debug;
protected import Util;
protected import Print;
protected import ModUtil;

public function elementSpecName "function: elementSpecName
Expand Down Expand Up @@ -1597,6 +1591,9 @@ algorithm
case R_PREDEFINED_REAL() then "PREDEFINED_REAL";
case R_PREDEFINED_STRING() then "PREDEFINED_STRING";
case R_PREDEFINED_BOOL() then "PREDEFINED_BOOL";

/* MetaModelica restriction */
case R_UNIONTYPE() then "UNIONTYPE";
end matchcontinue;
end restrString;

Expand Down
16 changes: 8 additions & 8 deletions Compiler/Algorithm.mo
Expand Up @@ -56,9 +56,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"

public import OpenModelica.Compiler.Exp;
public import OpenModelica.Compiler.Types;
public import OpenModelica.Compiler.SCode;
public import Exp;
public import Types;
public import SCode;

public
type Ident = String;
Expand Down Expand Up @@ -143,11 +143,11 @@ uniontype Else "An if statements can one or more `elseif\' branches and an

end Else;

protected import OpenModelica.Compiler.Util;
protected import OpenModelica.Compiler.Print;
protected import OpenModelica.Compiler.Debug;
protected import OpenModelica.Compiler.Error;
protected import OpenModelica.Compiler.Absyn;
protected import Util;
protected import Print;
protected import Debug;
protected import Error;
protected import Absyn;

public function makeAssignment "function: makeAssignment
Expand Down
12 changes: 6 additions & 6 deletions Compiler/Builtin.mo
Expand Up @@ -54,13 +54,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"

public import OpenModelica.Compiler.Absyn;
public import OpenModelica.Compiler.SCode;
public import OpenModelica.Compiler.Env;
public import Absyn;
public import SCode;
public import Env;

/* protected imports */
protected import OpenModelica.Compiler.Types;
protected import OpenModelica.Compiler.ClassInf;
protected import Types;
protected import ClassInf;

/*
- The primitive types
Expand Down Expand Up @@ -171,7 +171,7 @@ protected constant Types.Var timeVar=Types.VAR("time",
Types.ATTR(false,SCode.RO(),SCode.VAR(),Absyn.BIDIR()),false,(Types.T_REAL({}),NONE),Types.UNBOUND()) "- The `time\' variable" ;

protected
replaceable type Type_a;
replaceable type Type_a subtypeof Any;
constant tuple<Types.TType, Option<Type_a>> nil2real=(Types.T_FUNCTION({},(Types.T_REAL({}),NONE)),NONE) "- Some assorted function types" ;

protected constant tuple<Types.TType, Option<Type_a>> nil2bool=(Types.T_FUNCTION({},(Types.T_REAL({}),NONE)),NONE);
Expand Down
58 changes: 29 additions & 29 deletions Compiler/Ceval.mo
Expand Up @@ -64,13 +64,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Subscript list : Evaluates subscripts and generates constant expressions.
"

public import OpenModelica.Compiler.Env;
public import OpenModelica.Compiler.Exp;
public import OpenModelica.Compiler.Interactive;
public import OpenModelica.Compiler.Values;
public import OpenModelica.Compiler.DAELow;
public import OpenModelica.Compiler.Absyn;
public import OpenModelica.Compiler.Types;
public import Env;
public import Exp;
public import Interactive;
public import Values;
public import DAELow;
public import Absyn;
public import Types;

public
uniontype Msg
Expand All @@ -80,28 +80,28 @@ uniontype Msg

end Msg;

protected import OpenModelica.Compiler.SimCodegen;
protected import OpenModelica.Compiler.Static;
protected import OpenModelica.Compiler.Print;
protected import OpenModelica.Compiler.ModUtil;
protected import OpenModelica.Compiler.System;
protected import OpenModelica.Compiler.SCode;
protected import OpenModelica.Compiler.Inst;
protected import OpenModelica.Compiler.Lookup;
protected import OpenModelica.Compiler.Dump;
protected import OpenModelica.Compiler.DAE;
protected import OpenModelica.Compiler.Debug;
protected import OpenModelica.Compiler.Util;
protected import OpenModelica.Compiler.ClassInf;
protected import OpenModelica.Compiler.RTOpts;
protected import OpenModelica.Compiler.Parser;
protected import OpenModelica.Compiler.Prefix;
protected import OpenModelica.Compiler.Codegen;
protected import OpenModelica.Compiler.ClassLoader;
protected import OpenModelica.Compiler.Derive;
protected import OpenModelica.Compiler.Connect;
protected import OpenModelica.Compiler.Error;
protected import OpenModelica.Compiler.Settings;
protected import SimCodegen;
protected import Static;
protected import Print;
protected import ModUtil;
protected import System;
protected import SCode;
protected import Inst;
protected import Lookup;
protected import Dump;
protected import DAE;
protected import Debug;
protected import Util;
protected import ClassInf;
protected import RTOpts;
protected import Parser;
protected import Prefix;
protected import Codegen;
protected import ClassLoader;
protected import Derive;
protected import Connect;
protected import Error;
protected import Settings;


protected function cevalBuiltin "function: cevalBuiltin
Expand Down
8 changes: 4 additions & 4 deletions Compiler/ClassInf.mo
Expand Up @@ -57,8 +57,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"

public import OpenModelica.Compiler.SCode;
public import OpenModelica.Compiler.Absyn;
public import SCode;
public import Absyn;

public
uniontype State "- Machine states, the string contains the classname."
Expand Down Expand Up @@ -139,8 +139,8 @@ uniontype Event "- Events"

end Event;

protected import OpenModelica.Compiler.Print;
protected import OpenModelica.Compiler.Error;
protected import Print;
protected import Error;

public function printStateStr "- Printing
Expand Down
14 changes: 7 additions & 7 deletions Compiler/ClassLoader.mo
Expand Up @@ -52,14 +52,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"

public import OpenModelica.Compiler.Absyn;
public import Absyn;

protected import OpenModelica.Compiler.System;
protected import OpenModelica.Compiler.Interactive;
protected import OpenModelica.Compiler.Util;
protected import OpenModelica.Compiler.Parser;
protected import OpenModelica.Compiler.Print;
protected import OpenModelica.Compiler.Debug;
protected import System;
protected import Interactive;
protected import Util;
protected import Parser;
protected import Print;
protected import Debug;

public function loadClass "function: loadClass
This function takes a \'Path\' and the $OPENMODELICALIBRARY as a string
Expand Down
28 changes: 14 additions & 14 deletions Compiler/Codegen.mo
Expand Up @@ -55,10 +55,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-------------------------------------------------------------------------"

public import OpenModelica.Compiler.DAE;
public import OpenModelica.Compiler.Print;
public import OpenModelica.Compiler.Exp;
public import OpenModelica.Compiler.Absyn;
public import DAE;
public import Print;
public import Exp;
public import Absyn;

public
type Ident = String;
Expand Down Expand Up @@ -138,16 +138,16 @@ uniontype ExpContext
record EXP_EXTERNAL "for expressions in external calls" end EXP_EXTERNAL;
end ExpContext;

protected import OpenModelica.Compiler.Debug;
protected import OpenModelica.Compiler.Algorithm;
protected import OpenModelica.Compiler.ClassInf;
protected import OpenModelica.Compiler.ModUtil;
protected import OpenModelica.Compiler.Types;
protected import OpenModelica.Compiler.Util;
protected import OpenModelica.Compiler.Inst;
protected import OpenModelica.Compiler.Interactive;
protected import OpenModelica.Compiler.System;
protected import OpenModelica.Compiler.Error;
protected import Debug;
protected import Algorithm;
protected import ClassInf;
protected import ModUtil;
protected import Types;
protected import Util;
protected import Inst;
protected import Interactive;
protected import System;
protected import Error;

public constant CFunction cEmptyFunction=CFUNCTION("","",{},{},{},{},{},{}) " empty function ";

Expand Down
18 changes: 9 additions & 9 deletions Compiler/Connect.mo
Expand Up @@ -56,10 +56,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"

public import OpenModelica.Compiler.Exp;
public import OpenModelica.Compiler.Static;
public import OpenModelica.Compiler.DAE;
public import OpenModelica.Compiler.Env;
public import Exp;
public import Static;
public import DAE;
public import Env;

public
uniontype Face "This type indicates whether a connector is an inner or an outer
Expand Down Expand Up @@ -921,11 +921,11 @@ algorithm
end matchcontinue;
end getOuterFlowVariables2;

protected import OpenModelica.Compiler.Print;
protected import OpenModelica.Compiler.Util;
protected import OpenModelica.Compiler.Types;
protected import OpenModelica.Compiler.Lookup;
protected import OpenModelica.Compiler.Absyn;
protected import Print;
protected import Util;
protected import Types;
protected import Lookup;
protected import Absyn;

/*
- Printing
Expand Down
36 changes: 18 additions & 18 deletions Compiler/DAE.mo
Expand Up @@ -55,12 +55,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- Module header"

public import OpenModelica.Compiler.Absyn;
public import OpenModelica.Compiler.Exp;
public import OpenModelica.Compiler.Algorithm;
public import OpenModelica.Compiler.Types;
public import OpenModelica.Compiler.Values;
public import OpenModelica.Compiler.ClassInf;
public import Absyn;
public import Exp;
public import Algorithm;
public import Types;
public import Values;
public import ClassInf;

public
type Ident = String;
Expand Down Expand Up @@ -332,17 +332,17 @@ uniontype DAElist "A DAElist is a list of Elements. Variables, equations, functi

end DAElist;

protected import OpenModelica.Compiler.RTOpts;
protected import OpenModelica.Compiler.Graphviz;
protected import OpenModelica.Compiler.Dump;
protected import OpenModelica.Compiler.Print;
protected import OpenModelica.Compiler.Util;
protected import OpenModelica.Compiler.Ceval;
protected import OpenModelica.Compiler.ModUtil;
protected import OpenModelica.Compiler.Debug;
protected import OpenModelica.Compiler.Error;
protected import OpenModelica.Compiler.SCode;
protected import OpenModelica.Compiler.Env;
protected import RTOpts;
protected import Graphviz;
protected import Dump;
protected import Print;
protected import Util;
protected import Ceval;
protected import ModUtil;
protected import Debug;
protected import Error;
protected import SCode;
protected import Env;

public function dump "function: dump
Expand Down Expand Up @@ -2772,7 +2772,7 @@ public function buildGrStrlist "function buildGrStrlist
input Integer inInteger;
output list<String> outStringLst;
output list<Type_a> outTypeALst;
replaceable type Type_a;
replaceable type Type_a subtypeof Any;
partial function FuncTypeType_aToString
input Type_a inTypeA;
output String outString;
Expand Down

0 comments on commit eb09eb8

Please sign in to comment.