mirror of
https://github.com/zaphar/abortable_parser.git
synced 2025-07-22 20:39:50 -04:00
REFACTOR: Normalize naming for the contained rules in a combinator macro.
This commit is contained in:
parent
a5ca5a92ce
commit
71f76b16f7
@ -647,13 +647,13 @@ macro_rules! text_token {
|
|||||||
/// ```
|
/// ```
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! until {
|
macro_rules! until {
|
||||||
($i:expr, $term:ident!( $( $args:tt )* ) ) => {{
|
($i:expr, $rule:ident!( $( $args:tt )* ) ) => {{
|
||||||
use $crate::{Result, Offsetable, Span, SpanRange};
|
use $crate::{Result, Offsetable, Span, SpanRange};
|
||||||
let start_offset = $i.get_offset();
|
let start_offset = $i.get_offset();
|
||||||
let mut _i = $i.clone();
|
let mut _i = $i.clone();
|
||||||
let pfn = || {
|
let pfn = || {
|
||||||
loop {
|
loop {
|
||||||
match $term!(_i.clone(), $($args)*) {
|
match $rule!(_i.clone(), $($args)*) {
|
||||||
Result::Complete(_, _) => {
|
Result::Complete(_, _) => {
|
||||||
let range = SpanRange::Range(start_offset.._i.get_offset());
|
let range = SpanRange::Range(start_offset.._i.get_offset());
|
||||||
return Result::Complete(_i, $i.span(range));
|
return Result::Complete(_i, $i.span(range));
|
||||||
@ -672,8 +672,8 @@ macro_rules! until {
|
|||||||
pfn()
|
pfn()
|
||||||
}};
|
}};
|
||||||
|
|
||||||
($i:expr, $term:ident) => {
|
($i:expr, $rule:ident) => {
|
||||||
consume_until!($i, run!($term))
|
consume_until!($i, run!($rule))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,13 +681,13 @@ macro_rules! until {
|
|||||||
/// Leaves Failures, Aborts, and Incompletes untouched.
|
/// Leaves Failures, Aborts, and Incompletes untouched.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! discard {
|
macro_rules! discard {
|
||||||
($i:expr, $term:ident) => {
|
($i:expr, $rule:ident) => {
|
||||||
discard!($i, run!($term))
|
discard!($i, run!($rule))
|
||||||
};
|
};
|
||||||
|
|
||||||
($i:expr, $term:ident!( $( $args:tt )* ) ) => {{
|
($i:expr, $rule:ident!( $( $args:tt )* ) ) => {{
|
||||||
use $crate::Result;
|
use $crate::Result;
|
||||||
match $term!($i, $($args)*) {
|
match $rule!($i, $($args)*) {
|
||||||
Result::Complete(i, _) => Result::Complete(i, ()),
|
Result::Complete(i, _) => Result::Complete(i, ()),
|
||||||
Result::Incomplete(offset) => Result::Incomplete(offset),
|
Result::Incomplete(offset) => Result::Incomplete(offset),
|
||||||
Result::Fail(e) => Result::Fail(e),
|
Result::Fail(e) => Result::Fail(e),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user