diff --git a/pom.xml b/pom.xml index a59e510..65684a2 100644 --- a/pom.xml +++ b/pom.xml @@ -184,7 +184,7 @@ checkstyle - validate + test check 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 8672467..b0642d9 100644 --- a/src/main/java/edu/kit/typicalc/model/parser/LambdaParser.java +++ b/src/main/java/edu/kit/typicalc/model/parser/LambdaParser.java @@ -88,6 +88,8 @@ public class LambdaParser { case LET: Result let = parseLet(); return new Result<>(let.unwrap(), let.getError()); + case EOF: + return new Result<>(null, ParseError.TOO_FEW_TOKENS); default: return parseApplication(); } diff --git a/src/main/java/edu/kit/typicalc/model/parser/ParseError.java b/src/main/java/edu/kit/typicalc/model/parser/ParseError.java index 4b11451..dc0f6bb 100644 --- a/src/main/java/edu/kit/typicalc/model/parser/ParseError.java +++ b/src/main/java/edu/kit/typicalc/model/parser/ParseError.java @@ -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 */ 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 dd61151..d920d02 100644 --- a/src/test/java/edu/kit/typicalc/model/parser/LambdaParserTest.java +++ b/src/test/java/edu/kit/typicalc/model/parser/LambdaParserTest.java @@ -77,4 +77,9 @@ class LambdaParserTest { new BooleanTerm(true) )); } + @Test + void miscellaneousTerms() { + LambdaParser parser = new LambdaParser(""); + assertEquals(parser.parse().unwrapError(), ParseError.TOO_FEW_TOKENS); + } }