perlang-org / perlang

The Perlang Programming Language
https://perlang.org
MIT License
16 stars 1 forks source link

Detect invalid numbers in the REPL #137

Closed perlun closed 3 years ago

perlun commented 3 years ago

These currently produce no error, but at the same time they are not parsed correctly. We should have more predictable semantics for cases like this. As usual, check how Lox does it and try do the same for starters, until we've figured out something better.

$ perlang
Perlang Interactive REPL Console (0.1.0-dev.113, built from 2e264b7)
> 0b42
> 0x42
> 0x0x010
perlun commented 3 years ago

For reference, the same is actually the case if you enter a random URL in the REPL as well. Try this: https://github.com/theme-next/hexo-theme-next/issues/448#issuecomment-431677117

The colon seems to make it behave this odd. Try foo: and it behaves just the same. We could consider killing both of these birds with one stone.

perlun commented 3 years ago

This had the same root cause as #161. With that fix in place, all of these cases are now properly handled. Closing the issue as fixed. :rocket:

Perlang Interactive REPL Console (0.1.0-dev.134, built from 22781ce)
> 0b42
[line 1] Error at 'b42': Expect ';' after expression.
> 0x42
[line 1] Error at 'x42': Expect ';' after expression.
> 0x0x010
[line 1] Error at 'x0x010': Expect ';' after expression.
> https://github.com/theme-next/hexo-theme-next/issues/448#issuecomment-431677117
[line 1] Error at ':': Expect ';' after expression.