BlockstreamResearch / simfony

Rust-like high-level language that compiles down to Simplicity bytecode. Work in progress.
26 stars 9 forks source link

Nested comments #4

Closed uncomputable closed 2 days ago

uncomputable commented 10 months ago

Block comments cannot be nested, presumably because the parser is greedy.

The following program does not compile:

/* parent
    /* child */
*/
apoelstra commented 10 months ago

The issue isn't greediness vs non-greediness, it's that to implement nested comments you need to explicitly keep track of the nesting depth. (If you just used a non-greedy parser, it'd treat everything from the start of the first comment to the end of the last comment as "commented out" :))

But agreed, this is easy to implement and a big improvement to ergonomics, so we should support it.

uncomputable commented 2 days ago

I'm closing this issue because Rust has the same issue. The above program is invalid Rust. We have line comments now, which can be "nested" in each other.

apoelstra commented 2 days ago

Rust has nested comments.

uncomputable commented 2 days ago

Either I cannot trust my IDE or I'm just tired: First I see a syntax error for nested comments. How I everything compiles.

Anyway, I'm closing nested comments as out of scope :) We can look into this again when we replace the parser.

apoelstra commented 2 days ago

Sounds good!