simplified modules

This commit is contained in:
Umur Ozkul 2022-07-18 18:16:49 +02:00
parent 06134a6524
commit c1429e0907
7 changed files with 17 additions and 11 deletions

View File

@ -3,7 +3,6 @@ module InternalExpressionValue = ReducerInterface_InternalExpressionValue
open Jest open Jest
open Reducer_Peggy_TestHelpers open Reducer_Peggy_TestHelpers
open Expect
describe("Peggy to Expression", () => { describe("Peggy to Expression", () => {
describe("literals operators parenthesis", () => { describe("literals operators parenthesis", () => {

View File

@ -1,6 +1,6 @@
module Expression = Reducer_Expression module Expression = Reducer_Expression
module InternalExpressionValue = ReducerInterface_InternalExpressionValue module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Module = Reducer_Module module Bindings = Reducer_Bindings
module T = Reducer_Type_T module T = Reducer_Type_T
module TypeCompile = Reducer_Type_Compile module TypeCompile = Reducer_Type_Compile

View File

@ -2,7 +2,7 @@ module Expression = Reducer_Expression
module ExpressionT = Reducer_Expression_T module ExpressionT = Reducer_Expression_T
module ErrorValue = Reducer_ErrorValue module ErrorValue = Reducer_ErrorValue
module InternalExpressionValue = ReducerInterface_InternalExpressionValue module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Module = Reducer_Module module Bindings = Reducer_Bindings
module T = Reducer_Type_T module T = Reducer_Type_T
module TypeChecker = Reducer_Type_TypeChecker module TypeChecker = Reducer_Type_TypeChecker
@ -16,7 +16,7 @@ let checkArgumentsSourceCode = (aTypeSourceCode: string, sourceCode: string): re
let reducerFn = Expression.reduceExpression let reducerFn = Expression.reduceExpression
let rResult = let rResult =
Reducer.parse(sourceCode)->Belt.Result.flatMap(expr => Reducer.parse(sourceCode)->Belt.Result.flatMap(expr =>
reducerFn(expr, Module.emptyBindings, InternalExpressionValue.defaultEnvironment) reducerFn(expr, Bindings.emptyBindings, InternalExpressionValue.defaultEnvironment)
) )
rResult->Belt.Result.flatMap(result => rResult->Belt.Result.flatMap(result =>
switch result { switch result {

View File

@ -2,7 +2,7 @@ module Expression = Reducer_Expression
module ExpressionT = Reducer_Expression_T module ExpressionT = Reducer_Expression_T
module ErrorValue = Reducer_ErrorValue module ErrorValue = Reducer_ErrorValue
module InternalExpressionValue = ReducerInterface_InternalExpressionValue module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Module = Reducer_Module module Bindings = Reducer_Bindings
module T = Reducer_Type_T module T = Reducer_Type_T
module TypeChecker = Reducer_Type_TypeChecker module TypeChecker = Reducer_Type_TypeChecker
@ -19,7 +19,7 @@ let isTypeOfSourceCode = (aTypeSourceCode: string, sourceCode: string): result<
let reducerFn = Expression.reduceExpression let reducerFn = Expression.reduceExpression
let rResult = let rResult =
Reducer.parse(sourceCode)->Belt.Result.flatMap(expr => Reducer.parse(sourceCode)->Belt.Result.flatMap(expr =>
reducerFn(expr, Module.emptyBindings, InternalExpressionValue.defaultEnvironment) reducerFn(expr, Bindings.emptyBindings, InternalExpressionValue.defaultEnvironment)
) )
rResult->Belt.Result.flatMap(result => TypeChecker.isTypeOf(aTypeSourceCode, result, reducerFn)) rResult->Belt.Result.flatMap(result => TypeChecker.isTypeOf(aTypeSourceCode, result, reducerFn))
} }

View File

@ -1,3 +1,6 @@
// Only Bindings as the global module is supported
// Other module operations such as import export will be prepreocessed jobs
module ExpressionT = Reducer_Expression_T module ExpressionT = Reducer_Expression_T
module InternalExpressionValue = ReducerInterface_InternalExpressionValue module InternalExpressionValue = ReducerInterface_InternalExpressionValue
open Reducer_ErrorValue open Reducer_ErrorValue

View File

@ -1,7 +1,7 @@
module ErrorValue = Reducer_ErrorValue module ErrorValue = Reducer_ErrorValue
module ExpressionT = Reducer_Expression_T module ExpressionT = Reducer_Expression_T
module InternalExpressionValue = ReducerInterface_InternalExpressionValue module InternalExpressionValue = ReducerInterface_InternalExpressionValue
module Module = Reducer_Module module Bindings = Reducer_Bindings
module T = Reducer_Type_T module T = Reducer_Type_T
let ievFromTypeExpression = ( let ievFromTypeExpression = (
@ -11,11 +11,15 @@ let ievFromTypeExpression = (
let sIndex = "compiled" let sIndex = "compiled"
let sourceCode = `type ${sIndex}=${typeExpressionSourceCode}` let sourceCode = `type ${sIndex}=${typeExpressionSourceCode}`
Reducer_Expression.parse(sourceCode)->Belt.Result.flatMap(expr => { Reducer_Expression.parse(sourceCode)->Belt.Result.flatMap(expr => {
let rContext = reducerFn(expr, Module.emptyBindings, InternalExpressionValue.defaultEnvironment) let rContext = reducerFn(
expr,
Bindings.emptyBindings,
InternalExpressionValue.defaultEnvironment,
)
Belt.Result.map(rContext, context => Belt.Result.map(rContext, context =>
switch context { switch context {
| IEvModule(nameSpace) => | IEvBindings(nameSpace) =>
switch Module.getType(nameSpace, sIndex) { switch Bindings.getType(nameSpace, sIndex) {
| Some(value) => value | Some(value) => value
| None => raise(Reducer_Exception.ImpossibleException("Reducer_Type_Compile-none")) | None => raise(Reducer_Exception.ImpossibleException("Reducer_Type_Compile-none"))
} }

View File

@ -84,7 +84,7 @@ let toStringWithType = aValue =>
| IEvDeclaration(_) => `Declaration::${toString(aValue)}` | IEvDeclaration(_) => `Declaration::${toString(aValue)}`
| IEvDistribution(_) => `Distribution::${toString(aValue)}` | IEvDistribution(_) => `Distribution::${toString(aValue)}`
| IEvLambda(_) => `Lambda::${toString(aValue)}` | IEvLambda(_) => `Lambda::${toString(aValue)}`
| IEvBindings(_) => `Module::${toString(aValue)}` | IEvBindings(_) => `Bindings::${toString(aValue)}`
| IEvNumber(_) => `Number::${toString(aValue)}` | IEvNumber(_) => `Number::${toString(aValue)}`
| IEvRecord(_) => `Record::${toString(aValue)}` | IEvRecord(_) => `Record::${toString(aValue)}`
| IEvString(_) => `String::${toString(aValue)}` | IEvString(_) => `String::${toString(aValue)}`