pub fn parse_with_file_id(
    flags: ParserFlags,
    source: &str,
    ctx: &mut ast::Context,
    file_id: u32,
) -> Result<ast::NodePtr, ParseError> {
    let buf = NullTerminatedBuf::from_str_check(source);
    let parsed = ParsedJS::parse(flags, &buf);
    if let Some(ast) = parsed.to_ast(ctx, file_id) {
        Ok(ast)
    } else {
        let (loc, msg) = parsed.first_error().unwrap();
        Err(ParseError { loc, msg })
    }
}
/// This is a simple function that is intended to be used mostly for testing.
/// When there ar errors, it returns only the first error.
/// It checks if the input is already null-terminated and avoids making the copy in that case.
/// Note that if the null terminator is truly present in the input, it would parse successfully
/// what ought to be an error.
This is a simple function that is intended to be used mostly for testing.
When there ar errors, it returns only the first error.
It checks if the input is already null-terminated and avoids making the copy in that case.
Note that if the null terminator is truly present in the input, it would parse successfully
what ought to be an error.
This is a simple function that is intended to be used mostly for testing . When there ar errors it returns only the first error . It checks if the input is already null - terminated and avoids making the copy in that case . Note that if the null terminator is truly present in the input it would parse successfully what ought to be an error .
pub fn parse_with_file_id(
    flags: ParserFlags,
    source: &str,
    ctx: &mut ast::Context,
    file_id: u32,
) -> Result<ast::NodePtr, ParseError> {
    let buf = NullTerminatedBuf::from_str_check(source);
    let parsed = ParsedJS::parse(flags, &buf);
    if let Some(ast) = parsed.to_ast(ctx, file_id) {
        Ok(ast)
    } else {
        let (loc, msg) = parsed.first_error().unwrap();
        Err(ParseError { loc, msg })
    }
}
pub fn parse_with_file_id ( flags : ParserFlags , source : & str , ctx : & mut ast :: Context , file_id : u32 , ) -> Result < ast :: NodePtr , ParseError > { let buf = NullTerminatedBuf :: from_str_check ( source ) ; let parsed = ParsedJS :: parse ( flags , & buf ) ; if let Some ( ast ) = parsed . to_ast ( ctx , file_id ) { Ok ( ast ) } else { let ( loc , msg ) = parsed . first_error ( ) . unwrap ( ) ; Err ( ParseError { loc , msg } ) } }
This is a simple function that is intended to be used mostly for testing.
This is a simple function that is intended to be used mostly for testing .
flags
ParserFlags
source
&str
ctx
&mut ast::Context
file_id
u32
flags
ParserFlags
source
&str
ctx
&mut ast::Context
file_id
u32