2022-08-31 21:54:54 +00:00
|
|
|
@module("./ReducerProject_IncludeParser.js")
|
|
|
|
external parse__: string => array<array<string>> = "parse"
|
2022-07-25 14:34:33 +00:00
|
|
|
|
2022-10-05 01:17:30 +00:00
|
|
|
let parseIncludes = (expr: string): result<array<(string, string)>, SqError.t> =>
|
2022-07-25 14:34:33 +00:00
|
|
|
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
|
2022-08-31 21:54:54 +00:00
|
|
|
Belt.Array.map(answer, item => (item[0], item[1]))->Ok
|
2022-07-25 14:34:33 +00:00
|
|
|
} catch {
|
2022-08-23 09:47:24 +00:00
|
|
|
| Js.Exn.Error(obj) =>
|
2022-10-05 01:17:30 +00:00
|
|
|
RESyntaxError(Belt.Option.getExn(Js.Exn.message(obj)))
|
|
|
|
->SqError.fromMessageWithFrameStack(
|
|
|
|
Reducer_FrameStack.makeSingleFrameStack(Reducer_Peggy_Parse.syntaxErrorToLocation(obj)),
|
|
|
|
)
|
|
|
|
->Error
|
2022-07-25 14:34:33 +00:00
|
|
|
}
|