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

Add logging for full-moon parsing and AST conversion #157

Merged
merged 1 commit into from
Nov 25, 2023
Merged
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
20 changes: 17 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use full_moon::ast::Ast;
use crate::{
ast_converter::{AstConverter, ConvertError},
nodes::*,
utils::Timer,
};

#[derive(Clone, Debug, Default, PartialEq, Eq)]
Expand All @@ -14,9 +15,22 @@ pub struct Parser {

impl Parser {
pub fn parse(&self, code: &str) -> Result<Block, ParserError> {
full_moon::parse(code)
.map_err(ParserError::parsing)
.and_then(|ast| self.convert_ast(ast).map_err(ParserError::converting))
let full_moon_parse_timer = Timer::now();
let parse_result = full_moon::parse(code);
log::trace!(
"full-moon parsing done in {}",
full_moon_parse_timer.duration_label()
);
parse_result.map_err(ParserError::parsing).and_then(|ast| {
log::trace!("start converting full-moon AST");
let conversion_timer = Timer::now();
let block = self.convert_ast(ast).map_err(ParserError::converting);
log::trace!(
" ⨽ completed AST conversion in {}",
conversion_timer.duration_label()
);
block
})
}

pub fn preserve_tokens(mut self) -> Self {
Expand Down
Loading