aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2022-01-06 23:41:32 +0530
committerAkshay Nair <phenax5@gmail.com>2022-01-06 23:41:32 +0530
commit8ef91f03fac2bad20fb927fe2ca2782c66fdb513 (patch)
tree6214acb7d0cf940a4b4ac64fbca3c12294de71e8 /src/index.ts
parent3d88de49d99d86c70204d6870296b20177c2af21 (diff)
downloadelxr-8ef91f03fac2bad20fb927fe2ca2782c66fdb513.tar.gz
elxr-8ef91f03fac2bad20fb927fe2ca2782c66fdb513.zip
feat: adds more parser combinators
Diffstat (limited to '')
-rw-r--r--src/index.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/index.ts b/src/index.ts
index d236473..582f9be 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,5 +1,5 @@
import { constant, flow, identity, pipe } from 'fp-ts/function'
-import { mapTo, symbol } from './parser'
+import { andThen, delimited, mapTo, optional, pair, symbol } from './parser'
export const start = mapTo(symbol('^'), constant({ tag: 'Start' } as Expr))
export const end = mapTo(symbol('$'), constant({ tag: 'End' } as Expr))
@@ -27,6 +27,16 @@ type Expr =
| { tag: 'Truthy' }
| { tag: 'Falsey' }
+export const expressionP = symbol('fuck')
+
+export const parser = pair(
+ pair(
+ optional(start),
+ expressionP,
+ ),
+ optional(end),
+)
+
/*
^ $ => start and end of list