diff options
| author | Akshay Nair <phenax5@gmail.com> | 2022-01-07 12:29:36 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2022-01-07 12:29:36 +0530 |
| commit | 20480cd42bbbe1685b9470063248ed5fc1f2506b (patch) | |
| tree | edc0ffc194dc2d8a583be1492e01744c9b23ef49 /src/index.ts | |
| parent | 8ef91f03fac2bad20fb927fe2ca2782c66fdb513 (diff) | |
| download | elxr-20480cd42bbbe1685b9470063248ed5fc1f2506b.tar.gz elxr-20480cd42bbbe1685b9470063248ed5fc1f2506b.zip | |
refactor: minor changes
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/index.ts b/src/index.ts index 582f9be..95a5411 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,16 @@ import { constant, flow, identity, pipe } from 'fp-ts/function' -import { andThen, delimited, mapTo, optional, pair, symbol } from './parser' +import { + andThen, + delimited, + digit, + integer, + many1, + mapTo, + optional, + or, + 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,15 +38,12 @@ type Expr = | { tag: 'Truthy' } | { tag: 'Falsey' } -export const expressionP = symbol('fuck') +export const expressionP = or([ + symbol('fuck'), + mapTo(many1(digit), (j) => j.join('')), +]) -export const parser = pair( - pair( - optional(start), - expressionP, - ), - optional(end), -) +export const parser = pair(pair(optional(start), expressionP), optional(end)) /* |
