rigetti / quil-rs

Quil Parser & Program Builder
https://rigetti.github.io/quil-rs/
Apache License 2.0
18 stars 9 forks source link

The parser is not robust to whitespace #385

Closed MarquessV closed 3 days ago

MarquessV commented 1 month ago

The parser considers 4 spaces as an indentation token, which means that 8 spaces should be considered 2 indentations. The parser is "flexible" in that it allows for extra spaces after the initial 4, but that has less precedence than recognizing an additional indentation, so 4-7 spaces becomes the valid range for a single indentation. This doesn't necessarily seem incorrect to me, but it is brittle, and not really made clear to the user.

Since quil-rs serializes program to Quil using tabs for whitespace, and many editors and terminals default to rendering 8 spaces for tabs, this leads to a surprising error when attempting to roundtrip a serialized program copied from one's editor or terminal.

Ideas:

MarquessV commented 1 month ago

Capturing additional feedback from team discussion: