bind function calls
This commit is contained in:
parent
e3ef08839f
commit
7b080ff4c2
|
@ -34,17 +34,24 @@ let rec replaceSymbols = (expression: expression, bindings: ExpressionT.bindings
|
|||
): ExpressionT.bindings =>
|
||||
Belt.Map.String.set(bindings, "$parameters", ExpressionT.EParameters(parameters))
|
||||
|
||||
switch expression {
|
||||
| ExpressionT.EValue(EvSymbol(aSymbol)) => {
|
||||
let parameters = getParameters(bindings)
|
||||
let answerBindingIfNotParameter = (aSymbol, defaultExpression, parameters, bindings) =>
|
||||
switch Js.Array2.some(parameters, a => a == aSymbol) {
|
||||
| true => expression->Ok // We cannot bind the parameters with global values
|
||||
| true => defaultExpression->Ok // We cannot bind the parameters with global values
|
||||
| false =>
|
||||
switch bindings->Belt.Map.String.get(aSymbol) {
|
||||
| Some(boundExpression) => boundExpression->Ok
|
||||
| None => RESymbolNotFound(aSymbol)->Error
|
||||
}
|
||||
}
|
||||
|
||||
switch expression {
|
||||
| ExpressionT.EValue(EvSymbol(aSymbol)) => {
|
||||
let parameters = getParameters(bindings)
|
||||
answerBindingIfNotParameter(aSymbol, expression, parameters, bindings)
|
||||
}
|
||||
| ExpressionT.EValue(EvCall(aSymbol)) => {
|
||||
let parameters = getParameters(bindings)
|
||||
answerBindingIfNotParameter(aSymbol, expression, parameters, bindings)
|
||||
}
|
||||
| ExpressionT.EValue(_) => expression->Ok
|
||||
| ExpressionT.EBindings(_) => expression->Ok
|
||||
|
|
Loading…
Reference in New Issue
Block a user