diff options
| author | Akshay Nair <phenax5@gmail.com> | 2022-01-14 20:32:32 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2022-01-14 20:34:00 +0530 |
| commit | 920038de1945298e5a693cc11fd97a73e48b9bc8 (patch) | |
| tree | 3d15e1e2355784d04cbeefd199376434295ae770 /src | |
| parent | c2c6e8d1258158f61fba026ded1e48ffc5b36cf6 (diff) | |
| download | elxr-920038de1945298e5a693cc11fd97a73e48b9bc8.tar.gz elxr-920038de1945298e5a693cc11fd97a73e48b9bc8.zip | |
feat: removes + for number literal (causes issues with js regex syntax)
Diffstat (limited to 'src')
| -rw-r--r-- | src/parser/index.ts | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/parser/index.ts b/src/parser/index.ts index d1da542..a2276bb 100644 --- a/src/parser/index.ts +++ b/src/parser/index.ts @@ -81,12 +81,11 @@ const unsignedNum: Parser<number> = mapTo( ) const numberLiteral: Parser<Literal> = mapTo( - pair(optional(oneOf(['+', '-'])), unsignedNum), + pair(optional(matchChar('-')), unsignedNum), ([signO, n]) => pipe( signO, - Option.getOrElse(() => '+'), - sign => (sign === '-' ? -1 : 1) * n, + negative => (Option.isSome(negative) ? -1 : 1) * n, Literal.Number, ), ) |
