mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
Model und ModelImpl
This commit is contained in:
parent
143999d6e9
commit
a7bcf15c99
21
src/main/java/edu/kit/typicalc/model/Model.java
Normal file
21
src/main/java/edu/kit/typicalc/model/Model.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package edu.kit.typicalc.model;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import edu.kit.typicalc.model.parser.ParseError;
|
||||||
|
import edu.kit.typicalc.util.Result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface accepts user input and returns a type inference result.
|
||||||
|
*/
|
||||||
|
public interface Model {
|
||||||
|
/**
|
||||||
|
* Given the user input, an implementation of this method should compute the type
|
||||||
|
* inference results.
|
||||||
|
* @param lambdaTerm the lambda term to type-infer
|
||||||
|
* @param typeAssumptions the type assumptions to use
|
||||||
|
* @return either an error or a TypeInfererInterface on success
|
||||||
|
*/
|
||||||
|
Result<TypeInfererInterface, ParseError> getTypeInferer(String lambdaTerm,
|
||||||
|
Map<String, String> typeAssumptions);
|
||||||
|
}
|
39
src/main/java/edu/kit/typicalc/model/ModelImpl.java
Normal file
39
src/main/java/edu/kit/typicalc/model/ModelImpl.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package edu.kit.typicalc.model;
|
||||||
|
|
||||||
|
import edu.kit.typicalc.model.parser.LambdaParser;
|
||||||
|
import edu.kit.typicalc.model.parser.ParseError;
|
||||||
|
import edu.kit.typicalc.model.term.LambdaTerm;
|
||||||
|
import edu.kit.typicalc.util.Result;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accepts user input and returns a type inference result.
|
||||||
|
*/
|
||||||
|
public class ModelImpl implements Model {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Parses the user input given as the lambdaTerm and typeAssumptions and creates
|
||||||
|
* a TypeInferer object.
|
||||||
|
* @param lambdaTerm the lambda term to type-infer
|
||||||
|
* @param typeAssumptions the type assumptions to use
|
||||||
|
* @return A TypeInferer object that has calculated the type Inference for the given Lambda Term
|
||||||
|
* and type Assumptions
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<TypeInfererInterface, ParseError> getTypeInferer(String lambdaTerm,
|
||||||
|
Map<String, String> typeAssumptions) {
|
||||||
|
// Parse Lambda Term
|
||||||
|
LambdaParser parser = new LambdaParser(lambdaTerm);
|
||||||
|
Result<LambdaTerm, ParseError> result = parser.parse();
|
||||||
|
if (result.isError()) {
|
||||||
|
return new Result<>(null, result.unwrapError());
|
||||||
|
}
|
||||||
|
//TODO: Parse Type Assumptions and add list to typeInferer
|
||||||
|
|
||||||
|
//Create and return TypeInferer
|
||||||
|
TypeInferer typeInferer = new TypeInferer(result.unwrap(), null);
|
||||||
|
return new Result<>(typeInferer, null);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user