MAINT: Update and flesh out docs.

This commit is contained in:
Jeremy Wall 2018-10-09 20:33:36 -05:00
parent d9de070873
commit de0c03398c
4 changed files with 30 additions and 10 deletions

View File

@ -1,12 +1,12 @@
[package] [package]
name = "abortable-parser" name = "abortable_parser"
version = "0.1.0" version = "0.1.0"
authors = ["Jeremy Wall <jeremy@marzhillstudios.com>"] authors = ["Jeremy Wall <jeremy@marzhillstudios.com>"]
description = "A parser combinator library with an emphasis on error handling" description = "A parser combinator library with an emphasis on error handling"
repository = "https://github.com/zaphar/abortable_parser" repository = "https://github.com/zaphar/abortable_parser"
documentation = "https://docs.rs/crate/abortable-parser" documentation = "https://docs.rs/crate/abortable_parser"
readme = "README.md" readme = "README.md"
license = "Apache-2.0" license = "Apache-2.0"
keywords = ["parsing"] keywords = ["parsing", "combinator"]
[dependencies] [dependencies]

View File

@ -1,3 +1,4 @@
# Abortable Parser # 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. 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.

View File

@ -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. /// 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_export]
macro_rules! separated { macro_rules! separated {
($i:expr, $sep_rule:ident!( $( $sep_args:tt )* ), $item_rule:ident!( $( $item_args:tt )* ) ) => {{ ($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. /// If the term never matches then returns incomplete.
/// ``` /// ```

View File

@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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 //! The approach to macro composition is heavily inspired by nom. It focuses on a simple
//! handling as a first class citizen. abortable_parser has the concept of an unrecoverable //! API for combinators, and easy error handling.
//! parsing error as distinct from a general failure to match.
//! //!
//! 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. //! of error.
//! //!
//! # Simple parsing of a url. //! # Simple parsing of a url.