From de0c03398c78093590178bd9639a38d0eeeb08fe Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 9 Oct 2018 20:33:36 -0500 Subject: [PATCH] MAINT: Update and flesh out docs. --- Cargo.toml | 6 +++--- README.md | 1 + src/combinators.rs | 23 +++++++++++++++++++++-- src/lib.rs | 10 +++++----- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2731074..5f56dd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "abortable-parser" +name = "abortable_parser" version = "0.1.0" authors = ["Jeremy Wall "] description = "A parser combinator library with an emphasis on error handling" repository = "https://github.com/zaphar/abortable_parser" -documentation = "https://docs.rs/crate/abortable-parser" +documentation = "https://docs.rs/crate/abortable_parser" readme = "README.md" license = "Apache-2.0" -keywords = ["parsing"] +keywords = ["parsing", "combinator"] [dependencies] diff --git a/README.md b/README.md index 54421ae..8428f64 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # Abortable Parser +[![Build Status](https://travis-ci.org/zaphar/abortable_parser.svg?branch=master)](https://travis-ci.org/zaphar/abortable_parser) A parser combinator library in rust with an emphasis on error handling. Heavily inspired by [nom](https://github.com/Geal/nom) in it's approach to macro composition. \ No newline at end of file diff --git a/src/combinators.rs b/src/combinators.rs index dcc2a89..9876109 100644 --- a/src/combinators.rs +++ b/src/combinators.rs @@ -558,7 +558,7 @@ macro_rules! optional { }}; } -/// Runs a single matcher repeating 0 or mre times and returns a possibly empty +/// Runs a single matcher repeating 0 or more times and returns a possibly empty /// vector of the parsed results. /// /// ``` @@ -618,6 +618,24 @@ macro_rules! repeat { }; } +/// Parses separated list of items. +/// +/// ``` +/// # #[macro_use] extern crate abortable_parser; +/// use abortable_parser::iter; +/// # use abortable_parser::{Result, Offsetable}; +/// # fn main() { +/// let input_str = "foo,foo"; +/// let iter = iter::SliceIter::new(input_str.as_bytes()); +/// let result = separated!(iter, text_token!(","), text_token!("foo")); +/// # assert!(result.is_complete()); +/// if let Result::Complete(_, o) = result { +/// assert_eq!(2, o.len()); +/// assert_eq!("foo", o[0]); +/// assert_eq!("foo", o[1]); +/// } +/// # } +/// ``` #[macro_export] macro_rules! separated { ($i:expr, $sep_rule:ident!( $( $sep_args:tt )* ), $item_rule:ident!( $( $item_args:tt )* ) ) => {{ @@ -709,7 +727,8 @@ macro_rules! text_token { }}; } -/// Consumes an input until it reaches the term combinator matches. +/// Consumes an input until it reaches a term that the contained rule matches. +/// It does not consume the subrule. /// /// If the term never matches then returns incomplete. /// ``` diff --git a/src/lib.rs b/src/lib.rs index 97108cd..f9ebd3f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! An opinionated parser combinator library with a focus on fully abortable parsing and error handling. +//! An opinionated parser combinator library with a focus on fully abortable parsing and +//! easy error handling. //! -//! The approach to macro composition is heavily inspired by nom. However we emphasize error -//! handling as a first class citizen. abortable_parser has the concept of an unrecoverable -//! parsing error as distinct from a general failure to match. +//! The approach to macro composition is heavily inspired by nom. It focuses on a simple +//! API for combinators, and easy error handling. //! -//! We have a numner of macros that assist in the gneration or handling of each type +//! We have a number of macros that assist in the gneration or handling of each type //! of error. //! //! # Simple parsing of a url.