[−][src]Struct lexpr::parse::Parser
Parser for the S-expression text representation.
This type, given a input source, provides the parse
method,
which can be used to read a single S-expression from the input
source.
Methods
impl<'de, R> Parser<R> where
R: Read<'de>,
[src]
R: Read<'de>,
pub fn new(read: R) -> Self
[src]
Create an S-expression parser from one of the possible sexpr input sources.
Typically it is more convenient to use one of these methods instead:
Parser::from_str
Parser::from_slice
Parser::from_reader
pub fn with_options(read: R, options: Options) -> Self
[src]
Create a customized S-expression parser parser from one of the possible sexpr input sources.
Typically it is more convenient to use one of these methods instead:
Parser::from_str_custom
Parser::from_slice_custom
Parser::from_reader_custom
impl<R> Parser<IoRead<R>> where
R: Read,
[src]
R: Read,
pub fn from_reader(reader: R) -> Self
[src]
Creates an S-expression parser from an io::Read
.
pub fn from_reader_custom(reader: R, options: Options) -> Self
[src]
Creates an S-expression parser from an io::Read
.
impl<'a> Parser<SliceRead<'a>>
[src]
pub fn from_slice(bytes: &'a [u8]) -> Self
[src]
Creates an S-expression parser from a &[u8]
.
pub fn from_slice_custom(bytes: &'a [u8], options: Options) -> Self
[src]
Creates an S-expression parser from a &[u8]
.
impl<'a> Parser<StrRead<'a>>
[src]
pub fn from_str(s: &'a str) -> Self
[src]
Creates a S-expression parser from a &str
.
pub fn from_str_custom(s: &'a str, options: Options) -> Self
[src]
Creates a S-expression parser from a &str
.
impl<'de, R: Read<'de>> Parser<R>
[src]
pub fn end(&mut self) -> Result<()>
[src]
The Parser::end
method should be called after a value has been fully
parsed. This allows the Parser
to validate that the input stream is
at the end or that it only has trailing whitespace.
pub fn parse_value(&mut self) -> Result<Value>
[src]
Parse a single S-expression from the input source.
This expects an S-expression value to be actually present, and
returns an Err
when called at the end of input. Use
Parser::parse
if you need to handle end of input gracefully.
let mut parser = Parser::from_str(r#"foo ("bar" . 3.14) #:baz (1 2 3)"#); assert_eq!(parser.parse_value().unwrap(), sexp!(foo)); assert_eq!(parser.parse_value().unwrap(), sexp!(("bar" . 3.14))); assert_eq!(parser.parse_value().unwrap(), sexp!(#:baz)); assert_eq!(parser.parse_value().unwrap(), sexp!((1 2 3))); assert!(parser.end().is_ok());
pub fn parse(&mut self) -> Result<Option<Value>>
[src]
Parse a single S-expression from the input source.
If the end of input is ecountered, this will return
Ok(None)
, otherwise, if parsing suceeded, Ok(Some(Value))
.
let mut parser = Parser::from_str(r#"foo ("bar" . 3.14) #:baz (1 2 3)"#); assert_eq!(parser.parse().unwrap(), Some(sexp!(foo))); assert_eq!(parser.parse().unwrap(), Some(sexp!(("bar" . 3.14)))); assert_eq!(parser.parse().unwrap(), Some(sexp!(#:baz))); assert_eq!(parser.parse().unwrap(), Some(sexp!((1 2 3)))); assert_eq!(parser.parse().unwrap(), None);
Auto Trait Implementations
impl<R> Send for Parser<R> where
R: Send,
R: Send,
impl<R> Unpin for Parser<R> where
R: Unpin,
R: Unpin,
impl<R> Sync for Parser<R> where
R: Sync,
R: Sync,
impl<R> UnwindSafe for Parser<R> where
R: UnwindSafe,
R: UnwindSafe,
impl<R> RefUnwindSafe for Parser<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,