mirror of
https://github.com/roc-lang/roc.git
synced 2024-10-05 06:37:26 +03:00
example for skip_second
This commit is contained in:
parent
eed1957180
commit
c582ad6767
@ -1424,6 +1424,29 @@ macro_rules! skip_first {
|
||||
|
||||
/// If the first one parses, parse the second one; if it also parses, use the
|
||||
/// output from the first one.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// # use roc_parse::state::{State};
|
||||
/// # use crate::roc_parse::parser::{Parser, Progress, word};
|
||||
/// # use roc_parse::ident::lowercase_ident;
|
||||
/// # use roc_parse::skip_second;
|
||||
/// # use roc_region::all::{Loc, Position};
|
||||
/// # use bumpalo::Bump;
|
||||
/// # let arena = Bump::new();
|
||||
/// # fn foo<'a>(arena: &'a Bump) {
|
||||
/// let parser = skip_second!(
|
||||
/// lowercase_ident(),
|
||||
/// word(", world", |_| ())
|
||||
/// );
|
||||
///
|
||||
/// let (progress, output, state) = parser.parse(&arena, State::new("hello, world".as_bytes()), 0).unwrap();
|
||||
/// assert_eq!(progress, Progress::MadeProgress);
|
||||
/// assert_eq!(output, "hello");
|
||||
/// assert_eq!(state.pos().offset, 12);
|
||||
/// # }
|
||||
/// # foo(&arena);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! skip_second {
|
||||
($p1:expr, $p2:expr) => {
|
||||
|
Loading…
Reference in New Issue
Block a user