diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/eval.ts | 8 | ||||
| -rw-r--r-- | src/parser.ts | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/eval.ts b/src/eval.ts index 91514b9..0be3de5 100644 --- a/src/eval.ts +++ b/src/eval.ts @@ -322,6 +322,14 @@ const getFunctions = ( return EvalValue.String(dequotify(str || '')) }, + try: async () => { + try { + return await evalExpr(args[0], actions) + } catch (e) { + return evalExpr(args[1], actions) + } + }, + _: () => Promise.reject(new Error(`Not implemented: ${name}`)), }) } diff --git a/src/parser.ts b/src/parser.ts index eeb9acf..216c1bc 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -142,7 +142,7 @@ export const parseDeclarations = (input: string) => ) export const parse = (input: string): Array<Expr> => { - const res = P.many1(exprParser)(input.trim()) + const res = P.sepBy(exprParser, P.or([comma, whitespace]))(input.trim()) return match(res, { Ok: ({ value, input }) => { if (input) { |
