diff --git a/src/main/java/edu/kit/typicalc/model/parser/LambdaParser.java b/src/main/java/edu/kit/typicalc/model/parser/LambdaParser.java index 5bd1533..d737ed0 100644 --- a/src/main/java/edu/kit/typicalc/model/parser/LambdaParser.java +++ b/src/main/java/edu/kit/typicalc/model/parser/LambdaParser.java @@ -92,7 +92,7 @@ public class LambdaParser { } return new Result<>(null, ParseError.unexpectedToken(last, ParseError.ErrorType.TERM_ERROR) - .expectedTypes(ATOM_START_TOKENS)); + .expectedInput(ExpectedInput.TERM)); } /** diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java index 4483864..581a271 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/latexcreator/LatexCreator.java @@ -126,8 +126,8 @@ public class LatexCreator implements StepVisitor { public void visit(AbsStepWithLet absL) { tree.insert(0, generateConclusion(absL, mode == LatexCreatorMode.MATHJAX - ? "\\LeftLabel{\\class{typicalc-label typicalc-label-abs-let typicalc-step-" + absL.getStepIndex() - + "}{\\textrm A{\\small BS}}}" : LABEL_ABS, + ? "\\LeftLabel{\\class{typicalc-label typicalc-label-abs-let typicalc-step-" + + absL.getStepIndex() + "}{\\textrm A{\\small BS}}}" : LABEL_ABS, UIC)); absL.getPremise().accept(this); } diff --git a/src/test/java/edu/kit/typicalc/model/parser/LambdaParserTest.java b/src/test/java/edu/kit/typicalc/model/parser/LambdaParserTest.java index 218a056..d33bad7 100644 --- a/src/test/java/edu/kit/typicalc/model/parser/LambdaParserTest.java +++ b/src/test/java/edu/kit/typicalc/model/parser/LambdaParserTest.java @@ -21,6 +21,7 @@ class LambdaParserTest { term = parser.parse(); assertEquals(new AppTerm(new VarTerm("b1"), new VarTerm("a1")), term.unwrap()); } + @Test void absTerm() { LambdaParser parser = new LambdaParser("λx.x"); @@ -28,6 +29,7 @@ class LambdaParserTest { 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)"); @@ -39,6 +41,7 @@ class LambdaParserTest { ); assertEquals("(λx.x)(λx.x)", term.toString()); } + @Test void letTerm() { LambdaParser parser = new LambdaParser("let id = λx.x in id 1"); @@ -57,6 +60,7 @@ class LambdaParserTest { parser.parse().unwrap() ); } + @Test void complicatedTerm() { LambdaParser parser = new LambdaParser("(λx.λy.x y 5)(λz.z)(true)"); @@ -144,7 +148,7 @@ class LambdaParserTest { parser = new LambdaParser("let x = )"); error = parser.parse().unwrapError(); assertEquals(ParseError.ErrorCause.UNEXPECTED_TOKEN, error.getCauseEnum()); - assertEquals(new Token(TokenType.RIGHT_PARENTHESIS, ")", "let x = )",8), error.getCause().get()); + assertEquals(new Token(TokenType.RIGHT_PARENTHESIS, ")", "let x = )", 8), error.getCause().get()); parser = new LambdaParser("let x = y )"); error = parser.parse().unwrapError(); assertEquals(ParseError.ErrorCause.UNEXPECTED_TOKEN, error.getCauseEnum()); @@ -177,8 +181,8 @@ class LambdaParserTest { System.err.println(term.unwrapError().getCause()); } assertEquals(new AppTerm( - new AbsTerm(X, X), - new LetTerm(new VarTerm("id"), new AbsTerm(Y, Y), new VarTerm("id")) + new AbsTerm(X, X), + new LetTerm(new VarTerm("id"), new AbsTerm(Y, Y), new VarTerm("id")) ), term.unwrap()); } @@ -246,6 +250,16 @@ class LambdaParserTest { assertNotEquals(err2, err3); } + @Test + void errorCase4() { + ParseError err = getParseError("λx.x in x"); + assertEquals(ParseError + .unexpectedToken( + new Token(TokenType.IN, "in", "λx.x in x", 5), + ParseError.ErrorType.TERM_ERROR) + .expectedInput(ExpectedInput.TERM), err); + } + @Test void equality() { EqualsVerifier.forClass(Token.class).usingGetClass().verify();