Handle empty lambda term in parser

This commit is contained in:
Arne Keller 2021-01-29 08:12:45 +01:00
parent b403d62d1d
commit 878130ebba
4 changed files with 13 additions and 1 deletions

View File

@ -184,7 +184,7 @@
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>

View File

@ -88,6 +88,8 @@ public class LambdaParser {
case LET:
Result<LetTerm, ParseError> let = parseLet();
return new Result<>(let.unwrap(), let.getError());
case EOF:
return new Result<>(null, ParseError.TOO_FEW_TOKENS);
default:
return parseApplication();
}

View File

@ -12,6 +12,11 @@ public enum ParseError {
*/
TOO_MANY_TOKENS,
/**
* some tokens were required, but not provided
*/
TOO_FEW_TOKENS,
/**
* the string contained a character not allowed in that context
*/

View File

@ -77,4 +77,9 @@ class LambdaParserTest {
new BooleanTerm(true)
));
}
@Test
void miscellaneousTerms() {
LambdaParser parser = new LambdaParser("");
assertEquals(parser.parse().unwrapError(), ParseError.TOO_FEW_TOKENS);
}
}