Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex number in Scheme #2641

Closed
jcubic opened this issue Nov 17, 2020 · 5 comments · Fixed by #2648
Closed

Complex number in Scheme #2641

jcubic opened this issue Nov 17, 2020 · 5 comments · Fixed by #2648

Comments

@jcubic
Copy link
Contributor

jcubic commented Nov 17, 2020

Information:

Description
Complex number without imaginary number value is valid scheme complex number

Example
Example valid numbers that can be tested

10+i
10+.1i
10+1.i
@jcubic
Copy link
Contributor Author

jcubic commented Nov 17, 2020

I did few attempts to fix the number regex, but it was failing for other tests.

@RunDevelopment
Copy link
Member

Seems like I used an old version of the spec when making the number pattern. I'll fix it soon.

Note to me: Page 62 of this document defines the grammar for a valid number.

@RunDevelopment
Copy link
Member

@jcubic I have a question. I implemented it and now 10i, 10.10i, and 10e+10i aren't tokenized as numbers anymore. This is because I implemented the BNF grammar on page 62-63 literally (you only need to look at the <complex R> rule). They aren't valid numbers according to R7RS because they don't start with a sign (either + or -). Should I continue to follow the spec or should I relax it a little, so that the above numbers are tokenized again?

@jcubic
Copy link
Contributor Author

jcubic commented Nov 18, 2020

All examples works in Kawa but not in Gauche, Guile and Racket those are my base implementations that I'm testing against (racket is not exactly Scheme but it's compatible). The examples also work in my implementation (LIPS), except 10e+10i is parsed as 100.0, but that's a bug.

Maybe if Kawa support those, they can be marked as numbers, most of the time people will not use those type of values, because if they are not numbers they are treat as symbols so without quote '10 is marked as variable name, and they will use Kawa they would like to mark them as numbers.

@RunDevelopment
Copy link
Member

If nobody is gonna these anyway, then I'll just keep the strict grammar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants