From b80e1700067f0c9b6a636f6b1a339c6088bfac6e Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 12 Oct 2021 03:57:46 +0200 Subject: [PATCH] various small changes --- .../edu/kit/typicalc/model/Conclusion.java | 6 +++ .../java/edu/kit/typicalc/model/Tree.java | 4 +- .../model/parser/TypeAssumptionParser.java | 40 +++++++++++-------- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/model/Conclusion.java b/src/main/java/edu/kit/typicalc/model/Conclusion.java index ecdf9f2..b364367 100644 --- a/src/main/java/edu/kit/typicalc/model/Conclusion.java +++ b/src/main/java/edu/kit/typicalc/model/Conclusion.java @@ -32,6 +32,8 @@ public class Conclusion { } /** + * Returns the type assumptions used in the conclusion. + * * @return the type assumptions used in the conclusion */ public Map getTypeAssumptions() { @@ -39,6 +41,8 @@ public class Conclusion { } /** + * Returns the lambda term in the conclusion. + * * @return the lambda term in the conclusion */ public LambdaTerm getLambdaTerm() { @@ -46,6 +50,8 @@ public class Conclusion { } /** + * Returns the type assigned to the lambda term in the conclusion. + * * @return the type assigned to the lambda term in the conclusion */ public Type getType() { diff --git a/src/main/java/edu/kit/typicalc/model/Tree.java b/src/main/java/edu/kit/typicalc/model/Tree.java index 0156291..d69ce1c 100644 --- a/src/main/java/edu/kit/typicalc/model/Tree.java +++ b/src/main/java/edu/kit/typicalc/model/Tree.java @@ -100,7 +100,7 @@ public class Tree implements TermVisitorTree { } /** - * Indicates whether the tree contains a sub-inference of a let step that failed + * Indicates whether the tree contains a sub-inference of a let step that failed. * * @return true, if the tree contains a failed sub-inference, false otherwise */ @@ -165,7 +165,7 @@ public class Tree implements TermVisitorTree { Type premiseType = typeVarFactory.nextTypeVariable(); Constraint newConstraint = new Constraint(conclusionType, premiseType); - newConstraint.setStepIndex(stepNr); // TODO: also set on other let constraints? + newConstraint.setStepIndex(stepNr); InferenceStep premise; if (typeInfererLet.getType().isPresent()) { diff --git a/src/main/java/edu/kit/typicalc/model/parser/TypeAssumptionParser.java b/src/main/java/edu/kit/typicalc/model/parser/TypeAssumptionParser.java index 650f906..1a91c7a 100644 --- a/src/main/java/edu/kit/typicalc/model/parser/TypeAssumptionParser.java +++ b/src/main/java/edu/kit/typicalc/model/parser/TypeAssumptionParser.java @@ -52,6 +52,11 @@ public class TypeAssumptionParser { } } + /** + * Starts the process of parsing the given type assumptions. + * @param assumptions type assumptions as a string + * @return if successful, a map of the type assumptions, otherwise an error + */ public Result, ParseError> parse(String assumptions) { lexer = new LambdaLexer( cleanAssumptionText(assumptions), ParseError.ErrorSource.TYPE_ASSUMPTION_ERROR); @@ -59,10 +64,10 @@ public class TypeAssumptionParser { } /** - * parses Type Environment + * Parses a TypeEnvironment. * @return if successful, a map of the type assumptions, otherwise an error */ - public Result, ParseError> parseTE() { + private Result, ParseError> parseTE() { HashMap map = new HashMap<>(); while (true) { Result nextLexerToken = lexer.nextToken(); @@ -93,10 +98,11 @@ public class TypeAssumptionParser { } /** - * Parses single Type Assumption - * @return if successful, a type assumption, otherwise an error + * Parses a TypeAbstraction. + * @return if successful, a map entry consisting of a VarTerm and its corresponding TypeAbstraction, + * otherwise an error */ - public Result, ParseError> parseTA() { + private Result, ParseError> parseTA() { VarTerm term; if (currentToken.getType() == Token.TokenType.VARIABLE) { term = new VarTerm(currentToken.getText()); @@ -125,10 +131,10 @@ public class TypeAssumptionParser { /** - * Parses a Type - * @return if successful a type abstraction, otherwise an error. + * Parses a Type. + * @return if successful a TypeAbstraction, otherwise an error */ - public Result parseType() { + private Result parseType() { Result nextLexerToken = lexer.nextToken(); if (nextLexerToken.isError()) { return nextLexerToken.castError(); @@ -206,10 +212,10 @@ public class TypeAssumptionParser { } /** - * parses a single Type - * @return if successful a type, otherwise an error + * Parses a SingleType. + * @return if successful a Type, otherwise an error */ - public Result parseSingleType() { + private Result parseSingleType() { Result result = parseSimpleType(); if (result.isError()) { @@ -236,10 +242,10 @@ public class TypeAssumptionParser { } /** - * parses a simple type - * @return if successful a type, otherwise an error + * Parses a SimpleType. + * @return if successful a Type, otherwise an error */ - public Result parseSimpleType() { + private Result parseSimpleType() { if (currentToken.getType() == Token.TokenType.VARIABLE) { Type type = parseLiteral(currentToken.getText()); return new Result<>(type); @@ -268,10 +274,10 @@ public class TypeAssumptionParser { } /** - * parses the rest of a single type - * @return if successful a type or an empty optional, otherwise an error + * Parses a Rest. + * @return if successful a Type or an empty Optional, otherwise an error */ - public Result, ParseError> parseRest() { + private Result, ParseError> parseRest() { switch (currentToken.getType()) { case ARROW: Result nextLexerToken = lexer.nextToken();