Added ability to specify char type in 'parser_fn_decl!'
This commit is contained in:
parent
cac9602470
commit
be8e477ecc
@ -1,87 +1,129 @@
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! parser_fn_decl {
|
macro_rules! parser_fn_decl {
|
||||||
// only type generics | default src type -------------------------------------------------------
|
// unknown char type | custom src type ---------------------------------------------------------
|
||||||
(
|
(
|
||||||
$scope:vis fn $name:ident
|
$scope:vis fn $name:ident
|
||||||
$(<
|
<
|
||||||
$generic0Name:ident $(: $generic0Bound:path)?
|
C=?
|
||||||
$(, $genericNName:ident $(: $genericNBound:path)?)* $(,)?
|
$(, $lifetimeName:lifetime)*
|
||||||
>)?
|
$(, $genericName:ident $(: $genericBound:path)?)*
|
||||||
($srcName:ident : $srcType:ty $(, $argNName:ident : $argNType:ty)* $(,)?)
|
$(,)?
|
||||||
|
>
|
||||||
|
(
|
||||||
|
$srcName:ident : $srcType:ty
|
||||||
|
$(, $argName:ident : $argType:ty)*
|
||||||
|
$(,)?
|
||||||
|
)
|
||||||
$(-> $ret:ty)?
|
$(-> $ret:ty)?
|
||||||
$body:block
|
$body:block
|
||||||
) => {
|
) => {
|
||||||
$scope fn $name
|
$scope fn $name
|
||||||
<
|
<
|
||||||
'source, 'pos, P:Pos<'pos>, CS:CollectedSubstring<'source>
|
'source, 'pos,
|
||||||
$(, $generic0Name $(: $generic0Bound)? $(, $genericNName $(: $genericNBound)?)* )?
|
$( $lifetimeName, )*
|
||||||
|
C:Copy, P:Pos<'pos>, CS:CollectedSubstring<'source, C=C>
|
||||||
|
$(, $genericName $(: $genericBound)?)*
|
||||||
>
|
>
|
||||||
($srcName: $srcType $(, $argNName : $argNType)*)
|
(
|
||||||
|
$srcName: $srcType
|
||||||
|
$(, $argName : $argType)*
|
||||||
|
)
|
||||||
$(-> $ret)?
|
$(-> $ret)?
|
||||||
$body
|
$body
|
||||||
};
|
};
|
||||||
|
|
||||||
// lifetime + type generics | default src type --------------------------------------------------
|
// explicit char type | custom src type ---------------------------------------------------------
|
||||||
(
|
(
|
||||||
$scope:vis fn $name:ident
|
$scope:vis fn $name:ident
|
||||||
<
|
<
|
||||||
$lifetime0Name:lifetime $(, $lifetimeNName:lifetime)*
|
C=$charType:ty
|
||||||
$(, $genericNName:ident $(: $genericNBound:path)?)* $(,)?
|
$(, $lifetimeName:lifetime)*
|
||||||
|
$(, $genericName:ident $(: $genericBound:path)?)*
|
||||||
|
$(,)?
|
||||||
>
|
>
|
||||||
($srcName:ident : $srcType:ty $(, $argNName:ident : $argNType:ty)* $(,)?)
|
(
|
||||||
|
$srcName:ident : $srcType:ty
|
||||||
|
$(, $argName:ident : $argType:ty)*
|
||||||
|
$(,)?
|
||||||
|
)
|
||||||
$(-> $ret:ty)?
|
$(-> $ret:ty)?
|
||||||
$body:block
|
$body:block
|
||||||
) => {
|
) => {
|
||||||
$scope fn $name
|
$scope fn $name
|
||||||
<
|
<
|
||||||
'source, 'pos, $lifetime0Name $(, $lifetimeNName)*,
|
'source, 'pos,
|
||||||
P: Pos<'pos>, CS: CollectedSubstring<'source>
|
$( $lifetimeName, )*
|
||||||
$(, $genericNName $(: $genericNBound)?)*
|
P:Pos<'pos>, CS:CollectedSubstring<'source, C=$charType>
|
||||||
|
$(, $genericName $(: $genericBound)?)*
|
||||||
>
|
>
|
||||||
($srcName: $srcType $(, $argNName : $argNType)*)
|
(
|
||||||
|
$srcName: $srcType
|
||||||
|
$(, $argName : $argType)*
|
||||||
|
)
|
||||||
$(-> $ret)?
|
$(-> $ret)?
|
||||||
$body
|
$body
|
||||||
};
|
};
|
||||||
|
|
||||||
// only type generics | custom src type --------------------------------------------------------
|
// unknown char type | default src type --------------------------------------------------------
|
||||||
(
|
(
|
||||||
$scope:vis fn $name:ident
|
$scope:vis fn $name:ident
|
||||||
$(<
|
<
|
||||||
$generic0Name:ident $(: $generic0Bound:path)?
|
C=?
|
||||||
$(, $genericNName:ident $(: $genericNBound:path)?)* $(,)?
|
$(, $lifetimeName:lifetime)*
|
||||||
>)?
|
$(, $genericName:ident $(: $genericBound:path)?)*
|
||||||
($srcName:ident $(, $argNName:ident : $argNType:ty)* $(,)?)
|
$(,)?
|
||||||
|
>
|
||||||
|
(
|
||||||
|
$srcName:ident
|
||||||
|
$(, $argName:ident : $argType:ty)*
|
||||||
|
$(,)?
|
||||||
|
)
|
||||||
$(-> $ret:ty)?
|
$(-> $ret:ty)?
|
||||||
$body:block
|
$body:block
|
||||||
) => {
|
) => {
|
||||||
$scope fn $name
|
$scope fn $name
|
||||||
<
|
<
|
||||||
'source, 'pos, P:Pos<'pos>, CS:CollectedSubstring<'source>
|
'source, 'pos,
|
||||||
$(, $generic0Name $(: $generic0Bound)? $(, $genericNName $(: $genericNBound)?)* )?
|
$( $lifetimeName, )*
|
||||||
|
C:Copy, P:Pos<'pos>, CS:CollectedSubstring<'source, C=C>
|
||||||
|
$(, $genericName $(: $genericBound)?)*
|
||||||
>
|
>
|
||||||
($srcName: &'source mut impl SourceStream<'source, 'pos, P=P, CS=CS> $(, $argNName : $argNType)*)
|
(
|
||||||
|
$srcName: &'source mut impl SourceStream<'source, 'pos, C=C, P=P, CS=CS>
|
||||||
|
$(, $argName : $argType)*
|
||||||
|
)
|
||||||
$(-> $ret)?
|
$(-> $ret)?
|
||||||
$body
|
$body
|
||||||
};
|
};
|
||||||
|
|
||||||
// lifetime + type generics | custom src type --------------------------------------------------
|
// explicit char type | default src type -------------------------------------------------------
|
||||||
(
|
(
|
||||||
$scope:vis fn $name:ident
|
$scope:vis fn $name:ident
|
||||||
<
|
<
|
||||||
$lifetime0Name:lifetime $(, $lifetimeNName:lifetime)*
|
C=$charType:ty
|
||||||
$(, $genericNName:ident $(: $genericNBound:path)?)* $(,)?
|
$(, $lifetimeName:lifetime)*
|
||||||
|
$(, $genericName:ident $(: $genericBound:path)?)*
|
||||||
|
$(,)?
|
||||||
>
|
>
|
||||||
($srcName:ident $(, $argNName:ident : $argNType:ty)* $(,)?)
|
(
|
||||||
|
$srcName:ident
|
||||||
|
$(, $argName:ident : $argType:ty)*
|
||||||
|
$(,)?
|
||||||
|
)
|
||||||
$(-> $ret:ty)?
|
$(-> $ret:ty)?
|
||||||
$body:block
|
$body:block
|
||||||
) => {
|
) => {
|
||||||
$scope fn $name
|
$scope fn $name
|
||||||
<
|
<
|
||||||
'source, 'pos, $lifetime0Name $(, $lifetimeNName)*,
|
'source, 'pos,
|
||||||
P: Pos<'pos>, CS: CollectedSubstring<'source>
|
$( $lifetimeName, )*
|
||||||
$(, $genericNName $(: $genericNBound)?)*
|
P:Pos<'pos>, CS:CollectedSubstring<'source, C=$charType>
|
||||||
|
$(, $genericName $(: $genericBound)?)*
|
||||||
>
|
>
|
||||||
($srcName: &'source mut impl SourceStream<'source, 'pos, P=P, CS=CS> $(, $argNName : $argNType)*)
|
(
|
||||||
|
$srcName: &'source mut impl SourceStream<'source, 'pos, C=$charType, P=P, CS=CS>
|
||||||
|
$(, $argName : $argType)*
|
||||||
|
)
|
||||||
$(-> $ret)?
|
$(-> $ret)?
|
||||||
$body
|
$body
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user