mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
Handle empty lambda term in parser
This commit is contained in:
parent
b403d62d1d
commit
878130ebba
2
pom.xml
2
pom.xml
@ -184,7 +184,7 @@
|
|||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>checkstyle</id>
|
<id>checkstyle</id>
|
||||||
<phase>validate</phase>
|
<phase>test</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>check</goal>
|
<goal>check</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
@ -88,6 +88,8 @@ public class LambdaParser {
|
|||||||
case LET:
|
case LET:
|
||||||
Result<LetTerm, ParseError> let = parseLet();
|
Result<LetTerm, ParseError> let = parseLet();
|
||||||
return new Result<>(let.unwrap(), let.getError());
|
return new Result<>(let.unwrap(), let.getError());
|
||||||
|
case EOF:
|
||||||
|
return new Result<>(null, ParseError.TOO_FEW_TOKENS);
|
||||||
default:
|
default:
|
||||||
return parseApplication();
|
return parseApplication();
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,11 @@ public enum ParseError {
|
|||||||
*/
|
*/
|
||||||
TOO_MANY_TOKENS,
|
TOO_MANY_TOKENS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* some tokens were required, but not provided
|
||||||
|
*/
|
||||||
|
TOO_FEW_TOKENS,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the string contained a character not allowed in that context
|
* the string contained a character not allowed in that context
|
||||||
*/
|
*/
|
||||||
|
@ -77,4 +77,9 @@ class LambdaParserTest {
|
|||||||
new BooleanTerm(true)
|
new BooleanTerm(true)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
void miscellaneousTerms() {
|
||||||
|
LambdaParser parser = new LambdaParser("");
|
||||||
|
assertEquals(parser.parse().unwrapError(), ParseError.TOO_FEW_TOKENS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user