Skip to content

Commit

Permalink
refactor(regular_expression): correct typo (#5429)
Browse files Browse the repository at this point in the history
Just correct a misspelling.
  • Loading branch information
overlookmotel committed Sep 4, 2024
1 parent c984219 commit e7bd49d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
26 changes: 14 additions & 12 deletions crates/oxc_regular_expression/src/body_parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
body_parser::{diagnostics, reader::Reader, state::State, unicode, unicode_property},
options::ParserOptions,
span::SpanFactory,
surroage_pair,
surrogate_pair,
};

pub struct PatternParser<'a> {
Expand Down Expand Up @@ -1848,14 +1848,15 @@ impl<'a> PatternParser<'a> {
let span_start = self.reader.offset();

if let Some(lead_surrogate) =
self.reader.peek().filter(|&cp| surroage_pair::is_lead_surrogate(cp))
self.reader.peek().filter(|&cp| surrogate_pair::is_lead_surrogate(cp))
{
if let Some(trail_surrogate) =
self.reader.peek2().filter(|&cp| surroage_pair::is_trail_surrogate(cp))
self.reader.peek2().filter(|&cp| surrogate_pair::is_trail_surrogate(cp))
{
self.reader.advance();
self.reader.advance();
let cp = surroage_pair::combine_surrogate_pair(lead_surrogate, trail_surrogate);
let cp =
surrogate_pair::combine_surrogate_pair(lead_surrogate, trail_surrogate);

// [SS:EE] RegExpIdentifierStart :: UnicodeLeadSurrogate UnicodeTrailSurrogate
// It is a Syntax Error if the RegExpIdentifierCodePoint of RegExpIdentifierStart is not matched by the UnicodeIDStart lexical grammar production.
Expand Down Expand Up @@ -1908,15 +1909,16 @@ impl<'a> PatternParser<'a> {
let span_start = self.reader.offset();

if let Some(lead_surrogate) =
self.reader.peek().filter(|&cp| surroage_pair::is_lead_surrogate(cp))
self.reader.peek().filter(|&cp| surrogate_pair::is_lead_surrogate(cp))
{
if let Some(trail_surrogate) =
self.reader.peek2().filter(|&cp| surroage_pair::is_trail_surrogate(cp))
self.reader.peek2().filter(|&cp| surrogate_pair::is_trail_surrogate(cp))
{
self.reader.advance();
self.reader.advance();

let cp = surroage_pair::combine_surrogate_pair(lead_surrogate, trail_surrogate);
let cp =
surrogate_pair::combine_surrogate_pair(lead_surrogate, trail_surrogate);
// [SS:EE] RegExpIdentifierPart :: UnicodeLeadSurrogate UnicodeTrailSurrogate
// It is a Syntax Error if the RegExpIdentifierCodePoint of RegExpIdentifierPart is not matched by the UnicodeIDContinue lexical grammar production.
if !unicode::is_unicode_id_continue(cp) {
Expand Down Expand Up @@ -1956,14 +1958,14 @@ impl<'a> PatternParser<'a> {
// HexLeadSurrogate + HexTrailSurrogate
if let Some(lead_surrogate) = self
.consume_fixed_hex_digits(4)
.filter(|&cp| surroage_pair::is_lead_surrogate(cp))
.filter(|&cp| surrogate_pair::is_lead_surrogate(cp))
{
if self.reader.eat2('\\', 'u') {
if let Some(trail_surrogate) = self
.consume_fixed_hex_digits(4)
.filter(|&cp| surroage_pair::is_trail_surrogate(cp))
.filter(|&cp| surrogate_pair::is_trail_surrogate(cp))
{
return Ok(Some(surroage_pair::combine_surrogate_pair(
return Ok(Some(surrogate_pair::combine_surrogate_pair(
lead_surrogate,
trail_surrogate,
)));
Expand All @@ -1975,7 +1977,7 @@ impl<'a> PatternParser<'a> {
// HexLeadSurrogate
if let Some(lead_surrogate) = self
.consume_fixed_hex_digits(4)
.filter(|&cp| surroage_pair::is_lead_surrogate(cp))
.filter(|&cp| surrogate_pair::is_lead_surrogate(cp))
{
return Ok(Some(lead_surrogate));
}
Expand All @@ -1984,7 +1986,7 @@ impl<'a> PatternParser<'a> {
// HexTrailSurrogate
if let Some(trail_surrogate) = self
.consume_fixed_hex_digits(4)
.filter(|&cp| surroage_pair::is_trail_surrogate(cp))
.filter(|&cp| surrogate_pair::is_trail_surrogate(cp))
{
return Ok(Some(trail_surrogate));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_regular_expression/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{

#[allow(clippy::wildcard_imports)]
use crate::ast::*;
use crate::surroage_pair::{combine_surrogate_pair, is_lead_surrogate, is_trail_surrogate};
use crate::surrogate_pair::{combine_surrogate_pair, is_lead_surrogate, is_trail_surrogate};

impl<'a> Display for RegularExpression<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_regular_expression/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod flag_parser;
mod literal_parser;
mod options;
mod span;
mod surroage_pair;
mod surrogate_pair;

mod generated {
mod derive_clone_in;
Expand Down

0 comments on commit e7bd49d

Please sign in to comment.