mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
Friendly error message for "λx.x in x"
This commit is contained in:
parent
35013bd819
commit
ed7ce73679
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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());
|
||||
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user