pub struct Parser<'s> {
pub filepath: PathBuf,
pub source_code: &'s str,
pub root: DocumentFunction,
}Expand description
Parser holds a reference to the text document source code.
To generate better error messages, we also store the filepath.
The parsing process fills a tree with data.
A typical parsing process is done with the following methods:
consume_iter(iter) takes a LexingIterator and consumes the
generated tokens. Then finalize declares the termination of
the token consumption. Finally one can fetch the resulting
abstract syntax tree by calling the method tree().
Fields§
§filepath: PathBuf§source_code: &'s str§root: DocumentFunctionImplementations§
Source§impl<'s> Parser<'s>
impl<'s> Parser<'s>
pub fn new(filepath: &Path, source_code: &'s str) -> Parser<'s>
Sourcepub fn consume_iter(&mut self, iter: LexingIterator<'_>) -> Result<(), Error>
pub fn consume_iter(&mut self, iter: LexingIterator<'_>) -> Result<(), Error>
Consumes the tokens provided by the LexingIterator argument
Sourcepub fn tree(self) -> DocumentTree
pub fn tree(self) -> DocumentTree
Returns the Abstract Syntax Tree to be processed further
Auto Trait Implementations§
impl<'s> Freeze for Parser<'s>
impl<'s> RefUnwindSafe for Parser<'s>
impl<'s> Send for Parser<'s>
impl<'s> Sync for Parser<'s>
impl<'s> Unpin for Parser<'s>
impl<'s> UnwindSafe for Parser<'s>
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
Mutably borrows from an owned value. Read more