textmate / yaml.tmbundle

TextMate support for YAML
17 stars 17 forks source link

Fix highlighting of base 10 numbers #35

Open asottile opened 4 years ago

asottile commented 4 years ago

This was incorrectly highlighting the following:

ref: 3.8.3  # should be a string, highlighted as a number
asottile commented 4 years ago

@infininight this patch is small and subtle, would you be able to review?

geekley commented 2 years ago

Weirdly the dot in the regex is ... official? https://yaml.org/type/float.html

[-+]?([0-9][0-9_]*)?\.[0-9.]*([eE][-+][0-9]+)? (base 10)

This allows even weird things like 1.....1 Don't ask me why.

asottile commented 2 years ago

I suspect it's a mistake in the spec there -- it's not implemented that way in libyaml

geekley commented 2 years ago

In fact, it's highly questionable, since one of the examples doesn't even match the regex (and has a typo):

exponentioal: 685.230_15e+03
geekley commented 2 years ago

I don't know whether those "type" pages should be "official" or not ... they're "drafts" and from a previous version of the spec. The 1.2.2 spec has a different regex in the recommended Core Schema [-+]? ( \. [0-9]+ | [0-9]+ ( \. [0-9]* )? ) ( [eE] [-+]? [0-9]+ )? This all is too confusing. Same with what counts as a boolean. I don't know much about YAML, but I already know I don't like it :laughing:

geekley commented 2 years ago

Oh. I suspect the repeatable . was supposed to be a repeatable _. This makes sense based on that example, which would match in this case. I'll try reporting this on yaml spec repo.