Skip to content

Commit

Permalink
fix parsing inexact complex without real part #340
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Mar 16, 2024
1 parent 7efa6fb commit b58b1c2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
* fix `(expt +i +i)`
* fix let with duplicated variables [#335](https://github.com/jcubic/lips/issues/335)
* fix escape ellipsis in syntax-rules [#334](https://github.com/jcubic/lips/issues/334)
* fix parsing inexact complex without real part [#340](https://github.com/jcubic/lips/issues/340)

## 1.0.0-beta.18
### Breaking
Expand Down
12 changes: 7 additions & 5 deletions dist/lips.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions dist/lips.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/lips.esm.min.js

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions dist/lips.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/lips.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function gen_integer_re(mnemonic, range) {
var re_re = /^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/;
var float_stre = '(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)';
// TODO: extend to ([+-]1/2|float)([+-]1/2|float)
var complex_float_stre = `(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|${float_stre}|[+-]?[0-9]+))?(?:${float_stre}|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i`;
var complex_float_stre = `(?:#[ie])?(?:[+-]?(?:[0-9][0-9_]*/[0-9][0-9_]*|nan.0|inf.0|${float_stre}|[+-]?[0-9]+))?(?:${float_stre}|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i`;
var float_re = new RegExp(`^(#[ie])?${float_stre}$`, 'i');
function make_complex_match_re(mnemonic, range) {
// complex need special treatment of 10e+1i when it's hex or decimal
Expand Down Expand Up @@ -404,6 +404,8 @@ function parse_complex(arg, radix = 10) {
im = parse_num(parts[2]);
if (parts[1]) {
re = parse_num(parts[1]);
} else if (im instanceof LFloat) {
re = LFloat(0);
} else {
re = LNumber(0);
}
Expand Down

0 comments on commit b58b1c2

Please sign in to comment.