Skip to content
Closed
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
10 changes: 10 additions & 0 deletions src/tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ the characters `U+0022` (double-quote) (except when followed by at least as
many `U+0023` (`#`) characters as were used to start the raw string literal) or
`U+005C` (`\`) do not have any special meaning.

**Note that this is a _context-sensitive_ grammar, as opposed to _context-free_.**
This is because strings like `r###"I contain only 2 "##s so I'm ok"###` require
a parser to properly count the number of opening #'s and compare that count to two
different values. In practical terms this is very easy for a parser to do, but
a context-free language can't because the only way to express "counting" is
as a destructive operation which forces you to forget the count. This allows
for the "comparison" of two counts (such (as (balanced) (parens))) but not 3+.

See [the proof for more formal details](https://github.com/rust-lang/rust/blob/5187be620c76a313a19b9b596e1bce3a80a345dd/src/grammar/raw-string-literal-ambiguity.md).

Examples for string literals:

```rust
Expand Down