Skip to content

Commit

Permalink
- increase the memory_pool for real numbers from 10000 to 1000000.
Browse files Browse the repository at this point in the history
- added the new element wise operators ./,.*,.+,.^
  to the modelica/flat_modelica parsers, walker,
  lexers, Absyn.mo and Dump.mo
- handling no return equations and algorithms in Dump.mo.
- beautifying the output of the flat Modelica.
- beautifying the generated code.
- added a no return equation and algorithm in FlatParse.mof

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@3769 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Dec 12, 2008
1 parent e6a40d4 commit 0262b87
Show file tree
Hide file tree
Showing 11 changed files with 389 additions and 391 deletions.
59 changes: 27 additions & 32 deletions Compiler/Absyn.mo
Expand Up @@ -895,38 +895,33 @@ end NamedArg;


uniontype Operator "Expression operators"
record ADD end ADD;

record SUB end SUB;

record MUL end MUL;

record DIV end DIV;

record POW end POW;

record UPLUS end UPLUS;

record UMINUS end UMINUS;

record AND end AND;

record OR end OR;

record NOT end NOT;

record LESS end LESS;

record LESSEQ end LESSEQ;

record GREATER end GREATER;

record GREATEREQ end GREATEREQ;

record EQUAL end EQUAL;

record NEQUAL end NEQUAL;

/* arithmetic operators */
record ADD "addition" end ADD;
record SUB "subtraction" end SUB;
record MUL "multiplication" end MUL;
record DIV "division" end DIV;
record POW "power" end POW;
record UPLUS "unary plus" end UPLUS;
record UMINUS "unary minus" end UMINUS;
/* element-wise arithmetic operators */
record ADD_EW "element-wise addition" end ADD_EW;
record SUB_EW "element-wise subtraction" end SUB_EW;
record MUL_EW "element-wise multiplication" end MUL_EW;
record DIV_EW "element-wise division" end DIV_EW;
record POW_EW "element-wise power" end POW_EW;
record UPLUS_EW "element-wise unary minus" end UPLUS_EW;
record UMINUS_EW "element-wise unary plus" end UMINUS_EW;
/* logical operators */
record AND "logical and" end AND;
record OR "logical or" end OR;
record NOT "logical not" end NOT;
/* relational operators */
record LESS "less than" end LESS;
record LESSEQ "less than or equal" end LESSEQ;
record GREATER "greater than" end GREATER;
record GREATEREQ "greater than or equal" end GREATEREQ;
record EQUAL "relational equal" end EQUAL;
record NEQUAL "relational not equal" end NEQUAL;
end Operator;


Expand Down
25 changes: 20 additions & 5 deletions Compiler/ClassLoader.mo
Expand Up @@ -152,6 +152,7 @@ algorithm
String mp,pd,classfile,classfile_1,class_,mp_1,dirfile,packfile;
Absyn.Program p;
case (class_,mp_1)
local Real t1, t2; String s;
equation
mp = System.trim(mp_1, " \"\t");
pd = System.pathDelimiter();
Expand All @@ -160,8 +161,11 @@ algorithm
existRegularFile(classfile_1);
print("parsing ");
print(classfile_1);
print("\n");
t1 = clock();
p = Parser.parse(classfile_1);
t2 = clock();
s = realString(t2 -. t1);
print(" [" +& s +& "s]\n");
then
p;
case (class_,mp_1)
Expand Down Expand Up @@ -229,16 +233,20 @@ algorithm
Absyn.Program p1_1,p2,p;
list<String> subdirs;
Absyn.Path wpath_1,wpath;
case (pack,mp,(within_ as Absyn.TOP()),Absyn.PROGRAM(classes = oldc))
Real t1, t2; String s;
case (pack,mp,(within_ as Absyn.TOP()),Absyn.PROGRAM(classes = oldc))
equation
pd = System.pathDelimiter();
mp_1 = Util.stringAppendList({mp,pd,pack});
packagefile = Util.stringAppendList({mp_1,pd,"package.mo"});
existRegularFile(packagefile);
print("parsing ");
print(packagefile);
print("\n");
t1 = clock();
Absyn.PROGRAM(p1,w1) = Parser.parse(packagefile);
t2 = clock();
s = realString(t2 -. t1);
print(" [" +& s +& "s]\n");
Print.printBuf("loading ");
Print.printBuf(packagefile);
Print.printBuf("\n");
Expand All @@ -260,8 +268,11 @@ algorithm
existRegularFile(packagefile);
print("parsing ");
print(packagefile);
print("\n");
t1 = clock();
Absyn.PROGRAM(p1,w1) = Parser.parse(packagefile);
t2 = clock();
s = realString(t2 -. t1);
print(" [" +& s +& "s]\n");
Print.printBuf("loading ");
Print.printBuf(packagefile);
Print.printBuf("\n");
Expand Down Expand Up @@ -379,6 +390,7 @@ algorithm
list<Absyn.Class> cls,oldc;
Absyn.Program p_1,p_2;
list<String> fs;
Real t1, t2; String s;
case ({},mp,within_,Absyn.PROGRAM(classes = cls,within_ = w))
then (Absyn.PROGRAM(cls,w));
case ((f :: fs),mp,within_,Absyn.PROGRAM(classes = oldc))
Expand All @@ -387,8 +399,11 @@ algorithm
f_1 = Util.stringAppendList({mp,pd,f});
print("parsing ");
print(f_1);
print("\n");
t1 = clock();
Absyn.PROGRAM(cls,_) = Parser.parse(f_1);
t2 = clock();
s = realString(t2 -. t1);
print(" [" +& s +& "s]\n");
Print.printBuf("loading ");
Print.printBuf(f_1);
Print.printBuf("\n");
Expand Down
6 changes: 3 additions & 3 deletions Compiler/Codegen.mo
Expand Up @@ -435,15 +435,15 @@ algorithm
end cPrintDeclarations;

protected function addNewlineIfNotEmpty
input String inStr;
output String outStr;
input String inStr;
output String outStr;
algorithm
outStr := matchcontinue (inStr)
local String sTrim;
case (inStr)
equation
sTrim = System.trim(inStr, " ");
failure(true = stringEqual(sTrim, ""));
false = stringEqual(sTrim, "");
then (inStr +& "\n");
case (inStr) then "";
end matchcontinue;
Expand Down

0 comments on commit 0262b87

Please sign in to comment.