[−][src]Trait arithmetic_parser::grammars::Parse
Unites all necessary parsers to form a complete grammar definition.
The two extension points for a Grammar
are literals and type annotations. They are
defined via Base
type.
A Grammar
also defines a set of supported Features
. This allows to customize which
constructs are parsed.
Most common sets of Features
are covered by Typed
and Untyped
wrappers;
these types allow to not declare Parse
impl explicitly. It is still possible
to define custom Parse
implementations, as shown in the example below.
Examples
#[derive(Debug)] struct IntegerGrammar; impl ParseLiteral for IntegerGrammar { // Implementation skipped... } impl Parse for IntegerGrammar { type Base = Untyped<Self>; const FEATURES: Features = Features::empty(); } // Here's how a grammar can be used. let program = "x = 1 + 2 * 3 + sin(a^3 / b^2);"; let parsed = IntegerGrammar::parse_statements(program)?; println!("{:#?}", parsed);
Associated Types
Loading content...Associated Constants
Loading content...Provided methods
pub fn parse_statements<'a, I>(
input: I
) -> Result<Block<'a, Self::Base>, Error<'a>> where
I: IntoInputSpan<'a>,
Self: Sized,
[src]
input: I
) -> Result<Block<'a, Self::Base>, Error<'a>> where
I: IntoInputSpan<'a>,
Self: Sized,
Parses a list of statements.
pub fn parse_streaming_statements<'a, I>(
input: I
) -> Result<Block<'a, Self::Base>, Error<'a>> where
I: IntoInputSpan<'a>,
Self: Sized,
[src]
input: I
) -> Result<Block<'a, Self::Base>, Error<'a>> where
I: IntoInputSpan<'a>,
Self: Sized,
Parses a potentially incomplete list of statements.