Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(parser): shorten lexer code #4562

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/lexer/identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl<'a> Lexer<'a> {
/// Handle private identifier whose first byte is not an ASCII identifier start byte.
#[cold]
fn private_identifier_not_ascii_id(&mut self) -> Kind {
let b = self.source.peek_byte().unwrap();
let b = self.peek_byte().unwrap();
if !b.is_ascii() {
let c = self.peek_char().unwrap();
if is_identifier_start_unicode(c) {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/lexer/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'a> Lexer<'a> {
/// `JSXIdentifier` `IdentifierPart`
/// `JSXIdentifier` [no `WhiteSpace` or Comment here] -
pub(crate) fn continue_lex_jsx_identifier(&mut self) -> Option<Token> {
if self.source.peek_byte() != Some(b'-') {
if self.peek_byte() != Some(b'-') {
return None;
}
self.consume_char();
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl<'a> Lexer<'a> {
let offset = self.offset();
self.token.start = offset;

let Some(byte) = self.source.peek_byte() else {
let Some(byte) = self.peek_byte() else {
return Kind::Eof;
};

Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/lexer/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ macro_rules! handle_string_literal_escape {

// Consume bytes until reach end of string, line break, or another escape
let chunk_start = $lexer.source.position();
while let Some(b) = $lexer.source.peek_byte() {
while let Some(b) = $lexer.peek_byte() {
match b {
b if !$table.matches(b) => {
// SAFETY: A byte is available, as we just peeked it.
Expand Down