squiggle/packages/squiggle-lang/src/rescript/ReducerProject/ReducerProject_ParseIncludes.res

16 lines
540 B
Plaintext
Raw Normal View History

@module("./ReducerProject_IncludeParser.js") external parse__: string => array<string> = "parse"
2022-08-23 09:47:24 +00:00
let parseIncludes = (expr: string): result<array<string>, Reducer_ErrorValue.errorValue> =>
try {
2022-08-23 09:47:24 +00:00
let answer = parse__(expr)
// let logEntry = answer->Js.Array2.joinWith(",")
// `parseIncludes: ${logEntry} for expr: ${expr}`->Js.log
answer->Ok
} catch {
2022-08-23 09:47:24 +00:00
| Js.Exn.Error(obj) =>
RESyntaxError(
Belt.Option.getExn(Js.Exn.message(obj)),
Reducer_Peggy_Parse.syntaxErrorToLocation(obj)->Some,
)->Error
}