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

Added grammar of comments #85

Merged
merged 5 commits into from
Aug 14, 2017

Conversation

brauliobz
Copy link
Contributor

@brauliobz brauliobz commented Jul 20, 2017

Issue #84

@brauliobz brauliobz force-pushed the grammar_pull_request branch from dfb4236 to 586e630 Compare July 21, 2017 01:20
src/comments.md Outdated
@@ -1,5 +1,24 @@
# Comments

> **<sup>Lexer</sup>**
> LINE_COMMENT :
> &nbsp;&nbsp; `//` ~[\n\r]*
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A line comment can include bare CRs unless it isn't a doc-comment.

src/comments.md Outdated
> &nbsp;&nbsp; `/*` (BLOCK_COMMENT | .)* `*/`
>
> OUTER_DOC_LINE_COMMENT :
> &nbsp;&nbsp; `//!` ~[\n\r]*
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one of LF/CRLF/EOF can end outer/inner doc line comments and bare CR isn't allowed here. For example, "//! foo \r//! bar\n" will lead to a syntax error. The difficulty here would be to express the fact that //! foo \r//! bar\n isn't a non-doc comment neither.

src/comments.md Outdated
> &nbsp;&nbsp; `/*!` (OUTER_DOC_BLOCK_COMMENT | .)* `*/`
>
> INNER_DOC_LINE_COMMENT :
> &nbsp;&nbsp; `///` ~[\n\r]*
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an exception: comments starting with //// is a non-doc line comment.

src/comments.md Outdated
> &nbsp;&nbsp; `//!` ~[\n\r]*
>
> OUTER_DOC_BLOCK_COMMENT :
> &nbsp;&nbsp; `/*!` (OUTER_DOC_BLOCK_COMMENT | .)* `*/`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In outer/inner doc block comments, any kinds of block comments /* */ /** */ /*! */ can be nested.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In outer/inner doc comments, bare CR isn't allowed. CRLF is allowed instead.

@brauliobz
Copy link
Contributor Author

@qnighy Thank you for your comments 👍

I changed the comments' grammar to account for the special cases (and put a lot of examples to make these clear).

I'll try to tackle the CR / CRLF problem tomorrow.

@brauliobz brauliobz changed the title Added grammar of comments Added grammar of comments (and attributes and crates and identifiers...) Jul 21, 2017
@brauliobz brauliobz force-pushed the grammar_pull_request branch from 9f094be to c623f98 Compare July 22, 2017 12:06
@brauliobz brauliobz changed the title Added grammar of comments (and attributes and crates and identifiers...) Added grammar of comments Jul 22, 2017
@Havvy
Copy link
Contributor

Havvy commented Aug 7, 2017

@brauliobz What's the status here?

@brauliobz
Copy link
Contributor Author

@Havvy I got involved with other parts of the grammar and forgot about this one :/ . The remaining problem here is the CR/LF details. I'm doing it now.

@brauliobz
Copy link
Contributor Author

Rendered here.

@steveklabnik steveklabnik merged commit 6d29d00 into rust-lang:master Aug 14, 2017
@steveklabnik
Copy link
Member

LGTM, thanks!

@brauliobz brauliobz deleted the grammar_pull_request branch August 15, 2017 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants