Left recursion doesn't work when using a custom input type. Specifically, the input of my parser is LocatedSpan<T, RecursiveInfo> where T is a stream of tokens that contains a vector of an enumeration that defines the tokens variants .
When first deriving my recursive function with#[recursive_parser] it complained that I didn't have implemented the AsBytes trait, so this is what I came up with:
impl AsBytes for TokenStream {
fn as_bytes(&self) -> &[u8] {
unsafe {
core::slice::from_raw_parts(
(self as *const TokenStream) as *const u8,
::core::mem::size_of::<TokenStream>(),
)
}
}
}
However, the parser is terminating with the SIGSEV signal when trying to parse with left recursion.
Maybe a problem with the AsBytes implementation?
Left recursion doesn't work when using a custom input type. Specifically, the input of my parser is
LocatedSpan<T, RecursiveInfo>
whereT
is a stream of tokens that contains a vector of an enumeration that defines the tokens variants . When first deriving my recursive function with#[recursive_parser]
it complained that I didn't have implemented theAsBytes
trait, so this is what I came up with:However, the parser is terminating with the
SIGSEV
signal when trying to parse with left recursion. Maybe a problem with theAsBytes
implementation?