From f61677bbc3ae32cc460014cffe4d9ae9264291c5 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 20 Aug 2023 11:29:07 +0530 Subject: feat: function declaration --- src/parser.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/parser.ts') diff --git a/src/parser.ts b/src/parser.ts index 732e32a..eeb9acf 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -108,6 +108,18 @@ const exprParser: P.Parser = P.or([ identifierExprParser, ]) +export const parseExpr = (input: string): Expr => { + return match(exprParser(input), { + Ok: ({ value, input }) => { + if (input) throw new Error(`Aaaaaa. Input left: ${input}`) + return value + }, + Err: e => { + throw e + }, + }) +} + const declarationParser = P.or([callExprParser, selectorExprParser]) const multiDeclarationParser = P.sepBy(declarationParser, whitespace) -- cgit v1.3.1