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

underscore in numbers #660

Open
r6m opened this issue May 1, 2018 · 9 comments
Open

underscore in numbers #660

r6m opened this issue May 1, 2018 · 9 comments

Comments

@r6m
Copy link

r6m commented May 1, 2018

ruby had this nice feature to add underscore between digits for numbers 1_000_000_000
it would be great if goby can do it too.

@r6m r6m changed the title add numbers with underscore underscore in numbers May 1, 2018
@st0012
Copy link
Member

st0012 commented May 1, 2018

@rezam90 yep I think this is a good idea, thanks!

@st0012
Copy link
Member

st0012 commented May 1, 2018

@shes50103 are you willing to try this?

@SD10
Copy link
Member

SD10 commented May 1, 2018

@st0012 Does this involve the parser or only Lexer?

Anyone looking to make this change this is a good place to start:

func (l *Lexer) readNumber() []rune {

@st0012
Copy link
Member

st0012 commented May 1, 2018

@SD10 good point, I think this can be done either in lexer or parser, not sure in which one will be simpler though

@SD10
Copy link
Member

SD10 commented May 1, 2018

Yeah, I was thinking of a lazy solution though. I think it would be better to store the original value of the token and do this work in both the Lexer and the Parser. You were right

Here is where someone would need to turn 1_000_000 -> 1000000 in the Parser

func (p *Parser) parseIntegerLiteral() ast.Expression {

@st0012
Copy link
Member

st0012 commented May 1, 2018

@SD10 it seems that you're quite familiar with the components related to this feature, want to give it a try?

@SD10
Copy link
Member

SD10 commented May 1, 2018

If no one else claims it then sure
What do you think about supporting other forms of numeric literal syntax?

1.2e-3                      # Float
0xaabb                    # (Hexadecimal) Fixnum
0b001001               # (Binary) Fixnum
0377                       # (Octal) Fixnum

@st0012
Copy link
Member

st0012 commented May 1, 2018

I think we need to support all of them, but not right now

@shes50103
Copy link
Member

ok, I can do it!

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.

4 participants