Function optional

Source
pub fn optional<'a, I>(input: I) -> IResult<I, Optional<I>, Error<I>>
where I: Clone + Display + Offset + Input + for<'s> Compare<&'s str> + 'a, <I as Input>::Item: AsChar + Copy, Error<I>: ParseError<I>, for<'s> &'s str: FindToken<<I as Input>::Item>,
Expand description

Parses an optional as defined in the grammar spec.

§Grammar

optional           = '(' text-in-optional+ ')'
text-in-optional   = (- optional-to-escape) | ('\', optional-to-escape)
optional-to-escape = '(' | ')' | '{' | '/' | '\'

§Example

(name)
(with spaces)
(escaped \/\{\()
(no need to escape })
(🦀)

§Errors

§Recoverable Error

  • If input doesn’t start with (.

§Irrecoverable Failure