mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
LambdaTerm toString
This commit is contained in:
parent
07f16ed2d0
commit
2d92294736
@ -63,6 +63,11 @@ public class AbsTerm extends LambdaTerm {
|
||||
return termVisitorTree.visit(this, assumptions, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "λ" + var + "." + body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
@ -59,6 +59,11 @@ public class AppTerm extends LambdaTerm {
|
||||
return termVisitorTree.visit(this, assumptions, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + left + ")(" + right + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
@ -74,6 +74,11 @@ public class LetTerm extends LambdaTerm {
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "let " + variable + " = " + definition + " in " + body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
@ -48,6 +48,11 @@ public class VarTerm extends LambdaTerm {
|
||||
return visitor.visit(this, assumptions, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
@ -42,7 +42,6 @@ public class MainViewImpl extends AppLayout implements MainView {
|
||||
MainViewListener presenter = new Presenter(new ModelImpl(), this);
|
||||
addToNavbar(true, new UpperBar(presenter));
|
||||
addToDrawer(new DrawerContent());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,16 +24,20 @@ class LambdaParserTest {
|
||||
@Test
|
||||
void absTerm() {
|
||||
LambdaParser parser = new LambdaParser("λx.x");
|
||||
assertEquals(new AbsTerm(new VarTerm("x"), new VarTerm("x")), parser.parse().unwrap());
|
||||
LambdaTerm term = parser.parse().unwrap();
|
||||
assertEquals(new AbsTerm(new VarTerm("x"), new VarTerm("x")), term);
|
||||
assertEquals("λx.x", term.toString());
|
||||
}
|
||||
@Test
|
||||
void appTerm() {
|
||||
LambdaParser parser = new LambdaParser("(λx.x)(λx.x)");
|
||||
LambdaTerm term = parser.parse().unwrap();
|
||||
assertEquals(
|
||||
new AppTerm(new AbsTerm(new VarTerm("x"), new VarTerm("x")),
|
||||
new AbsTerm(new VarTerm("x"), new VarTerm("x"))),
|
||||
parser.parse().unwrap()
|
||||
term
|
||||
);
|
||||
assertEquals("(λx.x)(λx.x)", term.toString());
|
||||
}
|
||||
@Test
|
||||
void letTerm() {
|
||||
|
Loading…
Reference in New Issue
Block a user