diff options
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)) /* |
