From 02c06b638e82b422fc036209dbed1b0537d07d34 Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Thu, 9 Jun 2022 14:57:25 +0200 Subject: [PATCH] module access to expression --- .../Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res | 4 ++++ .../Reducer_Expression_ExpressionBuilder.res | 2 ++ .../Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression.res | 2 ++ 3 files changed, 8 insertions(+) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res index baa9a5f0..dbe16837 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression_test.res @@ -181,4 +181,8 @@ describe("Peggy to Expression", () => { (), ) }) + + describe("module", () => { + testToExpression("Math.pi", "{(:$_atIndex_$ :Math 'pi')}", ()) + }) }) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res index 39d49655..22afadba 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Expression/Reducer_Expression_ExpressionBuilder.res @@ -65,5 +65,7 @@ let eBindExpression = (bindingExpr: expression, expression: expression): express let eBindExpressionDefault = (expression: expression): expression => eFunction("$$_bindExpression_$$", list{expression}) +let eIdentifier = (name: string): expression => name->BExpressionValue.EvSymbol->BExpressionT.EValue + let eTypeIdentifier = (name: string): expression => name->BExpressionValue.EvTypeIdentifier->BExpressionT.EValue diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression.res index ce265b41..6e04a55d 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_ToExpression.res @@ -34,6 +34,8 @@ let rec fromNode = (node: Parse.node): expression => { nodeLetStatement["variable"]["value"], fromNode(nodeLetStatement["value"]), ) + | PgNodeModuleIdentifier(nodeModuleIdentifier) => + ExpressionBuilder.eIdentifier(nodeModuleIdentifier["value"]) | PgNodeString(nodeString) => ExpressionBuilder.eString(nodeString["value"]) | PgNodeTernary(nodeTernary) => ExpressionBuilder.eFunction(