Made macro less complicatd
This commit is contained in:
parent
90cf7db609
commit
e88a0f59b5
@ -502,31 +502,28 @@ macro_rules! parse_method {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! delimited {
|
macro_rules! delimited {
|
||||||
($self:expr, $start:pat, $parse_fn:ident, $( $delim:pat )|+, $end:pat) => {
|
|
||||||
delimited!($self, $start, $parse_fn, $( $delim )|*, $end, strict_delimiters)
|
|
||||||
};
|
|
||||||
($self:expr, $start:pat, $parse_fn:ident, $( $delim:pat )|+, $end:pat, nonstrict) => {
|
($self:expr, $start:pat, $parse_fn:ident, $( $delim:pat )|+, $end:pat, nonstrict) => {
|
||||||
delimited!($self, $start, $parse_fn, $( $delim )|*, $end, nonstrict_delimiters)
|
delimited!($self, $start, $parse_fn, $( $delim )|*, $end, false)
|
||||||
};
|
};
|
||||||
(_internal nonstrict_delimiters $self:expr, $( $delim:pat )|+, $end:pat) => {
|
($self:expr, $start:pat, $parse_fn:ident, $( $delim:pat )|+, $end:pat) => {
|
||||||
match $self.peek() {
|
delimited!($self, $start, $parse_fn, $( $delim )|*, $end, true)
|
||||||
$end | EOF => break,
|
|
||||||
$( $delim )|* => { $self.next(); continue },
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
(_internal strict_delimiters $self:expr, $( $delim:pat )|+, $end:pat) => {
|
($self:expr, $start:pat, $parse_fn:ident, $( $delim:pat )|+, $end:pat, $strictness:expr) => {
|
||||||
match $self.peek() {
|
|
||||||
$end | EOF => break,
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
($self:expr, $start:pat, $parse_fn:ident, $( $delim:pat )|+, $end:pat, $strictness:tt) => {
|
|
||||||
{
|
{
|
||||||
expect!($self, $start, "Expected <start symbol figure out string interpol in macros>");
|
expect!($self, $start, "Expected <start symbol figure out string interpol in macros>");
|
||||||
let mut acc = vec![];
|
let mut acc = vec![];
|
||||||
loop {
|
loop {
|
||||||
delimited!(_internal $strictness $self, $( $delim )|*, $end);
|
let peek = $self.peek();
|
||||||
|
match peek {
|
||||||
|
$end | EOF => break,
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
if !$strictness {
|
||||||
|
match peek {
|
||||||
|
$( $delim )|* => { $self.next(); continue },
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
|
}
|
||||||
acc.push($self.$parse_fn()?);
|
acc.push($self.$parse_fn()?);
|
||||||
match $self.peek() {
|
match $self.peek() {
|
||||||
$( $delim )|* => { $self.next(); continue },
|
$( $delim )|* => { $self.next(); continue },
|
||||||
|
Loading…
Reference in New Issue
Block a user