Skip to content

Commit

Permalink
- Susan indentation with '<<' is now determined by indentation of the…
Browse files Browse the repository at this point in the history
… line where is the '<<'

  that is, in examples:
<<
  text
>>
  <<
    text
  >>
  case PATTRN then <<
    text
  >>

  the word 'text' is always indented by 2


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4605 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
pavolpr committed Nov 30, 2009
1 parent ccc48e3 commit d6a8386
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 222 deletions.
28 changes: 14 additions & 14 deletions Compiler/TplCodegen.mo
Expand Up @@ -195,9 +195,9 @@ algorithm
txt = Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
txt = typedIdentsEx(txt, i_mf_outArgs, "output", "out_");
txt = Tpl.softNewLine(txt);
txt = Tpl.popBlock(txt);
txt = fun_5(txt, i_mf_locals);
txt = Tpl.softNewLine(txt);
txt = Tpl.popBlock(txt);
txt = Tpl.writeTok(txt, Tpl.ST_LINE("algorithm\n"));
txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE, SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
Expand Down Expand Up @@ -467,8 +467,8 @@ algorithm
local
TplAbsyn.TypedIdents i_locals;
equation
txt = Tpl.writeTok(txt, Tpl.ST_LINE(" local\n"));
txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(8));
txt = Tpl.writeTok(txt, Tpl.ST_LINE(" local\n"));
txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
txt = typedIdents(txt, i_locals);
txt = Tpl.popBlock(txt);
then txt;
Expand Down Expand Up @@ -532,8 +532,8 @@ algorithm
local
list<TplAbsyn.MMExp> i_statements;
equation
txt = Tpl.writeTok(txt, Tpl.ST_LINE(" equation\n"));
txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(8));
txt = Tpl.writeTok(txt, Tpl.ST_LINE(" equation\n"));
txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE, SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
txt = lm_14(txt, i_statements);
txt = Tpl.popIter(txt);
Expand Down Expand Up @@ -639,24 +639,24 @@ algorithm
list<TplAbsyn.MatchingExp> i_mexps;
equation
txt = Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
txt = Tpl.writeTok(txt, Tpl.ST_STRING("case ( "));
txt = Tpl.pushBlock(txt, Tpl.BT_ANCHOR(0));
txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE, SOME(Tpl.ST_LINE(",\n")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
txt = lm_12(txt, i_mexps);
txt = Tpl.popIter(txt);
txt = Tpl.popBlock(txt);
txt = Tpl.writeTok(txt, Tpl.ST_LINE(" )\n"));
txt = Tpl.popBlock(txt);
txt = fun_13(txt, i_locals);
txt = Tpl.softNewLine(txt);
txt = fun_15(txt, i_statements);
txt = Tpl.softNewLine(txt);
txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(6));
txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
txt = Tpl.writeTok(txt, Tpl.ST_STRING("then "));
txt = fun_17(txt, i_outArgs);
txt = Tpl.writeTok(txt, Tpl.ST_STRING(";"));
txt = Tpl.popBlock(txt);
txt = Tpl.popBlock(txt);
txt = Tpl.nextIter(txt);
txt = lm_18(txt, rest, i_outArgs);
then txt;
Expand Down Expand Up @@ -706,12 +706,12 @@ algorithm
out_txt := typedIdents(out_txt, i_locals);
out_txt := Tpl.softNewLine(out_txt);
out_txt := Tpl.popBlock(out_txt);
out_txt := Tpl.popBlock(out_txt);
out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE, SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
out_txt := lm_18(out_txt, i_matchCases, i_outArgs);
out_txt := Tpl.popIter(out_txt);
out_txt := Tpl.softNewLine(out_txt);
out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" end matchcontinue;"));
out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("end matchcontinue;"));
out_txt := Tpl.popBlock(out_txt);
end mmMatchFunBody;

public function pathIdent
Expand Down Expand Up @@ -1271,8 +1271,8 @@ public function mmEscapeStringConst
input Boolean i_escapeNewLine;

output Tpl.Text out_txt;
protected
list<String> ret_0;
protected
list<String> ret_0;
algorithm
ret_0 := stringListStringChar(i_internalValue);
out_txt := lm_32(txt, ret_0, i_escapeNewLine);
Expand Down Expand Up @@ -1846,7 +1846,6 @@ algorithm
TplAbsyn.PathIdent i_importPackage;
Boolean i_isDefault;
equation
txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
txt = fun_44(txt, i_isDefault);
txt = Tpl.writeTok(txt, Tpl.ST_STRING("absyn "));
txt = pathIdent(txt, i_importPackage);
Expand All @@ -1864,7 +1863,6 @@ algorithm
txt = pathIdent(txt, i_importPackage);
txt = Tpl.writeTok(txt, Tpl.ST_STRING(";"));
txt = Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
txt = Tpl.popBlock(txt);
txt = Tpl.nextIter(txt);
txt = lm_46(txt, rest);
then txt;
Expand Down Expand Up @@ -1937,11 +1935,13 @@ algorithm
txt = Tpl.writeTok(txt, Tpl.ST_STRING("spackage "));
txt = pathIdent(txt, i_name);
txt = Tpl.softNewLine(txt);
txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE, SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
txt = lm_46(txt, i_astDefs);
txt = Tpl.popIter(txt);
txt = Tpl.softNewLine(txt);
txt = Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
txt = Tpl.popBlock(txt);
txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE, SOME(Tpl.ST_STRING_LIST({
"\n",
"\n"
Expand Down
8 changes: 4 additions & 4 deletions Compiler/TplMain.mo
Expand Up @@ -394,10 +394,10 @@ public function MuchFun
input list<String> jokes;

output Tpl.Text out_txt;
protected
Tpl.Text txt;
Integer laughLevel;
list<String> jokes;
protected
Tpl.Text txt;
Integer laughLevel;
list<String> jokes;
algorithm
out_txt := Tpl.writeStr(txt, \"Susan\");
out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE(\"Susan is cosmic!\\n\"));
Expand Down

0 comments on commit d6a8386

Please sign in to comment.