aboutsummaryrefslogtreecommitdiff
path: root/src/types.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2022-01-08 17:33:10 +0530
committerAkshay Nair <phenax5@gmail.com>2022-01-08 17:33:10 +0530
commit173b249d9a91d8fee7c3cc18946e8fda188295c2 (patch)
tree65e1435798cc652101e9a0feefedbe3b3ccacc71 /src/types.ts
parent6639605b395ceb1355c95e06ff0e1470adc54101 (diff)
downloadelxr-173b249d9a91d8fee7c3cc18946e8fda188295c2.tar.gz
elxr-173b249d9a91d8fee7c3cc18946e8fda188295c2.zip
refactor: creates constructors for expr adt
Diffstat (limited to '')
-rw-r--r--src/types.ts36
1 files changed, 21 insertions, 15 deletions
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<ExprT>
+
+export const Expr = constructors<ExprT>()