Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lex nested block comments #9468

Closed
brson opened this issue Sep 24, 2013 · 11 comments · Fixed by #9936
Closed

Lex nested block comments #9468

brson opened this issue Sep 24, 2013 · 11 comments · Fixed by #9936
Labels
A-grammar Area: The grammar of Rust E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Milestone

Comments

@brson
Copy link
Contributor

brson commented Sep 24, 2013

Currently we don't support nested block comments. This allows lexing to be regular, but it widely seen as an inconvenience. Modify the lexer to keep track of comment nesting.

Nominating backcompat.

@erickt
Copy link
Contributor

erickt commented Sep 24, 2013

I thought we were going to grow a macro to handle block quotes. Did that ever get implemented?

@brson
Copy link
Contributor Author

brson commented Sep 25, 2013

@erickt I don't know what you mean by block quotes.

@catamorphism
Copy link
Contributor

Accepted for feature-complete

@ben0x539
Copy link
Contributor

Don't line comments address pretty much all uses of nested block comments?

@erickt
Copy link
Contributor

erickt commented Sep 27, 2013

@brson: by block quote, I mean in the style of CPP's #ifdef 0 ... #endif to allow for nesting comments. Something like this:

comment!(
fn foo(x: int) -> int {
    comment!(
    printfln!("%?", x);
    )
    x
}
)

@madjar
Copy link
Contributor

madjar commented Oct 3, 2013

From what I've gathered from the code, there are two implementations of the comment parsing, one of which supports nested comments, so I guess #9701 should be fixed before this bug.

@brson
Copy link
Contributor Author

brson commented Oct 15, 2013

That's pretty funny that the pretty printer already supports nested comments. I don't think they necessarily have to be merged to fix this bug, though our lexing is a bit of a mess.

@brson
Copy link
Contributor Author

brson commented Oct 15, 2013

@madjar Are you going to tackle this?

@madjar
Copy link
Contributor

madjar commented Oct 16, 2013

@brson If there's no massive refactoring to do, I can try! Expect a PR soon.

madjar added a commit to madjar/rust that referenced this issue Oct 20, 2013
bors added a commit that referenced this issue Oct 21, 2013
This should close #9468.

I removed the test stating that nested comments should not be implemented.

I had a little chicken-and-egg problem because a comment of the std contains "/*", and adding support for nested comment creates a backward incompatibility in that case, so I had to use a dirty hack to get stage1 and stage2 to compile. This part should be revert when this commit lands in a snapshot.

This is my first non-typo contribution, so I'm open to any comment.
bors added a commit that referenced this issue Oct 21, 2013
This should close #9468.

I removed the test stating that nested comments should not be implemented.

I had a little chicken-and-egg problem because a comment of the std contains "/*", and adding support for nested comment creates a backward incompatibility in that case, so I had to use a dirty hack to get stage1 and stage2 to compile. This part should be revert when this commit lands in a snapshot.

This is my first non-typo contribution, so I'm open to any comment.
@bors bors closed this as completed in 1dc3d0b Oct 21, 2013
@jibal
Copy link

jibal commented Jun 9, 2014

The reference manual says "Comments in Rust code follow the general C++ style of line and block-comment forms, with no nesting of block-comment delimiters" ... right after production rules for nested comments.

@huonw
Copy link
Member

huonw commented Jun 9, 2014

@jibal looks like it was forgotten to be updated, thanks for noticing! (I opened #14767.)

djkoloski pushed a commit to djkoloski/rust that referenced this issue Sep 21, 2022
Fix FormatArgsExpn parsing of FormatSpec positions

Woops, forgot visitors don't walk themselves

Fixes rust-lang#9468

r? `@giraffate`

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-grammar Area: The grammar of Rust E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants