feat: add error information in the progress callback
This allows users to bail parsing if an error was *definitely* detected using the progress callback, as all possible stack versions have a non-zero error cost. Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
This commit is contained in:
parent
ca087d2c07
commit
cda634a1c4
9 changed files with 87 additions and 4 deletions
|
|
@ -82,6 +82,7 @@ pub struct TSInput {
|
|||
pub struct TSParseState {
|
||||
pub payload: *mut ::core::ffi::c_void,
|
||||
pub current_byte_offset: u32,
|
||||
pub has_error: bool,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
|
|
|||
|
|
@ -147,6 +147,11 @@ impl ParseState {
|
|||
pub const fn current_byte_offset(&self) -> usize {
|
||||
unsafe { self.0.as_ref() }.current_byte_offset as usize
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn has_error(&self) -> bool {
|
||||
unsafe { self.0.as_ref() }.has_error
|
||||
}
|
||||
}
|
||||
|
||||
/// A stateful object that is passed into a [`QueryProgressCallback`]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue