pub struct ParseState { /* private fields */ }Implementations§
Source§impl ParseState
impl ParseState
Sourcepub fn new(syntax: &SyntaxReference) -> ParseState
pub fn new(syntax: &SyntaxReference) -> ParseState
Creates a state from a syntax definition, keeping its own reference-counted point to the main context of the syntax
Sourcepub fn parse_line(
&mut self,
line: &str,
syntax_set: &SyntaxSet,
) -> Result<ParseLineOutput, ParsingError>
pub fn parse_line( &mut self, line: &str, syntax_set: &SyntaxSet, ) -> Result<ParseLineOutput, ParsingError>
Parses a single line of the file. Because of the way regex engines work you unfortunately have to pass in a single line contiguous in memory. This can be bad for really long lines. Sublime Text avoids this by just not highlighting lines that are too long (thousands of characters).
For efficiency reasons this returns only the changes to the current scope at each point in the line.
You can use ScopeStack::apply on each operation in succession to get the stack for a given point.
Look at the code in highlighter.rs for an example of doing this for highlighting purposes.
The returned vector is in order both by index to apply at (the usize) and also by order to apply them at a
given index (e.g popping old scopes before pushing new scopes).
The SyntaxSet has to be the one that contained the syntax that was used to construct
this ParseState, or an extended version of it. Otherwise the parsing would return the
wrong result or even panic. The reason for this is that contexts within the SyntaxSet
are referenced via indexes.
Sourcepub fn is_speculative(&self) -> bool
pub fn is_speculative(&self) -> bool
Returns true when the parser is inside a branch_point and the
result of parse_line may be revised by a future fail action.
Once the branch resolves (or if no branch was entered), this returns
false and all ops emitted so far are final.
Trait Implementations§
Source§impl Clone for ParseState
impl Clone for ParseState
Source§fn clone(&self) -> ParseState
fn clone(&self) -> ParseState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParseState
impl Debug for ParseState
Source§impl PartialEq for ParseState
impl PartialEq for ParseState
impl Eq for ParseState
impl StructuralPartialEq for ParseState
Auto Trait Implementations§
impl Freeze for ParseState
impl RefUnwindSafe for ParseState
impl !Send for ParseState
impl !Sync for ParseState
impl Unpin for ParseState
impl UnsafeUnpin for ParseState
impl UnwindSafe for ParseState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.