Skip to content
Closed
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
1 change: 1 addition & 0 deletions crates/parser/src/lexed_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct LexError {

impl<'a> LexedStr<'a> {
pub fn new(edition: Edition, text: &'a str) -> LexedStr<'a> {
#[cfg(feature = "tracing")]
let _p = tracing::info_span!("LexedStr::new").entered();
let mut conv = Converter::new(edition, text);
if let Ok(script) = crate::frontmatter::ScriptSource::parse(text) {
Expand Down
1 change: 1 addition & 0 deletions crates/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub enum TopEntryPoint {

impl TopEntryPoint {
pub fn parse(&self, input: &Input, edition: Edition) -> Output {
#[cfg(feature = "tracing")]
let _p = tracing::info_span!("TopEntryPoint::parse", ?self).entered();
let entry_point: fn(&'_ mut parser::Parser<'_>) = match self {
TopEntryPoint::SourceFile => grammar::entry::top::source_file,
Expand Down
1 change: 1 addition & 0 deletions crates/parser/src/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub enum StrStep<'a> {

impl LexedStr<'_> {
pub fn to_input(&self, edition: Edition) -> crate::Input {
#[cfg(feature = "tracing")]
let _p = tracing::info_span!("LexedStr::to_input").entered();
let mut res = crate::Input::with_capacity(self.len());
let mut was_joint = false;
Expand Down
3 changes: 2 additions & 1 deletion crates/syntax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rustc-hash.workspace = true
rustc-literal-escaper.workspace = true
smol_str.workspace = true
triomphe.workspace = true
tracing.workspace = true
tracing = { workspace = true, optional = true }

parser.workspace = true
stdx.workspace = true
Expand All @@ -33,6 +33,7 @@ rustc_apfloat = "0.2.3"
test-utils.workspace = true

[features]
default = ["tracing"]
in-rust-tree = []

[lints]
Expand Down
2 changes: 2 additions & 0 deletions crates/syntax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ impl ast::Expr {
/// ast::Expr::parse("let fail = true;", Edition::CURRENT).tree();
/// ```
pub fn parse(text: &str, edition: Edition) -> Parse<ast::Expr> {
#[cfg(feature = "tracing")]
let _p = tracing::info_span!("Expr::parse").entered();
let (green, errors) = parsing::parse_text_at(text, parser::TopEntryPoint::Expr, edition);
let root = SyntaxNode::new_root(green.clone());
Expand Down Expand Up @@ -227,6 +228,7 @@ pub use crate::ast::SourceFile;

impl SourceFile {
pub fn parse(text: &str, edition: Edition) -> Parse<SourceFile> {
#[cfg(feature = "tracing")]
let _p = tracing::info_span!("SourceFile::parse").entered();
let (green, errors) = parsing::parse_text(text, edition);
let root = SyntaxNode::new_root(green.clone());
Expand Down
3 changes: 3 additions & 0 deletions crates/syntax/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{SyntaxError, SyntaxTreeBuilder, syntax_node::GreenNode};
pub(crate) use crate::parsing::reparsing::incremental_reparse;

pub(crate) fn parse_text(text: &str, edition: parser::Edition) -> (GreenNode, Vec<SyntaxError>) {
#[cfg(feature = "tracing")]
let _p = tracing::info_span!("parse_text").entered();
let lexed = parser::LexedStr::new(edition, text);
let parser_input = lexed.to_input(edition);
Expand All @@ -23,6 +24,7 @@ pub(crate) fn parse_text_at(
entry: parser::TopEntryPoint,
edition: parser::Edition,
) -> (GreenNode, Vec<SyntaxError>) {
#[cfg(feature = "tracing")]
let _p = tracing::info_span!("parse_text_at").entered();
let lexed = parser::LexedStr::new(edition, text);
let parser_input = lexed.to_input(edition);
Expand All @@ -35,6 +37,7 @@ pub(crate) fn build_tree(
lexed: parser::LexedStr<'_>,
parser_output: parser::Output,
) -> (GreenNode, Vec<SyntaxError>, bool) {
#[cfg(feature = "tracing")]
let _p = tracing::info_span!("build_tree").entered();
let mut builder = SyntaxTreeBuilder::default();

Expand Down
1 change: 1 addition & 0 deletions crates/syntax/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
};

pub(crate) fn validate(root: &SyntaxNode, errors: &mut Vec<SyntaxError>) {
#[cfg(feature = "tracing")]
let _p = tracing::info_span!("parser::validate").entered();
// FIXME:
// * Add unescape validation of raw string literals and raw byte string literals
Expand Down