Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
MathPrettyPrinter
Commits
2a33bda9
Commit
2a33bda9
authored
Jul 05, 2018
by
Bram Kohlen
Browse files
Reimplemented indentation
parent
f52709ca
Pipeline
#60760
passed with stages
in 1 minute and 7 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/mpp/montimath/MathPrettyPrinter.java
View file @
2a33bda9
...
@@ -27,6 +27,7 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
...
@@ -27,6 +27,7 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
public
MathPrettyPrinter
()
{
public
MathPrettyPrinter
()
{
this
.
printer
=
new
IndentPrinter
();
this
.
printer
=
new
IndentPrinter
();
this
.
printer
.
setIndentLength
(
4
);
this
.
importVisited
=
false
;
this
.
importVisited
=
false
;
this
.
inMatrixEnvironment
=
false
;
this
.
inMatrixEnvironment
=
false
;
}
}
...
@@ -151,10 +152,13 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
...
@@ -151,10 +152,13 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
this
.
printScript
();
this
.
printScript
();
this
.
printSpace
();
this
.
printSpace
();
this
.
printer
.
print
(
node
.
getName
());
this
.
printer
.
print
(
node
.
getName
());
this
.
printer
.
println
();
this
.
printer
.
indent
();
}
}
@Override
@Override
public
void
endVisit
(
ASTMathScript
node
)
{
public
void
endVisit
(
ASTMathScript
node
)
{
this
.
printer
.
unindent
();
this
.
printEnd
();
this
.
printEnd
();
}
}
...
@@ -232,7 +236,6 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
...
@@ -232,7 +236,6 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
@Override
@Override
public
void
visit
(
ASTMathForLoopHead
node
)
{
public
void
visit
(
ASTMathForLoopHead
node
)
{
this
.
printer
.
println
();
this
.
printFor
();
this
.
printFor
();
this
.
printSpace
();
this
.
printSpace
();
this
.
printer
.
print
(
node
.
getName
());
this
.
printer
.
print
(
node
.
getName
());
...
@@ -241,24 +244,38 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
...
@@ -241,24 +244,38 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
this
.
printSpace
();
this
.
printSpace
();
}
}
@Override
public
void
endVisit
(
ASTMathForLoopHead
node
)
{
this
.
printer
.
println
();
this
.
printer
.
indent
();
}
@Override
@Override
public
void
endVisit
(
ASTMathForLoopExpression
node
)
{
public
void
endVisit
(
ASTMathForLoopExpression
node
)
{
this
.
printer
.
unindent
();
this
.
printEnd
();
this
.
printEnd
();
this
.
printSemicolon
();
this
.
printer
.
println
(
2
);
this
.
printer
.
println
(
2
);
}
}
@Override
@Override
public
void
visit
(
ASTMathIfExpression
node
)
{
public
void
visit
(
ASTMathIfExpression
node
)
{
this
.
printer
.
println
();
this
.
printIf
();
this
.
printIf
();
this
.
printSpace
();
this
.
printSpace
();
}
}
public
void
revisit
(
ASTMathIfExpression
node
)
{
this
.
printer
.
println
();
this
.
printer
.
indent
();
}
@Override
public
void
endVisit
(
ASTMathIfExpression
node
)
{
this
.
printer
.
unindent
();
}
@Override
@Override
public
void
endVisit
(
ASTMathIfStatement
node
)
{
public
void
endVisit
(
ASTMathIfStatement
node
)
{
this
.
printEnd
();
this
.
printEnd
();
this
.
printSemicolon
();
this
.
printer
.
println
(
2
);
this
.
printer
.
println
(
2
);
}
}
...
@@ -296,9 +313,27 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
...
@@ -296,9 +313,27 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
this
.
printSpace
();
this
.
printSpace
();
}
}
@Override
public
void
revisit
(
ASTMathElseIfExpression
node
)
{
this
.
printer
.
println
();
this
.
printer
.
indent
();
}
@Override
public
void
endVisit
(
ASTMathElseIfExpression
node
)
{
this
.
printer
.
unindent
();
}
@Override
@Override
public
void
visit
(
ASTMathElseExpression
node
)
{
public
void
visit
(
ASTMathElseExpression
node
)
{
this
.
printElse
();
this
.
printElse
();
this
.
printer
.
println
();
this
.
printer
.
indent
();
}
@Override
public
void
endVisit
(
ASTMathElseExpression
node
)
{
this
.
printer
.
unindent
();
}
}
@Override
@Override
...
...
src/main/java/de/monticore/lang/monticar/mpp/montimath/MathStructuredVisitor.java
View file @
2a33bda9
...
@@ -494,4 +494,78 @@ public interface MathStructuredVisitor extends MathVisitor {
...
@@ -494,4 +494,78 @@ public interface MathStructuredVisitor extends MathVisitor {
}
}
default
void
revisit
(
ASTMathArithmeticMatrixEELeftDivideExpression
node
)
{}
default
void
revisit
(
ASTMathArithmeticMatrixEELeftDivideExpression
node
)
{}
@Override
default
void
handle
(
ASTMathIfExpression
node
)
{
this
.
getRealThis
().
visit
(
node
);
this
.
getRealThis
().
traversePartOne
(
node
);
this
.
getRealThis
().
revisit
(
node
);
this
.
getRealThis
().
traversePartTwo
(
node
);
this
.
getRealThis
().
endVisit
(
node
);
}
default
void
traversePartOne
(
ASTMathIfExpression
node
)
{
if
(
null
!=
node
.
getCondition
())
{
node
.
getCondition
().
accept
(
this
.
getRealThis
());
}
}
default
void
traversePartTwo
(
ASTMathIfExpression
node
)
{
Iterator
iter_bodys
=
node
.
getBodyList
().
iterator
();
while
(
iter_bodys
.
hasNext
())
{
((
ASTStatement
)
iter_bodys
.
next
()).
accept
(
this
.
getRealThis
());
}
}
default
void
revisit
(
ASTMathIfExpression
node
)
{
}
@Override
default
void
handle
(
ASTMathElseIfExpression
node
)
{
this
.
getRealThis
().
visit
(
node
);
this
.
getRealThis
().
traversePartOne
(
node
);
this
.
getRealThis
().
revisit
(
node
);
this
.
getRealThis
().
traversePartTwo
(
node
);
this
.
getRealThis
().
endVisit
(
node
);
}
default
void
traversePartOne
(
ASTMathElseIfExpression
node
)
{
if
(
null
!=
node
.
getCondition
())
{
node
.
getCondition
().
accept
(
this
.
getRealThis
());
}
}
default
void
traversePartTwo
(
ASTMathElseIfExpression
node
)
{
Iterator
iter_bodys
=
node
.
getBodyList
().
iterator
();
while
(
iter_bodys
.
hasNext
())
{
((
ASTStatement
)
iter_bodys
.
next
()).
accept
(
this
.
getRealThis
());
}
}
default
void
revisit
(
ASTMathElseIfExpression
node
)
{
}
/*@Override
default void handle(ASTMathElseExpression node) {
this.getRealThis().visit(node);
this.getRealThis().traversePartOne(node);
this.getRealThis().revisit(node);
this.getRealThis().traversePartTwo(node);
this.getRealThis().endVisit(node);
}
default void traverse(ASTMathElseExpression node) {
Iterator iter_bodys = node.getBodyList().iterator();
while(iter_bodys.hasNext()) {
((ASTStatement)iter_bodys.next()).accept(this.getRealThis());
}
}*/
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment