pub trait ScriptParser: Send + Sync {
// Required methods
fn parse_expression(
&self,
source: &str,
) -> Result<ScriptExpression, ScriptError>;
fn parse_module(
&self,
source: &str,
) -> Result<Vec<ScriptStatement>, ScriptError>;
}Expand description
A JavaScript parser, as acorn is to micromark’s MDX extensions: md.mdx asks it where
an expression or a block of imports and exports is valid, and keeps only the source.
Required Methods§
Sourcefn parse_expression(
&self,
source: &str,
) -> Result<ScriptExpression, ScriptError>
fn parse_expression( &self, source: &str, ) -> Result<ScriptExpression, ScriptError>
Parse source whole as one expression (JSX included), comments and white space
around it allowed, and describe it.
Sourcefn parse_module(
&self,
source: &str,
) -> Result<Vec<ScriptStatement>, ScriptError>
fn parse_module( &self, source: &str, ) -> Result<Vec<ScriptStatement>, ScriptError>
Parse source as a module and list its top-level statements.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".