Trait glsl_lang::parse::parsable::Parsable

source ·
pub trait Parsable: Sized {
    // Required methods
    fn parse_with_options<'i>(
        source: &'i str,
        opts: &ParseOptions,
    ) -> Result<(Self, ParseContext), ParseError<<DefaultLexer<'i> as HasLexerError>::Error>>;
    fn parse_with_context<'i>(
        source: &'i str,
        ctx: &ParseContext,
    ) -> Result<(Self, ParseContext), ParseError<<DefaultLexer<'i> as HasLexerError>::Error>>;

    // Provided method
    fn parse(
        source: &str,
    ) -> Result<Self, ParseError<<DefaultLexer<'_> as HasLexerError>::Error>> { ... }
}
Expand description

A parsable is something we can parse either directly, or embedded in some other syntax structure.

This allows us to parse specific AST items even though we don’t export a LALR parser for it. Due to the way it is currently implemented, we have to generate extra code around the input, thus, if you are matching on span positions, you will get a different result than if using the parser directly.

Required Methods§

source

fn parse_with_options<'i>( source: &'i str, opts: &ParseOptions, ) -> Result<(Self, ParseContext), ParseError<<DefaultLexer<'i> as HasLexerError>::Error>>

Parse the input source with the given options

source

fn parse_with_context<'i>( source: &'i str, ctx: &ParseContext, ) -> Result<(Self, ParseContext), ParseError<<DefaultLexer<'i> as HasLexerError>::Error>>

Parse the input source with the given context

Provided Methods§

source

fn parse( source: &str, ) -> Result<Self, ParseError<<DefaultLexer<'_> as HasLexerError>::Error>>

Parse the input source

Object Safety§

This trait is not object safe.

Implementors§