-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add doc for comments * Update src/grammars/comments.md --------- Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## Comments | ||
|
||
### Non-doc comments | ||
|
||
Comments follow the general Rust style of line (`//`) and block (`/* ... */`) comment forms. | ||
Non-doc comments are interpreted as a form of whitespace. | ||
|
||
```pest | ||
/* | ||
Block comment | ||
*/ | ||
another_rule = { // line comment | ||
... // whitespace goes anywhere | ||
} | ||
``` | ||
|
||
### Doc comments | ||
|
||
Line doc comments begin with exactly three slashes `///` | ||
and `//!` is used to document the entire grammar file. | ||
|
||
```pest | ||
//! A parser for JSON file. | ||
json = { ... } | ||
/// Matches object, e.g.: `{ "foo": "bar" }` | ||
object = { ... } | ||
``` | ||
|
||
Then will get | ||
|
||
```rust | ||
/// A parser for JSON file. | ||
enum Rule { | ||
json, | ||
/// Matches object, e.g.: `{ "foo": "bar" }` | ||
object, | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters