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

Add raw string syntax to grammar file #125

Merged
merged 1 commit into from
Aug 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion docs/grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,22 @@ float_exp = ("e" | "E"), digit, {digit};
## String

```ebnf
string = "\"", { no_double_quotation_marks | string_escape }, "\"";
string = string_std | string_raw;
string_std = "\"", { no_double_quotation_marks | string_escape }, "\"";
string_escape = "\\", ("\"" | "\\" | "b" | "f" | "n" | "r" | "t" | ("u", unicode_hex));
string_raw = ("r#", string_raw, "#") | "\"", { unicode_non_greedy }, "\"";
```

> Note: Raw strings start with an `r`, followed by n `#` and a quotation mark
`"`. They may contain any characters or escapes (except the end sequence).
A raw string ends with a quotation mark (`"`), followed by n `#`.
Example:
```rust
r##"This is a "raw string". It can contain quotations or
backslashes (\)!"##
```
I don't know any sane way to write this out in EBNF, if you do, let me know.

## Char

```ebnf
Expand Down