chore(parser): parse regular expression in example

This commit is contained in:
Boshen 2024-08-28 18:12:08 +08:00
parent b43a3948a1
commit 5e27798dc3
No known key found for this signature in database
GPG key ID: 9C7A8C8AB22BEBD1

View file

@ -2,7 +2,7 @@
use std::{env, path::Path};
use oxc_allocator::Allocator;
use oxc_parser::Parser;
use oxc_parser::{ParseOptions, Parser};
use oxc_span::SourceType;
// Instruction:
@ -17,7 +17,9 @@ fn main() -> Result<(), String> {
let allocator = Allocator::default();
let source_type = SourceType::from_path(path).unwrap();
let now = std::time::Instant::now();
let ret = Parser::new(&allocator, &source_text, source_type).parse();
let ret = Parser::new(&allocator, &source_text, source_type)
.with_options(ParseOptions { parse_regular_expression: true, ..ParseOptions::default() })
.parse();
let elapsed_time = now.elapsed();
println!("{}ms.", elapsed_time.as_millis());