+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

refactor(rome_js_parser): Extract shared parser infrastructure #3833

Merged
merged 11 commits into from
Nov 25, 2022
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
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions crates/rome_css_syntax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ impl CssSyntaxKind {
}

impl rome_rowan::SyntaxKind for CssSyntaxKind {
const TOMBSTONE: Self = CssSyntaxKind::TOMBSTONE;
const EOF: Self = EOF;

fn is_unknown(&self) -> bool {
matches!(self, CSS_UNKNOWN)
}
Expand All @@ -78,6 +81,10 @@ impl rome_rowan::SyntaxKind for CssSyntaxKind {
fn is_list(&self) -> bool {
CssSyntaxKind::is_list(*self)
}

fn to_string(&self) -> Option<&'static str> {
CssSyntaxKind::to_string(self)
}
}

impl TryFrom<CssSyntaxKind> for TriviaPieceKind {
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_factory/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::generated::JsSyntaxFactory;
use rome_js_syntax::JsLanguage;
use rome_rowan::TreeBuilder;

mod generated;
pub use crate::generated::JsSyntaxFactory;
pub mod make;

// Re-exported for tests
Expand Down
1 change: 1 addition & 0 deletions crates/rome_js_parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rome_js_syntax = { path = "../rome_js_syntax" }
rome_js_factory = { path = "../rome_js_factory" }
rome_js_unicode_table = { path = "../rome_js_unicode_table" }
rome_rowan = { path = "../rome_rowan" }
rome_parser = { path = "../rome_parser" }
drop_bomb = "0.1.5"
bitflags = "1.3.2"
indexmap = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_parser/src/lexer/buffered_lexer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{LexContext, Lexer, LexerCheckpoint, ReLexContext, TextRange, TokenFlags};
use crate::ParseDiagnostic;
use rome_js_syntax::{JsSyntaxKind, JsSyntaxKind::EOF};
use rome_parser::diagnostic::ParseDiagnostic;
use std::collections::VecDeque;
use std::iter::FusedIterator;

Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_parser/src/lexer/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ParseDiagnostic;
use crate::prelude::*;
use rome_diagnostics::location::FileId;

pub fn invalid_digits_after_unicode_escape_sequence(
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ pub use highlight::*;
pub(crate) use buffered_lexer::BufferedLexer;
pub use rome_js_syntax::*;

use crate::ParseDiagnostic;
use rome_diagnostics::location::FileId;
use rome_js_syntax::JsSyntaxKind::*;
use rome_js_unicode_table::{
is_id_continue, is_id_start, lookup_byte,
Dispatch::{self, *},
};
use rome_parser::diagnostic::ParseDiagnostic;

use self::errors::invalid_digits_after_unicode_escape_sequence;

Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载