Closed SteelPhase closed 4 years ago
Could you link to official go documentation on valid numeric literal syntax?
Allowing _
isn't quite is straightforward as it sounds since there are many cases that are unclear 1__0
, 1_0_1
, 1_
, 1_e10
, 1_e__10
, 1__0e10_
, etc. Trial-and-error is not a very quick way to figure out exactly what is valid/invalid but I'm unaware of the official specification of Go's numeric literals
I did however reformat this repo today to make the change easy to implement
I linked to integer, and floating point literals in my message above. They are both located here https://golang.org/ref/spec
For numbers there are test cases here https://github.com/golang/go/blob/master/src/go/scanner/scanner_test.go#L916
I linked to integer, and floating point literals in my message above. They are both located here https://golang.org/ref/spec
>.< my bad I completely read over the links, thanks! That'll make it a lot easier to implement
@jeff-hykin Is it possible to reuse some of the numeric handling in cpp-textmate-grammar/source/shared_patterns
?
I am not familiar with ruby/gem at all and don't know how to importtextmate_grammar
the cpp-textmate-grammar uses. Is there a pointer to the instruction?
@hyangah
Is it possible to reuse some of the numeric handling?
Yes, BUT a straight copy-paste probably will cause problems because C++ numbers contain a lot of junk (C++ allows quotes '
instead of underscores as separators, allows custom units, etc). Using the cpp-textmate-grammar as a guide is generally a good idea though.
I am not familiar with ruby/gem at all don't know how to import textmate_grammar
This repo should automatically import textmate_grammar
which is an older version of the one cpp-textmate-grammar. I apologize for the broken CONTRIBUTING.md
though, since it didn't explain how to setup the ruby/gem part.
Is there a pointer to the instruction?
I pushed a commit just now that updated the CONTRIBUTING.md which should explain how to get this repo (better-go-syntax) running, and explains how this repo works
I hoped to finish a full guide on the textmate_grammar
library this summer but had to postpone it.
Also, if anyone can simply come up with regex that passes all the test cases then I can merge it into the grammar
I tried translating the spec directly to a regex https://play.golang.org/p/hbqmflTLVUu, but it should be possible to run them through a regex minifier.
This should be fixed now! Thanks @egonelbre and @hyangah
Integer, and floating point literals allow underscores, and the regex associated with them here doesn't seem to support underscores. Is there a way these could be updated to support underscores.