Skip to content

Lex nested block comments #9468

@brson

Description

@brson
Contributor

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.

Activity

erickt

erickt commented on Sep 24, 2013

@erickt
Contributor

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

brson

brson commented on Sep 25, 2013

@brson
ContributorAuthor

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

catamorphism

catamorphism commented on Sep 26, 2013

@catamorphism
Contributor

Accepted for feature-complete

ben0x539

ben0x539 commented on Sep 27, 2013

@ben0x539
Contributor

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

erickt

erickt commented on Sep 27, 2013

@erickt
Contributor

@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

madjar commented on Oct 3, 2013

@madjar
Contributor

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

brson commented on Oct 15, 2013

@brson
ContributorAuthor

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

brson commented on Oct 15, 2013

@brson
ContributorAuthor

@madjar Are you going to tackle this?

madjar

madjar commented on Oct 16, 2013

@madjar
Contributor

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

added a commit that references this issue on Oct 20, 2013
e7d89fa
added a commit that references this issue on Oct 21, 2013
7391a76
added a commit that references this issue on Oct 21, 2013
6dd6623
jibal

jibal commented on Jun 9, 2014

@jibal

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

huonw commented on Jun 9, 2014

@huonw
Contributor

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

added a commit that references this issue on Sep 21, 2022
5e0663e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-grammarArea: The grammar of RustE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @ben0x539@erickt@madjar@brson@catamorphism

      Issue actions

        Lex nested block comments · Issue #9468 · rust-lang/rust