diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS_Reducer_ErrorValue.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Reducer_ErrorValue.res index 8b137891..32541a06 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS_Reducer_ErrorValue.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS_Reducer_ErrorValue.res @@ -1 +1,11 @@ +open ForTS__Types +@genType +let toString = (e: reducerErrorValue): string => Reducer_ErrorValue.errorToString(e) + +@genType +let getLocation = (e: reducerErrorValue): option => + switch e { + | RESyntaxError(_, optionalLocation) => optionalLocation + | _ => None + } diff --git a/packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res b/packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res index 1914e740..c382576d 100644 --- a/packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res +++ b/packages/squiggle-lang/src/rescript/ForTS/ForTS__Types.res @@ -1,4 +1,6 @@ @genType.opaque type result_<'a, 'e> = result<'a, 'e> +@genType.opaque type reducerErrorValue = Reducer_ErrorValue.errorValue +@genType type syntaxErrorLocation = Reducer_ErrorValue.syntaxErrorLocation /* The reason this is not ExpressionValue is that ExpressionValue is becoming a parametric type @@ -13,7 +15,6 @@ type squiggleValue_Declaration = ReducerInterface_InternalExpressionValue.lambda @genType.opaque type squiggleValue_Lambda = ReducerInterface_InternalExpressionValue.lambdaValue @genType.opaque type squiggleValue_Record = ReducerInterface_InternalExpressionValue.map @genType.opaque type squiggleValue_Type = ReducerInterface_InternalExpressionValue.map -@genType.opaque type reducerErrorValue = Reducer_ErrorValue.errorValue @genType.opaque type reducerProject = ReducerProject_T.t diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res index de1dd93f..3ff122ca 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res @@ -1,6 +1,6 @@ -//FIXME: Move this under ForTS +//TODO: Do not export here but in ForTS__Types @gentype.import("peggy") @genType.as("LocationRange") -type location +type syntaxErrorLocation type errorValue = | REArityError(option, int, int) @@ -17,7 +17,7 @@ type errorValue = | REOperationError(Operation.operationError) | RERecordPropertyNotFound(string, string) | RESymbolNotFound(string) - | RESyntaxError(string, option) + | RESyntaxError(string, option) | RETodo(string) // To do | REUnitNotFound(string) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res index 59002761..8ecff48c 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_Parse.res @@ -5,10 +5,10 @@ type node = {"type": string} @module("./Reducer_Peggy_GeneratedParser.js") external parse__: string => node = "parse" -type withLocation = {"location": Reducer_ErrorValue.location} +type withLocation = {"location": Reducer_ErrorValue.syntaxErrorLocation} external castWithLocation: Js.Exn.t => withLocation = "%identity" -let syntaxErrorToLocation = (error: Js.Exn.t): Reducer_ErrorValue.location => +let syntaxErrorToLocation = (error: Js.Exn.t): Reducer_ErrorValue.syntaxErrorLocation => castWithLocation(error)["location"] let parse = (expr: string): result =>