Struct LanguageEnv

Source
pub struct LanguageEnv<'a, I> { /* private fields */ }
Expand description

A type containing parsers for a specific language. For some parsers there are two version where the parser which ends with a _ is a variant which does not skip whitespace and comments after parsing the token itself.

Implementations§

Source§

impl<'a, I> LanguageEnv<'a, I>
where I: Stream<Token = char>, I::Error: ParseError<I::Token, I::Range, I::Position>,

Source

pub fn new<A, B, C, D, E, F, G>( def: LanguageDef<A, B, C, D, E, F, G>, ) -> LanguageEnv<'a, I>
where A: Parser<I, Output = char> + 'a, B: Parser<I, Output = char> + 'a, C: Parser<I, Output = char> + 'a, D: Parser<I, Output = char> + 'a, E: Parser<I, Output = ()> + 'a, F: Parser<I, Output = ()> + 'a, G: Parser<I, Output = ()> + 'a,

Constructs a new parser from a language defintion

Source

pub fn lex<'b, P>(&'b self, p: P) -> Lex<'a, 'b, P, I>
where P: Parser<I> + 'b,

Creates a lexing parser from p

Source

pub fn white_space<'b>(&'b self) -> WhiteSpace<'a, 'b, I>

Skips spaces and comments

Source

pub fn symbol<'b>( &'b self, name: &'static str, ) -> Lex<'a, 'b, Expected<With<TokensCmp<fn(char, char) -> bool, Chars<'static>, I>, Value<I, &'static str>>, &'static str>, I>

Parses a symbol, lexing the stream if it is successful

Source

pub fn identifier<'b>(&'b self) -> LexLanguageParser<'a, 'b, I, String>

Parses an identifier, failing if it parses something that is a reserved identifier

Source

pub fn identifier_<'b>(&'b self) -> LanguageParser<'a, 'b, I, String>

Source

pub fn range_identifier<'b>(&'b self) -> LexLanguageParser<'a, 'b, I, &'a str>
where I: RangeStream<Range = &'a str>,

Parses an identifier, failing if it parses something that is a reserved identifier

Source

pub fn range_identifier_<'b>(&'b self) -> LanguageParser<'a, 'b, I, &'a str>
where I: RangeStream<Range = &'a str>,

Source

pub fn reserved<'b>(&'b self, name: &'static str) -> Reserved<'a, 'b, I>
where I::Range: 'b,

Parses the reserved identifier name

Source

pub fn op<'b>(&'b self) -> LexLanguageParser<'a, 'b, I, String>

Parses an operator, failing if it parses something that is a reserved operator

Source

pub fn op_<'b>(&'b self) -> LanguageParser<'a, 'b, I, String>

Source

pub fn range_op<'b>(&'b self) -> LexLanguageParser<'a, 'b, I, &'a str>
where I: RangeStream<Range = &'a str>,

Parses an identifier, failing if it parses something that is a reserved identifier

Source

pub fn range_op_<'b>(&'b self) -> LanguageParser<'a, 'b, I, &'a str>
where I: RangeStream<Range = &'a str>,

Source

pub fn reserved_op<'b>( &'b self, name: &'static str, ) -> Lex<'a, 'b, Reserved<'a, 'b, I>, I>
where I::Range: 'b,

Parses the reserved operator name

Source

pub fn reserved_op_<'b>(&'b self, name: &'static str) -> Reserved<'a, 'b, I>
where I::Range: 'b,

Source

pub fn char_literal<'b>(&'b self) -> LexLanguageParser<'a, 'b, I, char>

Parses a character literal taking escape sequences into account

Source

pub fn char_literal_<'b>(&'b self) -> LanguageParser<'a, 'b, I, char>

Source

pub fn string_literal<'b>(&'b self) -> LexLanguageParser<'a, 'b, I, String>

Parses a string literal taking character escapes into account

Source

pub fn string_literal_<'b>(&'b self) -> LanguageParser<'a, 'b, I, String>

Source

pub fn angles<'b, P>(&'b self, parser: P) -> BetweenChar<'a, 'b, P, I>
where P: Parser<I>, I::Range: 'b,

Parses p inside angle brackets < p >

Source

pub fn braces<'b, P>(&'b self, parser: P) -> BetweenChar<'a, 'b, P, I>
where P: Parser<I>, I::Range: 'b,

Parses p inside braces { p }

Source

pub fn brackets<'b, P>(&'b self, parser: P) -> BetweenChar<'a, 'b, P, I>
where P: Parser<I>, I::Range: 'b,

Parses p inside brackets [ p ]

Source

pub fn parens<'b, P>(&'b self, parser: P) -> BetweenChar<'a, 'b, P, I>
where P: Parser<I>, I::Range: 'b,

Parses p inside parentheses ( p )

Source

pub fn integer<'b>(&'b self) -> LexLanguageParser<'a, 'b, I, i64>

Parses an integer

Source

pub fn integer_<'b>(&'b self) -> LanguageParser<'a, 'b, I, i64>

Source

pub fn float<'b>(&'b self) -> LexLanguageParser<'a, 'b, I, f64>

Parses a floating point number

Source

pub fn float_<'b>(&'b self) -> LanguageParser<'a, 'b, I, f64>

Auto Trait Implementations§

§

impl<'a, I> !Freeze for LanguageEnv<'a, I>

§

impl<'a, I> !RefUnwindSafe for LanguageEnv<'a, I>

§

impl<'a, I> !Send for LanguageEnv<'a, I>

§

impl<'a, I> !Sync for LanguageEnv<'a, I>

§

impl<'a, I> Unpin for LanguageEnv<'a, I>

§

impl<'a, I> !UnwindSafe for LanguageEnv<'a, I>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.