Add negative lookahead to the grammar

This adds the `!` prefix which represents negative lookahead. This was
included in the original PEG paper, though it was called "NOT", whereas
I went with a more explicit "NegativeLookahead".

This will be helpful in several productions which need to have these
kinds of exclusions.

The syntax is also commonly used in regular expression engines which
usually use `(?!expr)`. This is also common in many other PEG libraries.

There is a small risk this could be confusing, since `!` is sometimes
used for other purposes in other contexts. For example, Prolog uses `!`
for their cut operator. I think this should be fine since it is common
with PEG.
6 files changed
tree: 665d08de9a9bd5e27f05f1f2756508c11f9bea4b
  1. .cargo/
  2. .github/
  3. dev-guide/
  4. docs/
  5. src/
  6. theme/
  7. tools/
  8. .gitattributes
  9. .gitignore
  10. book.toml
  11. Cargo.lock
  12. Cargo.toml
  13. CONTRIBUTING.md
  14. LICENSE-APACHE
  15. LICENSE-MIT
  16. README.md
  17. reference.md
  18. rust-toolchain.toml
  19. rustfmt.toml
  20. triagebot.toml
README.md

The Rust Language Reference

This document is the primary reference for the Rust programming language.

Contributor docs

See the Reference Developer Guide for information on contributing to the Reference.