lpil / glance

👁️‍🗨️ A Gleam source code parser, in Gleam!
Apache License 2.0
46 stars 11 forks source link

IS `bit_string` the wrong token for nested bits? #22

Closed dusty-phillips closed 1 month ago

dusty-phillips commented 2 months ago

I'm looking here:

https://github.com/lpil/glance/blob/main/src/glance.gleam#L1110

This doesn't seem to be valid gleam. I think it's supposed to be bits?

This parses successfully with glance, but it is an error when parsed with the gleam compiler.

  let x = <<<<32:16>>:bit_string, <<32>>:bit_string>>

Conversely, this parses correctly with the gleam compiler, but is a UnexpectedToken error in glance:

  let x = <<<<32:16>>:bits, <<32>>:bits>>
dusty-phillips commented 2 months ago

I suspect "binary" is supposed to be "bytes" as well.

lpil commented 2 months ago

Glance is permissive and supports more syntaxes than the compiler parser. These specifically enable the parsing of some older versions of Gleam.

dusty-phillips commented 2 months ago

@lpil that makes sense, but I think it's not parsing the current compiler syntax.

I'm obviously not clear on the history, but if glance is supposed to be more permissive than the compiler, I think it should accept :bits, since the compiler parser does so?

lpil commented 2 months ago

It should! Yes