Snap for 8202755 from 947c808bf28e3c9ade3a4e469d312064faee2bcd to tm-release

Change-Id: I1b0d3bf13208e9ebaafaca06a8eebb6017f92284
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..616f116
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,53 @@
+// This file is generated by cargo2android.py --run.
+// Do not modify this file as changes will be overridden on upgrade.
+
+
+
+package {
+    default_applicable_licenses: ["external_rust_crates_pest_derive_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+//
+// large-scale-change included anything that looked like it might be a license
+// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
+//
+// Please consider removing redundant or irrelevant files from 'license_text:'.
+// See: http://go/android-license-faq
+license {
+    name: "external_rust_crates_pest_derive_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-MIT",
+    ],
+    license_text: [
+        "LICENSE-APACHE",
+        "LICENSE-MIT",
+    ],
+}
+
+rust_proc_macro {
+    name: "libpest_derive",
+    crate_name: "pest_derive",
+    cargo_env_compat: true,
+    cargo_pkg_version: "2.1.0",
+    srcs: ["src/lib.rs"],
+    edition: "2015",
+    rustlibs: [
+        "libpest",
+        "libpest_generator",
+    ],
+}
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..47dfec4
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,41 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g. crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
+[package]
+name = "pest_derive"
+version = "2.1.0"
+authors = ["Dragoș Tiselice <dragostiselice@gmail.com>"]
+description = "pest's derive macro"
+homepage = "https://pest-parser.github.io/"
+documentation = "https://docs.rs/pest"
+readme = "_README.md"
+keywords = ["pest", "parser", "peg", "grammar"]
+categories = ["parsing"]
+license = "MIT/Apache-2.0"
+repository = "https://github.com/pest-parser/pest"
+
+[lib]
+name = "pest_derive"
+proc-macro = true
+[dependencies.pest]
+version = "2.1.0"
+
+[dependencies.pest_generator]
+version = "2.1.0"
+[badges.codecov]
+repository = "pest-parser/pest"
+
+[badges.maintenance]
+status = "actively-developed"
+
+[badges.travis-ci]
+repository = "pest-parser/pest"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
new file mode 100644
index 0000000..2740871
--- /dev/null
+++ b/Cargo.toml.orig
@@ -0,0 +1,26 @@
+[package]
+name = "pest_derive"
+description = "pest's derive macro"
+version = "2.1.0"
+authors = ["Dragoș Tiselice <dragostiselice@gmail.com>"]
+homepage = "https://pest-parser.github.io/"
+repository = "https://github.com/pest-parser/pest"
+documentation = "https://docs.rs/pest"
+keywords = ["pest", "parser", "peg", "grammar"]
+categories = ["parsing"]
+license = "MIT/Apache-2.0"
+readme = "_README.md"
+
+[lib]
+name = "pest_derive"
+proc-macro = true
+
+[dependencies]
+# for tests, included transitively anyway
+pest = { path = "../pest", version = "2.1.0" }
+pest_generator = { path = "../generator", version = "2.1.0" }
+
+[badges]
+codecov = { repository = "pest-parser/pest" }
+maintenance = { status = "actively-developed" }
+travis-ci = { repository = "pest-parser/pest" }
diff --git a/LICENSE b/LICENSE
new file mode 120000
index 0000000..6b579aa
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1 @@
+LICENSE-APACHE
\ No newline at end of file
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
new file mode 100644
index 0000000..16fe87b
--- /dev/null
+++ b/LICENSE-APACHE
@@ -0,0 +1,201 @@
+                              Apache License
+                        Version 2.0, January 2004
+                     http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+   "License" shall mean the terms and conditions for use, reproduction,
+   and distribution as defined by Sections 1 through 9 of this document.
+
+   "Licensor" shall mean the copyright owner or entity authorized by
+   the copyright owner that is granting the License.
+
+   "Legal Entity" shall mean the union of the acting entity and all
+   other entities that control, are controlled by, or are under common
+   control with that entity. For the purposes of this definition,
+   "control" means (i) the power, direct or indirect, to cause the
+   direction or management of such entity, whether by contract or
+   otherwise, or (ii) ownership of fifty percent (50%) or more of the
+   outstanding shares, or (iii) beneficial ownership of such entity.
+
+   "You" (or "Your") shall mean an individual or Legal Entity
+   exercising permissions granted by this License.
+
+   "Source" form shall mean the preferred form for making modifications,
+   including but not limited to software source code, documentation
+   source, and configuration files.
+
+   "Object" form shall mean any form resulting from mechanical
+   transformation or translation of a Source form, including but
+   not limited to compiled object code, generated documentation,
+   and conversions to other media types.
+
+   "Work" shall mean the work of authorship, whether in Source or
+   Object form, made available under the License, as indicated by a
+   copyright notice that is included in or attached to the work
+   (an example is provided in the Appendix below).
+
+   "Derivative Works" shall mean any work, whether in Source or Object
+   form, that is based on (or derived from) the Work and for which the
+   editorial revisions, annotations, elaborations, or other modifications
+   represent, as a whole, an original work of authorship. For the purposes
+   of this License, Derivative Works shall not include works that remain
+   separable from, or merely link (or bind by name) to the interfaces of,
+   the Work and Derivative Works thereof.
+
+   "Contribution" shall mean any work of authorship, including
+   the original version of the Work and any modifications or additions
+   to that Work or Derivative Works thereof, that is intentionally
+   submitted to Licensor for inclusion in the Work by the copyright owner
+   or by an individual or Legal Entity authorized to submit on behalf of
+   the copyright owner. For the purposes of this definition, "submitted"
+   means any form of electronic, verbal, or written communication sent
+   to the Licensor or its representatives, including but not limited to
+   communication on electronic mailing lists, source code control systems,
+   and issue tracking systems that are managed by, or on behalf of, the
+   Licensor for the purpose of discussing and improving the Work, but
+   excluding communication that is conspicuously marked or otherwise
+   designated in writing by the copyright owner as "Not a Contribution."
+
+   "Contributor" shall mean Licensor and any individual or Legal Entity
+   on behalf of whom a Contribution has been received by Licensor and
+   subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   copyright license to reproduce, prepare Derivative Works of,
+   publicly display, publicly perform, sublicense, and distribute the
+   Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   (except as stated in this section) patent license to make, have made,
+   use, offer to sell, sell, import, and otherwise transfer the Work,
+   where such license applies only to those patent claims licensable
+   by such Contributor that are necessarily infringed by their
+   Contribution(s) alone or by combination of their Contribution(s)
+   with the Work to which such Contribution(s) was submitted. If You
+   institute patent litigation against any entity (including a
+   cross-claim or counterclaim in a lawsuit) alleging that the Work
+   or a Contribution incorporated within the Work constitutes direct
+   or contributory patent infringement, then any patent licenses
+   granted to You under this License for that Work shall terminate
+   as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+   Work or Derivative Works thereof in any medium, with or without
+   modifications, and in Source or Object form, provided that You
+   meet the following conditions:
+
+   (a) You must give any other recipients of the Work or
+       Derivative Works a copy of this License; and
+
+   (b) You must cause any modified files to carry prominent notices
+       stating that You changed the files; and
+
+   (c) You must retain, in the Source form of any Derivative Works
+       that You distribute, all copyright, patent, trademark, and
+       attribution notices from the Source form of the Work,
+       excluding those notices that do not pertain to any part of
+       the Derivative Works; and
+
+   (d) If the Work includes a "NOTICE" text file as part of its
+       distribution, then any Derivative Works that You distribute must
+       include a readable copy of the attribution notices contained
+       within such NOTICE file, excluding those notices that do not
+       pertain to any part of the Derivative Works, in at least one
+       of the following places: within a NOTICE text file distributed
+       as part of the Derivative Works; within the Source form or
+       documentation, if provided along with the Derivative Works; or,
+       within a display generated by the Derivative Works, if and
+       wherever such third-party notices normally appear. The contents
+       of the NOTICE file are for informational purposes only and
+       do not modify the License. You may add Your own attribution
+       notices within Derivative Works that You distribute, alongside
+       or as an addendum to the NOTICE text from the Work, provided
+       that such additional attribution notices cannot be construed
+       as modifying the License.
+
+   You may add Your own copyright statement to Your modifications and
+   may provide additional or different license terms and conditions
+   for use, reproduction, or distribution of Your modifications, or
+   for any such Derivative Works as a whole, provided Your use,
+   reproduction, and distribution of the Work otherwise complies with
+   the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+   any Contribution intentionally submitted for inclusion in the Work
+   by You to the Licensor shall be under the terms and conditions of
+   this License, without any additional terms or conditions.
+   Notwithstanding the above, nothing herein shall supersede or modify
+   the terms of any separate license agreement you may have executed
+   with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+   names, trademarks, service marks, or product names of the Licensor,
+   except as required for reasonable and customary use in describing the
+   origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+   agreed to in writing, Licensor provides the Work (and each
+   Contributor provides its Contributions) on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+   implied, including, without limitation, any warranties or conditions
+   of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+   PARTICULAR PURPOSE. You are solely responsible for determining the
+   appropriateness of using or redistributing the Work and assume any
+   risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+   whether in tort (including negligence), contract, or otherwise,
+   unless required by applicable law (such as deliberate and grossly
+   negligent acts) or agreed to in writing, shall any Contributor be
+   liable to You for damages, including any direct, indirect, special,
+   incidental, or consequential damages of any character arising as a
+   result of this License or out of the use or inability to use the
+   Work (including but not limited to damages for loss of goodwill,
+   work stoppage, computer failure or malfunction, or any and all
+   other commercial damages or losses), even if such Contributor
+   has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+   the Work or Derivative Works thereof, You may choose to offer,
+   and charge a fee for, acceptance of support, warranty, indemnity,
+   or other liability obligations and/or rights consistent with this
+   License. However, in accepting such obligations, You may act only
+   on Your own behalf and on Your sole responsibility, not on behalf
+   of any other Contributor, and only if You agree to indemnify,
+   defend, and hold each Contributor harmless for any liability
+   incurred by, or claims asserted against, such Contributor by reason
+   of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+   To apply the Apache License to your work, attach the following
+   boilerplate notice, with the fields enclosed by brackets "[]"
+   replaced with your own identifying information. (Don't include
+   the brackets!)  The text should be enclosed in the appropriate
+   comment syntax for the file format. We also recommend that a
+   file or class name and description of purpose be included on the
+   same "printed page" as the copyright notice for easier
+   identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+	http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644
index 0000000..31aa793
--- /dev/null
+++ b/LICENSE-MIT
@@ -0,0 +1,23 @@
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..096be95
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,20 @@
+name: "pest_derive"
+description: "pest\'s derive macro"
+third_party {
+  url {
+    type: HOMEPAGE
+    value: "https://crates.io/crates/pest_derive"
+  }
+  url {
+    type: ARCHIVE
+    value: "https://static.crates.io/crates/pest_derive/pest_derive-2.1.0.crate"
+  }
+  version: "2.1.0"
+  # Dual-licensed, using the least restrictive per go/thirdpartylicenses#same.
+  license_type: NOTICE
+  last_upgrade_date {
+    year: 2022
+    month: 1
+    day: 27
+  }
+}
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_APACHE2
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..45dc4dd
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1 @@
+include platform/prebuilts/rust:master:/OWNERS
diff --git a/_README.md b/_README.md
new file mode 100644
index 0000000..2c94a72
--- /dev/null
+++ b/_README.md
@@ -0,0 +1,167 @@
+<p align="center">
+  <img src="https://raw.github.com/pest-parser/pest/master/pest-logo.svg?sanitize=true" width="80%"/>
+</p>
+
+# pest. The Elegant Parser
+
+[![Join the chat at https://gitter.im/dragostis/pest](https://badges.gitter.im/dragostis/pest.svg)](https://gitter.im/dragostis/pest?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+[![Book](https://img.shields.io/badge/book-WIP-4d76ae.svg)](https://pest-parser.github.io/book)
+[![Docs](https://docs.rs/pest/badge.svg)](https://docs.rs/pest)
+
+[![Build Status](https://travis-ci.org/pest-parser/pest.svg?branch=master)](https://travis-ci.org/pest-parser/pest)
+[![codecov](https://codecov.io/gh/pest-parser/pest/branch/master/graph/badge.svg)](https://codecov.io/gh/pest-parser/pest)
+[![Crates.io](https://img.shields.io/crates/d/pest.svg)](https://crates.io/crates/pest)
+[![Crates.io](https://img.shields.io/crates/v/pest.svg)](https://crates.io/crates/pest)
+
+pest is a general purpose parser written in Rust with a focus on accessibility,
+correctness, and performance. It uses parsing expression grammars
+(or [PEG]) as input, which are similar in spirit to regular expressions, but
+which offer the enhanced expressivity needed to parse complex languages.
+
+[PEG]: https://en.wikipedia.org/wiki/Parsing_expression_grammar
+
+## Getting started
+
+The recommended way to start parsing with pest is to read the official [book].
+
+Other helpful resources:
+
+* API reference on [docs.rs]
+* play with grammars and share them on our [fiddle]
+* leave feedback, ask questions, or greet us on [Gitter]
+
+[book]: https://pest-parser.github.io/book
+[docs.rs]: https://docs.rs/pest
+[fiddle]: https://pest-parser.github.io/#editor
+[Gitter]: https://gitter.im/dragostis/pest
+
+## Example
+
+The following is an example of a grammar for a list of alpha-numeric identifiers
+where the first identifier does not start with a digit:
+
+```rust
+alpha = { 'a'..'z' | 'A'..'Z' }
+digit = { '0'..'9' }
+
+ident = { (alpha | digit)+ }
+
+ident_list = _{ !digit ~ ident ~ (" " ~ ident)+ }
+          // ^
+          // ident_list rule is silent which means it produces no tokens
+```
+
+Grammars are saved in separate .pest files which are never mixed with procedural
+code. This results in an always up-to-date formalization of a language that is
+easy to read and maintain.
+
+## Meaningful error reporting
+
+Based on the grammar definition, the parser also includes automatic error
+reporting. For the example above, the input `"123"` will result in:
+
+```
+thread 'main' panicked at ' --> 1:1
+  |
+1 | 123
+  | ^---
+  |
+  = unexpected digit', src/main.rs:12
+```
+while `"ab *"` will result in:
+```
+thread 'main' panicked at ' --> 1:1
+  |
+1 | ab *
+  |    ^---
+  |
+  = expected ident', src/main.rs:12
+```
+
+## Pairs API
+
+The grammar can be used to derive a `Parser` implementation automatically.
+Parsing returns an iterator of nested token pairs:
+
+```rust
+extern crate pest;
+#[macro_use]
+extern crate pest_derive;
+
+use pest::Parser;
+
+#[derive(Parser)]
+#[grammar = "ident.pest"]
+struct IdentParser;
+
+fn main() {
+    let pairs = IdentParser::parse(Rule::ident_list, "a1 b2").unwrap_or_else(|e| panic!("{}", e));
+
+    // Because ident_list is silent, the iterator will contain idents
+    for pair in pairs {
+
+        let span = pair.clone().into_span();
+        // A pair is a combination of the rule which matched and a span of input
+        println!("Rule:    {:?}", pair.as_rule());
+        println!("Span:    {:?}", span);
+        println!("Text:    {}", span.as_str());
+
+        // A pair can be converted to an iterator of the tokens which make it up:
+        for inner_pair in pair.into_inner() {
+            let inner_span = inner_pair.clone().into_span();
+            match inner_pair.as_rule() {
+                Rule::alpha => println!("Letter:  {}", inner_span.as_str()),
+                Rule::digit => println!("Digit:   {}", inner_span.as_str()),
+                _ => unreachable!()
+            };
+        }
+    }
+}
+```
+
+This produces the following output:
+```
+Rule:    ident
+Span:    Span { start: 0, end: 2 }
+Text:    a1
+Letter:  a
+Digit:   1
+Rule:    ident
+Span:    Span { start: 3, end: 5 }
+Text:    b2
+Letter:  b
+Digit:   2
+```
+
+## Other features
+
+* Precedence climbing
+* Input handling
+* Custom errors
+* Runs on stable Rust
+
+## Projects using pest
+
+* [pest_meta](https://github.com/pest-parser/pest/blob/master/meta/src/grammar.pest) (bootstrapped)
+* [brain](https://github.com/brain-lang/brain)
+* [Chelone](https://github.com/Aaronepower/chelone)
+* [comrak](https://github.com/kivikakk/comrak)
+* [graphql-parser](https://github.com/Keats/graphql-parser)
+* [handlebars-rust](https://github.com/sunng87/handlebars-rust)
+* [hexdino](https://github.com/Luz/hexdino)
+* [Huia](https://gitlab.com/jimsy/huia/)
+* [json5-rs](https://github.com/callum-oakley/json5-rs)
+* [mt940](https://github.com/svenstaro/mt940-rs)
+* [py_literal](https://github.com/jturner314/py_literal)
+* [rouler](https://github.com/jarcane/rouler)
+* [RuSh](https://github.com/lwandrebeck/RuSh)
+* [rs_pbrt](https://github.com/wahn/rs_pbrt)
+* [stache](https://github.com/dgraham/stache)
+* [tera](https://github.com/Keats/tera)
+* [ui_gen](https://github.com/emoon/ui_gen)
+* [ukhasnet-parser](https://github.com/adamgreig/ukhasnet-parser)
+
+## Special thanks
+
+A special round of applause goes to prof. Marius Minea for his guidance and all
+pest contributors, some of which being none other than my friends.
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..f60d5d9
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,302 @@
+// pest. The Elegant Parser
+// Copyright (c) 2018 Dragoș Tiselice
+//
+// Licensed under the Apache License, Version 2.0
+// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
+// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. All files in the project carrying such notice may not be copied,
+// modified, or distributed except according to those terms.
+
+//! # pest. The Elegant Parser
+//!
+//! pest is a general purpose parser written in Rust with a focus on accessibility, correctness,
+//! and performance. It uses parsing expression grammars (or [PEG]) as input, which are similar in
+//! spirit to regular expressions, but which offer the enhanced expressivity needed to parse
+//! complex languages.
+//!
+//! [PEG]: https://en.wikipedia.org/wiki/Parsing_expression_grammar
+//!
+//! ## Getting started
+//!
+//! The recommended way to start parsing with pest is to read the official [book].
+//!
+//! Other helpful resources:
+//!
+//! * API reference on [docs.rs]
+//! * play with grammars and share them on our [fiddle]
+//! * leave feedback, ask questions, or greet us on [Gitter]
+//!
+//! [book]: https://pest-parser.github.io/book
+//! [docs.rs]: https://docs.rs/pest
+//! [fiddle]: https://pest-parser.github.io/#editor
+//! [Gitter]: https://gitter.im/dragostis/pest
+//!
+//! ## `.pest` files
+//!
+//! Grammar definitions reside in custom `.pest` files located in the `src` directory. Their path is
+//! relative to `src` and is specified between the `derive` attribute and empty `struct` that
+//! `Parser` will be derived on.
+//!
+//! ```ignore
+//! #[derive(Parser)]
+//! #[grammar = "path/to/my_grammar.pest"] // relative to src
+//! struct MyParser;
+//! ```
+//!
+//! ## Inline grammars
+//!
+//! Grammars can also be inlined by using the `#[grammar_inline = "..."]` attribute.
+//!
+//! ## Grammar
+//!
+//! A grammar is a series of rules separated by whitespace, possibly containing comments.
+//!
+//! ### Comments
+//!
+//! Comments start with `//` and end at the end of the line.
+//!
+//! ```ignore
+//! // a comment
+//! ```
+//!
+//! ### Rules
+//!
+//! Rules have the following form:
+//!
+//! ```ignore
+//! name = optional_modifier { expression }
+//! ```
+//!
+//! The name of the rule is formed from alphanumeric characters or `_` with the condition that the
+//! first character is not a digit and is used to create token pairs. When the rule starts being
+//! parsed, the starting part of the token is being produced, with the ending part being produced
+//! when the rule finishes parsing.
+//!
+//! The following token pair notation `a(b(), c())` denotes the tokens: start `a`, start `b`, end
+//! `b`, start `c`, end `c`, end `a`.
+//!
+//! #### Modifiers
+//!
+//! Modifiers are optional and can be one of `_`, `@`, `$`, or `!`. These modifiers change the
+//! behavior of the rules.
+//!
+//! 1. Silent (`_`)
+//!
+//!     Silent rules do not create token pairs during parsing, nor are they error-reported.
+//!
+//!     ```ignore
+//!     a = _{ "a" }
+//!     b =  { a ~ "b" }
+//!     ```
+//!
+//!     Parsing `"ab"` produces the token pair `b()`.
+//!
+//! 2. Atomic (`@`)
+//!
+//!     Atomic rules do not accept whitespace or comments within their expressions and have a
+//!     cascading effect on any rule they call. I.e. rules that are not atomic but are called by atomic
+//!     rules behave atomically.
+//!
+//!     Any rules called by atomic rules do not generate token pairs.
+//!
+//!     ```ignore
+//!     a =  { "a" }
+//!     b = @{ a ~ "b" }
+//!
+//!     WHITESPACE = _{ " " }
+//!     ```
+//!
+//!     Parsing `"ab"` produces the token pair `b()`, while `"a   b"` produces an error.
+//!
+//! 3. Compound-atomic (`$`)
+//!
+//!     Compound-atomic are identical to atomic rules with the exception that rules called by them are
+//!     not forbidden from generating token pairs.
+//!
+//!     ```ignore
+//!     a =  { "a" }
+//!     b = ${ a ~ "b" }
+//!
+//!     WHITESPACE = _{ " " }
+//!     ```
+//!
+//!     Parsing `"ab"` produces the token pairs `b(a())`, while `"a   b"` produces an error.
+//!
+//! 4. Non-atomic (`!`)
+//!
+//!     Non-atomic are identical to normal rules with the exception that they stop the cascading effect
+//!     of atomic and compound-atomic rules.
+//!
+//!     ```ignore
+//!     a =  { "a" }
+//!     b = !{ a ~ "b" }
+//!     c = @{ b }
+//!
+//!     WHITESPACE = _{ " " }
+//!     ```
+//!
+//!     Parsing both `"ab"` and `"a   b"` produce the token pairs `c(a())`.
+//!
+//! #### Expressions
+//!
+//! Expressions can be either terminals or non-terminals.
+//!
+//! 1. Terminals
+//!
+//!     | Terminal   | Usage                                                          |
+//!     |------------|----------------------------------------------------------------|
+//!     | `"a"`      | matches the exact string `"a"`                                 |
+//!     | `^"a"`     | matches the exact string `"a"` case insensitively (ASCII only) |
+//!     | `'a'..'z'` | matches one character between `'a'` and `'z'`                  |
+//!     | `a`        | matches rule `a`                                               |
+//!
+//! Strings and characters follow
+//! [Rust's escape mechanisms](https://doc.rust-lang.org/reference/tokens.html#byte-escapes), while
+//! identifiers can contain alpha-numeric characters and underscores (`_`), as long as they do not
+//! start with a digit.
+//!
+//! 2. Non-terminals
+//!
+//!     | Non-terminal          | Usage                                                      |
+//!     |-----------------------|------------------------------------------------------------|
+//!     | `(e)`                 | matches `e`                                                |
+//!     | `e1 ~ e2`             | matches the sequence `e1` `e2`                             |
+//!     | <code>e1 \| e2</code> | matches either `e1` or `e2`                                |
+//!     | `e*`                  | matches `e` zero or more times                             |
+//!     | `e+`                  | matches `e` one or more times                              |
+//!     | `e{n}`                | matches `e` exactly `n` times                              |
+//!     | `e{, n}`              | matches `e` at most `n` times                              |
+//!     | `e{n,} `              | matches `e` at least `n` times                             |
+//!     | `e{m, n}`             | matches `e` between `m` and `n` times inclusively          |
+//!     | `e?`                  | optionally matches `e`                                     |
+//!     | `&e`                  | matches `e` without making progress                        |
+//!     | `!e`                  | matches if `e` doesn't match without making progress       |
+//!     | `PUSH(e)`             | matches `e` and pushes it's captured string down the stack |
+//!
+//!     where `e`, `e1`, and `e2` are expressions.
+//!
+//! Expressions can modify the stack only if they match the input. For example,
+//! if `e1` in the compound expression `e1 | e2` does not match the input, then
+//! it does not modify the stack, so `e2` sees the stack in the same state as
+//! `e1` did. Repetitions and optionals (`e*`, `e+`, `e{, n}`, `e{n,}`,
+//! `e{m,n}`, `e?`) can modify the stack each time `e` matches. The `!e` and `&e`
+//! expressions are a special case; they never modify the stack.
+//!
+//! ## Special rules
+//!
+//! Special rules can be called within the grammar. They are:
+//!
+//! * `WHITESPACE` - runs between rules and sub-rules
+//! * `COMMENT` - runs between rules and sub-rules
+//! * `ANY` - matches exactly one `char`
+//! * `SOI` - (start-of-input) matches only when a `Parser` is still at the starting position
+//! * `EOI` - (end-of-input) matches only when a `Parser` has reached its end
+//! * `POP` - pops a string from the stack and matches it
+//! * `POP_ALL` - pops the entire state of the stack and matches it
+//! * `PEEK` - peeks a string from the stack and matches it
+//! * `PEEK[a..b]` - peeks part of the stack and matches it
+//! * `PEEK_ALL` - peeks the entire state of the stack and matches it
+//! * `DROP` - drops the top of the stack (fails to match if the stack is empty)
+//!
+//! `WHITESPACE` and `COMMENT` should be defined manually if needed. All other rules cannot be
+//! overridden.
+//!
+//! ## `WHITESPACE` and `COMMENT`
+//!
+//! When defined, these rules get matched automatically in sequences (`~`) and repetitions
+//! (`*`, `+`) between expressions. Atomic rules and those rules called by atomic rules are exempt
+//! from this behavior.
+//!
+//! These rules should be defined so as to match one whitespace character and one comment only since
+//! they are run in repetitions.
+//!
+//! If both `WHITESPACE` and `COMMENT` are defined, this grammar:
+//!
+//! ```ignore
+//! a = { b ~ c }
+//! ```
+//!
+//! is effectively transformed into this one behind the scenes:
+//!
+//! ```ignore
+//! a = { b ~ WHITESPACE* ~ (COMMENT ~ WHITESPACE*)* ~ c }
+//! ```
+//!
+//! ## `PUSH`, `POP`, `DROP`, and `PEEK`
+//!
+//! `PUSH(e)` simply pushes the captured string of the expression `e` down a stack. This stack can
+//! then later be used to match grammar based on its content with `POP` and `PEEK`.
+//!
+//! `PEEK` always matches the string at the top of stack. So, if the stack contains `["b", "a"]`
+//! (`"a"` being on top), this grammar:
+//!
+//! ```ignore
+//! a = { PEEK }
+//! ```
+//!
+//! is effectively transformed into at parse time:
+//!
+//! ```ignore
+//! a = { "a" }
+//! ```
+//!
+//! `POP` works the same way with the exception that it pops the string off of the stack if the
+//! match worked. With the stack from above, if `POP` matches `"a"`, the stack will be mutated
+//! to `["b"]`.
+//!
+//! `DROP` makes it possible to remove the string at the top of the stack
+//! without matching it. If the stack is nonempty, `DROP` drops the top of the
+//! stack. If the stack is empty, then `DROP` fails to match.
+//!
+//! ### Advanced peeking
+//!
+//! `PEEK[start..end]` and `PEEK_ALL` allow to peek deeper into the stack. The syntax works exactly
+//! like Rust’s exclusive slice syntax. Additionally, negative indices can be used to indicate an
+//! offset from the top. If the end lies before or at the start, the expression matches (as does
+//! a `PEEK_ALL` on an empty stack). With the stack `["c", "b", "a"]` (`"a"` on top):
+//!
+//! ```ignore
+//! fill = PUSH("c") ~ PUSH("b") ~ PUSH("a")
+//! v = { PEEK_ALL } = { "a" ~ "b" ~ "c" }  // top to bottom
+//! w = { PEEK[..] } = { "c" ~ "b" ~ "a" }  // bottom to top
+//! x = { PEEK[1..2] } = { PEEK[1..-1] } = { "b" }
+//! y = { PEEK[..-2] } = { PEEK[0..1] } = { "a" }
+//! z = { PEEK[1..] } = { PEEK[-2..3] } = { "c" ~ "b" }
+//! n = { PEEK[2..-2] } = { PEEK[2..1] } = { "" }
+//! ```
+//!
+//! For historical reasons, `PEEK_ALL` matches from top to bottom, while `PEEK[start..end]` matches
+//! from bottom to top. There is currectly no syntax to match a slice of the stack top to bottom.
+//!
+//! ## `Rule`
+//!
+//! All rules defined or used in the grammar populate a generated `enum` called `Rule`. This
+//! implements `pest`'s `RuleType` and can be used throughout the API.
+//!
+//! ## `Built-in rules`
+//!
+//! Pest also comes with a number of built-in rules for convenience. They are:
+//!
+//! * `ASCII_DIGIT` - matches a numeric character from 0..9
+//! * `ASCII_NONZERO_DIGIT` - matches a numeric character from 1..9
+//! * `ASCII_BIN_DIGIT` - matches a numeric character from 0..1
+//! * `ASCII_OCT_DIGIT` - matches a numeric character from 0..7
+//! * `ASCII_HEX_DIGIT` - matches a numeric character from 0..9 or a..f or A..F
+//! * `ASCII_ALPHA_LOWER` - matches a character from a..z
+//! * `ASCII_ALPHA_UPPER` - matches a character from A..Z
+//! * `ASCII_ALPHA` - matches a character from a..z or A..Z
+//! * `ASCII_ALPHANUMERIC` - matches a character from a..z or A..Z or 0..9
+//! * `ASCII` - matches a character from \x00..\x7f
+//! * `NEWLINE` - matches either "\n" or "\r\n" or "\r"
+
+#![doc(html_root_url = "https://docs.rs/pest_derive")]
+
+extern crate pest_generator;
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_derive(Parser, attributes(grammar, grammar_inline))]
+pub fn derive_parser(input: TokenStream) -> TokenStream {
+    pest_generator::derive_parser(input.into(), true).into()
+}
diff --git a/tests/grammar.pest b/tests/grammar.pest
new file mode 100644
index 0000000..43a7b8c
--- /dev/null
+++ b/tests/grammar.pest
@@ -0,0 +1,83 @@
+// pest. The Elegant Parser
+// Copyright (c) 2018 Dragoș Tiselice
+//
+// Licensed under the Apache License, Version 2.0
+// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
+// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. All files in the project carrying such notice may not be copied,
+// modified, or distributed except according to those terms.
+
+string = { "abc" }
+insensitive = { ^"abc" }
+range = { '0'..'9' }
+ident = { string }
+pos_pred = { &string }
+neg_pred = { !string }
+double_neg_pred = { !!string }
+sequence = !{ string ~ string }
+sequence_compound = ${ string ~ string }
+sequence_atomic = @{ string ~ string }
+sequence_non_atomic = @{ sequence }
+sequence_atomic_compound = @{ sequence_compound }
+sequence_nested = { string ~ string }
+sequence_compound_nested = ${ sequence_nested }
+choice = { string | range }
+optional = { string? }
+repeat = { string* }
+repeat_atomic = @{ string* }
+repeat_once = { string+ }
+repeat_once_atomic = @{ string+ }
+repeat_min_max = { string{2, 3} }
+repeat_min_max_atomic = @{ string{2, 3} }
+repeat_exact = { string{2} }
+repeat_min = { string{2,} }
+repeat_min_atomic = @{ string{2,} }
+repeat_max = { string{, 2} }
+repeat_max_atomic = @{ string{, 2} }
+soi_at_start = { SOI ~ string }
+repeat_mutate_stack = { (PUSH('a'..'c') ~ ",")* ~ POP ~ POP ~ POP }
+peek_ = { PUSH(range) ~ PUSH(range) ~ PEEK ~ PEEK }
+peek_all = { PUSH(range) ~ PUSH(range) ~ PEEK_ALL }
+peek_slice_23 = { PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PUSH(range) ~ PEEK[1..-2] }
+pop_ = { PUSH(range) ~ PUSH(range) ~ POP ~ POP }
+pop_all = { PUSH(range) ~ PUSH(range) ~ POP_ALL }
+pop_fail = { PUSH(range) ~ !POP ~ range ~ POP }
+checkpoint_restore = ${
+		PUSH("") ~ (PUSH("a") ~ "b" ~ POP | DROP ~ "b" | POP ~ "a") ~ EOI
+}
+ascii_digits = { ASCII_DIGIT+ }
+ascii_nonzero_digits = { ASCII_NONZERO_DIGIT+ }
+ascii_bin_digits = { ASCII_BIN_DIGIT+ }
+ascii_oct_digits = { ASCII_OCT_DIGIT+ }
+ascii_hex_digits = { ASCII_HEX_DIGIT+ }
+ascii_alpha_lowers = { ASCII_ALPHA_LOWER+ }
+ascii_alpha_uppers = { ASCII_ALPHA_UPPER+ }
+ascii_alphas = { ASCII_ALPHA+ }
+ascii_alphanumerics = { ASCII_ALPHANUMERIC+ }
+asciis = { ASCII+ }
+newline = { NEWLINE+ }
+unicode = { XID_START ~ XID_CONTINUE* }
+SYMBOL = { "shadows builtin" }
+
+WHITESPACE = _{ " " }
+COMMENT = _{ "$"+ }
+
+// Line comment
+
+/* 1-line multiline comment */
+
+/*
+	N-line multiline comment
+*/
+
+/*
+	// Line comment inside multiline
+
+	/*
+		(Multiline inside) multiline
+	*/
+
+	Invalid segment of grammar below (repeated rule)
+
+	WHITESPACE = _{ "hi" }
+*/
diff --git a/tests/grammar.rs b/tests/grammar.rs
new file mode 100644
index 0000000..799beb7
--- /dev/null
+++ b/tests/grammar.rs
@@ -0,0 +1,951 @@
+// pest. The Elegant Parser
+// Copyright (c) 2018 Dragoș Tiselice
+//
+// Licensed under the Apache License, Version 2.0
+// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
+// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. All files in the project carrying such notice may not be copied,
+// modified, or distributed except according to those terms.
+
+#[macro_use]
+extern crate pest;
+#[macro_use]
+extern crate pest_derive;
+
+#[derive(Parser)]
+#[grammar = "../tests/grammar.pest"]
+struct GrammarParser;
+
+#[test]
+fn string() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::string,
+        tokens: [
+            string(0, 3)
+        ]
+    };
+}
+
+#[test]
+fn insensitive() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "aBC",
+        rule: Rule::insensitive,
+        tokens: [
+            insensitive(0, 3)
+        ]
+    };
+}
+
+#[test]
+fn range() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "6",
+        rule: Rule::range,
+        tokens: [
+            range(0, 1)
+        ]
+    };
+}
+
+#[test]
+fn ident() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::ident,
+        tokens: [
+            ident(0, 3, [
+                string(0, 3)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn pos_pred() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::pos_pred,
+        tokens: [
+            pos_pred(0, 0)
+        ]
+    };
+}
+
+#[test]
+fn neg_pred() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "",
+        rule: Rule::neg_pred,
+        tokens: [
+            neg_pred(0, 0)
+        ]
+    };
+}
+
+#[test]
+fn double_neg_pred() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::double_neg_pred,
+        tokens: [
+            double_neg_pred(0, 0)
+        ]
+    };
+}
+
+#[test]
+fn sequence() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc   abc",
+        rule: Rule::sequence,
+        tokens: [
+            sequence(0, 9, [
+                string(0, 3),
+                string(6, 9)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn sequence_compound() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabc",
+        rule: Rule::sequence_compound,
+        tokens: [
+            sequence_compound(0, 6, [
+                string(0, 3),
+                string(3, 6)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn sequence_atomic() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabc",
+        rule: Rule::sequence_atomic,
+        tokens: [
+            sequence_atomic(0, 6)
+        ]
+    };
+}
+
+#[test]
+fn sequence_non_atomic() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc   abc",
+        rule: Rule::sequence_non_atomic,
+        tokens: [
+            sequence_non_atomic(0, 9, [
+                sequence(0, 9, [
+                    string(0, 3),
+                    string(6, 9)
+                ])
+            ])
+        ]
+    };
+}
+
+#[test]
+#[should_panic]
+fn sequence_atomic_space() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::sequence_atomic,
+        tokens: []
+    };
+}
+
+#[test]
+fn sequence_atomic_compound() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabc",
+        rule: Rule::sequence_atomic_compound,
+        tokens: [
+            sequence_atomic_compound(0, 6, [
+                sequence_compound(0, 6, [
+                    string(0, 3),
+                    string(3, 6)
+                ])
+            ])
+        ]
+    };
+}
+
+#[test]
+fn sequence_compound_nested() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabc",
+        rule: Rule::sequence_compound_nested,
+        tokens: [
+            sequence_compound_nested(0, 6, [
+                sequence_nested(0, 6, [
+                    string(0, 3),
+                    string(3, 6)
+                ])
+            ])
+        ]
+    };
+}
+
+#[test]
+#[should_panic]
+fn sequence_compound_nested_space() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::sequence_compound_nested,
+        tokens: []
+    };
+}
+
+#[test]
+fn choice_string() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::choice,
+        tokens: [
+            choice(0, 3, [
+                string(0, 3)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn choice_range() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "0",
+        rule: Rule::choice,
+        tokens: [
+            choice(0, 1, [
+                range(0, 1)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn optional_string() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::optional,
+        tokens: [
+            optional(0, 3, [
+                string(0, 3)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn optional_empty() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "",
+        rule: Rule::optional,
+        tokens: [
+            optional(0, 0)
+        ]
+    };
+}
+
+#[test]
+fn repeat_empty() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "",
+        rule: Rule::repeat,
+        tokens: [
+            repeat(0, 0)
+        ]
+    };
+}
+
+#[test]
+fn repeat_strings() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc   abc",
+        rule: Rule::repeat,
+        tokens: [
+            repeat(0, 9, [
+                string(0, 3),
+                string(6, 9)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn repeat_atomic_empty() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "",
+        rule: Rule::repeat_atomic,
+        tokens: [
+            repeat_atomic(0, 0)
+        ]
+    };
+}
+
+#[test]
+fn repeat_atomic_strings() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabc",
+        rule: Rule::repeat_atomic,
+        tokens: [
+            repeat_atomic(0, 6)
+        ]
+    };
+}
+
+#[test]
+#[should_panic]
+fn repeat_atomic_space() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::repeat_atomic,
+        tokens: []
+    };
+}
+
+#[test]
+#[should_panic]
+fn repeat_once_empty() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "",
+        rule: Rule::repeat_once,
+        tokens: []
+    };
+}
+
+#[test]
+fn repeat_once_strings() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc   abc",
+        rule: Rule::repeat_once,
+        tokens: [
+            repeat_once(0, 9, [
+                string(0, 3),
+                string(6, 9)
+            ])
+        ]
+    };
+}
+
+#[test]
+#[should_panic]
+fn repeat_once_atomic_empty() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "",
+        rule: Rule::repeat_once_atomic,
+        tokens: []
+    };
+}
+
+#[test]
+fn repeat_once_atomic_strings() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabc",
+        rule: Rule::repeat_once_atomic,
+        tokens: [
+            repeat_once_atomic(0, 6)
+        ]
+    };
+}
+
+#[test]
+#[should_panic]
+fn repeat_once_atomic_space() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::repeat_once_atomic,
+        tokens: []
+    };
+}
+
+#[test]
+fn repeat_min_max_twice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::repeat_min_max,
+        tokens: [
+            repeat_min_max(0, 7, [
+                string(0, 3),
+                string(4, 7)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn repeat_min_max_thrice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc abc",
+        rule: Rule::repeat_min_max,
+        tokens: [
+            repeat_min_max(0, 11, [
+                string(0, 3),
+                string(4, 7),
+                string(8, 11)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn repeat_min_max_atomic_twice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabc",
+        rule: Rule::repeat_min_max_atomic,
+        tokens: [
+            repeat_min_max_atomic(0, 6)
+        ]
+    };
+}
+
+#[test]
+fn repeat_min_max_atomic_thrice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabcabc",
+        rule: Rule::repeat_min_max_atomic,
+        tokens: [
+            repeat_min_max_atomic(0, 9)
+        ]
+    };
+}
+
+#[test]
+#[should_panic]
+fn repeat_min_max_atomic_space() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::repeat_min_max_atomic,
+        tokens: []
+    };
+}
+
+#[test]
+fn repeat_exact() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::repeat_exact,
+        tokens: [
+            repeat_exact(0, 7, [
+                string(0, 3),
+                string(4, 7)
+            ])
+        ]
+    };
+}
+
+#[test]
+#[should_panic]
+fn repeat_min_once() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::repeat_min,
+        tokens: []
+    };
+}
+
+#[test]
+fn repeat_min_twice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::repeat_min,
+        tokens: [
+            repeat_min(0, 7, [
+                string(0, 3),
+                string(4, 7)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn repeat_min_thrice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc  abc",
+        rule: Rule::repeat_min,
+        tokens: [
+            repeat_min(0, 12, [
+                string(0, 3),
+                string(4, 7),
+                string(9, 12)
+            ])
+        ]
+    };
+}
+
+#[test]
+#[should_panic]
+fn repeat_min_atomic_once() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::repeat_min_atomic,
+        tokens: []
+    };
+}
+
+#[test]
+fn repeat_min_atomic_twice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabc",
+        rule: Rule::repeat_min_atomic,
+        tokens: [
+            repeat_min_atomic(0, 6)
+        ]
+    };
+}
+
+#[test]
+fn repeat_min_atomic_thrice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabcabc",
+        rule: Rule::repeat_min_atomic,
+        tokens: [
+            repeat_min_atomic(0, 9)
+        ]
+    };
+}
+
+#[test]
+#[should_panic]
+fn repeat_min_atomic_space() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::repeat_min_atomic,
+        tokens: []
+    };
+}
+
+#[test]
+fn repeat_max_once() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::repeat_max,
+        tokens: [
+            repeat_max(0, 3, [
+                string(0, 3)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn repeat_max_twice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::repeat_max,
+        tokens: [
+            repeat_max(0, 7, [
+                string(0, 3),
+                string(4, 7)
+            ])
+        ]
+    };
+}
+
+#[test]
+#[should_panic]
+fn repeat_max_thrice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::repeat_max,
+        tokens: []
+    };
+}
+
+#[test]
+fn repeat_max_atomic_once() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::repeat_max_atomic,
+        tokens: [
+            repeat_max_atomic(0, 3)
+        ]
+    };
+}
+
+#[test]
+fn repeat_max_atomic_twice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabc",
+        rule: Rule::repeat_max_atomic,
+        tokens: [
+            repeat_max_atomic(0, 6)
+        ]
+    };
+}
+
+#[test]
+#[should_panic]
+fn repeat_max_atomic_thrice() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abcabcabc",
+        rule: Rule::repeat_max_atomic,
+        tokens: []
+    };
+}
+
+#[test]
+#[should_panic]
+fn repeat_max_atomic_space() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc abc",
+        rule: Rule::repeat_max_atomic,
+        tokens: []
+    };
+}
+
+#[test]
+fn repeat_comment() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc$$$ $$$abc",
+        rule: Rule::repeat_once,
+        tokens: [
+            repeat_once(0, 13, [
+                string(0, 3),
+                string(10, 13)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn soi_at_start() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::soi_at_start,
+        tokens: [
+            soi_at_start(0, 3, [
+                string(0, 3)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn peek() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "0111",
+        rule: Rule::peek_,
+        tokens: [
+            peek_(0, 4, [
+                range(0, 1),
+                range(1, 2)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn peek_all() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "0110",
+        rule: Rule::peek_all,
+        tokens: [
+            peek_all(0, 4, [
+                range(0, 1),
+                range(1, 2)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn peek_slice_23() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "0123412",
+        rule: Rule::peek_slice_23,
+        tokens: [
+            peek_slice_23(0, 7, [
+                range(0, 1),
+                range(1, 2),
+                range(2, 3),
+                range(3, 4),
+                range(4, 5),
+            ])
+        ]
+    };
+}
+
+#[test]
+fn pop() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "0110",
+        rule: Rule::pop_,
+        tokens: [
+            pop_(0, 4, [
+                range(0, 1),
+                range(1, 2)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn pop_all() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "0110",
+        rule: Rule::pop_all,
+        tokens: [
+            pop_all(0, 4, [
+                range(0, 1),
+                range(1, 2)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn pop_fail() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "010",
+        rule: Rule::pop_fail,
+        tokens: [
+            pop_fail(0, 3, [
+                range(0, 1),
+                range(1, 2)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn repeat_mutate_stack() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "a,b,c,cba",
+        rule: Rule::repeat_mutate_stack,
+        tokens: [
+            repeat_mutate_stack(0, 9)
+        ]
+    };
+}
+
+#[test]
+fn checkpoint_restore() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "a",
+        rule: Rule::checkpoint_restore,
+        tokens: [
+            checkpoint_restore(0, 1, [EOI(1, 1)])
+        ]
+    };
+}
+
+#[test]
+fn ascii_digits() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "6",
+        rule: Rule::ascii_digits,
+        tokens: [
+            ascii_digits(0, 1)
+        ]
+    };
+}
+
+#[test]
+fn ascii_nonzero_digits() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "5",
+        rule: Rule::ascii_nonzero_digits,
+        tokens: [
+            ascii_nonzero_digits(0, 1)
+        ]
+    };
+}
+
+#[test]
+fn ascii_bin_digits() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "1",
+        rule: Rule::ascii_bin_digits,
+        tokens: [
+            ascii_bin_digits(0, 1)
+        ]
+    };
+}
+
+#[test]
+fn ascii_oct_digits() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "3",
+        rule: Rule::ascii_oct_digits,
+        tokens: [
+            ascii_oct_digits(0, 1)
+        ]
+    };
+}
+
+#[test]
+fn ascii_hex_digits() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "6bC",
+        rule: Rule::ascii_hex_digits,
+        tokens: [
+            ascii_hex_digits(0, 3)
+        ]
+    };
+}
+
+#[test]
+fn ascii_alpha_lowers() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "a",
+        rule: Rule::ascii_alpha_lowers,
+        tokens: [
+            ascii_alpha_lowers(0, 1)
+        ]
+    };
+}
+
+#[test]
+fn ascii_alpha_uppers() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "K",
+        rule: Rule::ascii_alpha_uppers,
+        tokens: [
+            ascii_alpha_uppers(0, 1)
+        ]
+    };
+}
+
+#[test]
+fn ascii_alphas() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "wF",
+        rule: Rule::ascii_alphas,
+        tokens: [
+            ascii_alphas(0, 2)
+        ]
+    };
+}
+
+#[test]
+fn ascii_alphanumerics() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "4jU",
+        rule: Rule::ascii_alphanumerics,
+        tokens: [
+            ascii_alphanumerics(0, 3)
+        ]
+    };
+}
+
+#[test]
+fn asciis() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "x02",
+        rule: Rule::asciis,
+        tokens: [
+            asciis(0, 3)
+        ]
+    };
+}
+
+#[test]
+fn newline() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "\n\r\n\r",
+        rule: Rule::newline,
+        tokens: [
+            newline(0, 4)
+        ]
+    };
+}
+
+#[test]
+fn unicode() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "نامهای",
+        rule: Rule::unicode,
+        tokens: [
+            unicode(0, 12)
+        ]
+    }
+}
+
+#[test]
+fn shadowing() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "shadows builtin",
+        rule: Rule::SYMBOL,
+        tokens: [
+            SYMBOL(0, 15)
+        ]
+    }
+}
diff --git a/tests/grammar_inline.rs b/tests/grammar_inline.rs
new file mode 100644
index 0000000..2cc730a
--- /dev/null
+++ b/tests/grammar_inline.rs
@@ -0,0 +1,26 @@
+// Licensed under the Apache License, Version 2.0
+// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
+// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. All files in the project carrying such notice may not be copied,
+// modified, or distributed except according to those terms.
+
+#[macro_use]
+extern crate pest;
+#[macro_use]
+extern crate pest_derive;
+
+#[derive(Parser)]
+#[grammar_inline = "string = { \"abc\" }"]
+struct GrammarParser;
+
+#[test]
+fn inline_string() {
+    parses_to! {
+        parser: GrammarParser,
+        input: "abc",
+        rule: Rule::string,
+        tokens: [
+            string(0, 3)
+        ]
+    };
+}
diff --git a/tests/lists.pest b/tests/lists.pest
new file mode 100644
index 0000000..47756b7
--- /dev/null
+++ b/tests/lists.pest
@@ -0,0 +1,18 @@
+// pest. The Elegant Parser
+// Copyright (c) 2018 Dragoș Tiselice
+//
+// Licensed under the Apache License, Version 2.0
+// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
+// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. All files in the project carrying such notice may not be copied,
+// modified, or distributed except according to those terms.
+
+item = { (!"\n" ~ ANY)* }
+
+lists        = _{ lines ~ EOI }
+lines        = _{ top_first ~ ("\n" ~ top_continue)* }
+top_first    = _{ "- " ~ item ~ ("\n" ~ children)? }
+top_continue = _{ PEEK_ALL ~ "- " ~ item ~ ("\n" ~ children)? }
+
+indentation = _{ (" " | "\t")+ }
+children    =  { PEEK_ALL ~ PUSH(indentation) ~ lines ~ DROP }
diff --git a/tests/lists.rs b/tests/lists.rs
new file mode 100644
index 0000000..4ba0eff
--- /dev/null
+++ b/tests/lists.rs
@@ -0,0 +1,121 @@
+// pest. The Elegant Parser
+// Copyright (c) 2018 Dragoș Tiselice
+//
+// Licensed under the Apache License, Version 2.0
+// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
+// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. All files in the project carrying such notice may not be copied,
+// modified, or distributed except according to those terms.
+
+#[macro_use]
+extern crate pest;
+#[macro_use]
+extern crate pest_derive;
+
+#[derive(Parser)]
+#[grammar = "../tests/lists.pest"]
+struct ListsParser;
+
+#[test]
+fn item() {
+    parses_to! {
+        parser: ListsParser,
+        input: "- a",
+        rule: Rule::lists,
+        tokens: [
+            item(2, 3)
+        ]
+    };
+}
+
+#[test]
+fn items() {
+    parses_to! {
+        parser: ListsParser,
+        input: "- a\n- b",
+        rule: Rule::lists,
+        tokens: [
+            item(2, 3),
+            item(6, 7)
+        ]
+    };
+}
+
+#[test]
+fn children() {
+    parses_to! {
+        parser: ListsParser,
+        input: "  - b",
+        rule: Rule::children,
+        tokens: [
+            children(0, 5, [
+                item(4, 5)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn nested_item() {
+    parses_to! {
+        parser: ListsParser,
+        input: "- a\n  - b",
+        rule: Rule::lists,
+        tokens: [
+            item(2, 3),
+            children(4, 9, [
+                item(8, 9)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn nested_items() {
+    parses_to! {
+        parser: ListsParser,
+        input: "- a\n  - b\n  - c",
+        rule: Rule::lists,
+        tokens: [
+            item(2, 3),
+            children(4, 15, [
+                item(8, 9),
+                item(14, 15)
+            ])
+        ]
+    };
+}
+
+#[test]
+fn nested_two_levels() {
+    parses_to! {
+        parser: ListsParser,
+        input: "- a\n  - b\n    - c",
+        rule: Rule::lists,
+        tokens: [
+            item(2, 3),
+            children(4, 17, [
+                item(8, 9),
+                children(10, 17, [
+                    item(16, 17)
+                ])
+            ])
+        ]
+    };
+}
+
+#[test]
+fn nested_then_not() {
+    parses_to! {
+        parser: ListsParser,
+        input: "- a\n  - b\n- c",
+        rule: Rule::lists,
+        tokens: [
+            item(2, 3),
+            children(4, 9, [
+                item(8, 9)
+            ]),
+            item(12, 13)
+        ]
+    };
+}
diff --git a/tests/reporting.pest b/tests/reporting.pest
new file mode 100644
index 0000000..060dbfc
--- /dev/null
+++ b/tests/reporting.pest
@@ -0,0 +1,27 @@
+// pest. The Elegant Parser
+// Copyright (c) 2018 Dragoș Tiselice
+//
+// Licensed under the Apache License, Version 2.0
+// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
+// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. All files in the project carrying such notice may not be copied,
+// modified, or distributed except according to those terms.
+
+a = { "a" }
+b = { "b" }
+c = { "c" }
+d = { ANY }
+
+choices = _{ a | b | c }
+choices_no_progress = { a | b | c }
+choices_a_progress = { a ~ a | b | c }
+choices_b_progress = { a | b ~ b | c }
+
+level1 = _{ level2 }
+level2 = _{ a | b | c }
+
+negative = _{ !d }
+negative_match = _{ !a ~ b }
+mixed = _{ !d | a }
+mixed_progress = _{ (!d | a | b) ~ a }
+
diff --git a/tests/reporting.rs b/tests/reporting.rs
new file mode 100644
index 0000000..aa0a974
--- /dev/null
+++ b/tests/reporting.rs
@@ -0,0 +1,125 @@
+// pest. The Elegant Parser
+// Copyright (c) 2018 Dragoș Tiselice
+//
+// Licensed under the Apache License, Version 2.0
+// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
+// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. All files in the project carrying such notice may not be copied,
+// modified, or distributed except according to those terms.
+
+#[macro_use]
+extern crate pest;
+#[macro_use]
+extern crate pest_derive;
+
+#[derive(Parser)]
+#[grammar = "../tests/reporting.pest"]
+struct ReportingParser;
+
+#[test]
+fn choices() {
+    fails_with! {
+        parser: ReportingParser,
+        input: "x",
+        rule: Rule::choices,
+        positives: vec![Rule::a, Rule::b, Rule::c],
+        negatives: vec![],
+        pos: 0
+    };
+}
+
+#[test]
+fn choices_no_progress() {
+    fails_with! {
+        parser: ReportingParser,
+        input: "x",
+        rule: Rule::choices_no_progress,
+        positives: vec![Rule::choices_no_progress],
+        negatives: vec![],
+        pos: 0
+    };
+}
+
+#[test]
+fn choices_a_progress() {
+    fails_with! {
+        parser: ReportingParser,
+        input: "a",
+        rule: Rule::choices_a_progress,
+        positives: vec![Rule::a],
+        negatives: vec![],
+        pos: 1
+    };
+}
+
+#[test]
+fn choices_b_progress() {
+    fails_with! {
+        parser: ReportingParser,
+        input: "b",
+        rule: Rule::choices_b_progress,
+        positives: vec![Rule::b],
+        negatives: vec![],
+        pos: 1
+    };
+}
+
+#[test]
+fn nested() {
+    fails_with! {
+        parser: ReportingParser,
+        input: "x",
+        rule: Rule::level1,
+        positives: vec![Rule::a, Rule::b, Rule::c],
+        negatives: vec![],
+        pos: 0
+    };
+}
+
+#[test]
+fn negative() {
+    fails_with! {
+        parser: ReportingParser,
+        input: "x",
+        rule: Rule::negative,
+        positives: vec![],
+        negatives: vec![Rule::d],
+        pos: 0
+    };
+}
+
+#[test]
+fn negative_match() {
+    fails_with! {
+        parser: ReportingParser,
+        input: "x",
+        rule: Rule::negative_match,
+        positives: vec![Rule::b],
+        negatives: vec![],
+        pos: 0
+    };
+}
+
+#[test]
+fn mixed() {
+    fails_with! {
+        parser: ReportingParser,
+        input: "x",
+        rule: Rule::mixed,
+        positives: vec![Rule::a],
+        negatives: vec![Rule::d],
+        pos: 0
+    };
+}
+
+#[test]
+fn mixed_progress() {
+    fails_with! {
+        parser: ReportingParser,
+        input: "b",
+        rule: Rule::mixed_progress,
+        positives: vec![Rule::a],
+        negatives: vec![],
+        pos: 1
+    };
+}