Skip to content

Commit

Permalink
refactor(regular_expression): s/RegExpLiteral/RegularExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Aug 20, 2024
1 parent ed9a1c4 commit 081e2a3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/oxc_regular_expression/examples/parse_literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn main() {
let ret = parser.parse();

match ret {
Ok(ast::RegExpLiteral { pattern, flags, .. }) => {
Ok(ast::RegularExpression { pattern, flags, .. }) => {
println!("✨ {}", pattern.span.source_text(source_text));
println!("{pattern:#?}");
println!("✨ {}", flags.span.source_text(source_text));
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_regular_expression/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use oxc_allocator::{Box, Vec};
use oxc_span::{Atom as SpanAtom, Span};

#[derive(Debug)]
pub struct RegExpLiteral<'a> {
pub struct RegularExpression<'a> {
pub span: Span,
pub pattern: Pattern<'a>,
pub flags: Flags,
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_regular_expression/src/literal_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'a> Parser<'a> {
}
}

pub fn parse(self) -> Result<ast::RegExpLiteral<'a>> {
pub fn parse(self) -> Result<ast::RegularExpression<'a>> {
// Precheck if the source text is a valid regular expression literal
// If valid, parse the pattern and flags with returned span offsets
let (body_start_offset, body_end_offset, flag_start_offset) =
Expand Down Expand Up @@ -54,7 +54,7 @@ impl<'a> Parser<'a> {
)
.parse()?;

Ok(ast::RegExpLiteral {
Ok(ast::RegularExpression {
span: self.span_factory.create(0, self.source_text.len()),
pattern,
flags,
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_regular_expression/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl ParserOptions {
pub fn with_unicode_mode(self) -> ParserOptions {
ParserOptions { unicode_mode: true, ..self }
}

#[must_use]
pub fn with_unicode_sets_mode(self) -> ParserOptions {
ParserOptions { unicode_mode: true, unicode_sets_mode: true, ..self }
Expand Down

0 comments on commit 081e2a3

Please sign in to comment.