From 173b249d9a91d8fee7c3cc18946e8fda188295c2 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 8 Jan 2022 17:33:10 +0530 Subject: refactor: creates constructors for expr adt --- src/types.ts | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'src/types.ts') diff --git a/src/types.ts b/src/types.ts index 21e9517..7863981 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,17 +1,23 @@ +import { constructors, Union } from "./utils" -export type Expr = - | { tag: 'Start' } - | { tag: 'End' } - | { tag: 'Optional'; expr: Expr } - | { tag: 'OneOrMore'; expr: Expr } - | { tag: 'ZeroOrMore'; expr: Expr } - | { tag: 'NextItem' } - | { tag: 'AnyItem' } - | { tag: 'Or' } - | { tag: 'AnyString' } - | { tag: 'AnyNumber' } - | { tag: 'AnyBool' } - | { tag: 'Truthy' } - | { tag: 'Falsey' } - | { tag: 'Group'; exprs: Expr[] } +type ExprT = { + Start: any, + End: any, + Optional: { expr: Expr }, + OneOrMore: { expr: Expr }, + ZeroOrMore: { expr: Expr }, + NextItem: any, + AnyItem: any, + Or: any, + AnyString: any, + AnyNumber: any, + AnyBool: any, + Truthy: any, + Falsey: any, + Group: { exprs: Expr[] }, +} + +export type Expr = Union + +export const Expr = constructors() -- cgit v1.3.1