Skip to content

Commit

Permalink
add Debug to TopLevelGrammar
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Sep 25, 2024
1 parent f50f002 commit c524852
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion parser/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
/// This represents a collection of grammars, with a designated
/// "start" grammar at first position.
/// Grammars can refer to each other via GrammarRef nodes.
#[derive(Serialize, Deserialize, Clone)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct TopLevelGrammar {
pub grammars: Vec<GrammarWithLexer>,
pub max_tokens: Option<usize>,
Expand Down Expand Up @@ -56,6 +56,12 @@ pub struct GrammarWithLexer {
pub allow_invalid_utf8: bool,
}

impl Debug for GrammarWithLexer {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "GrammarWithLexer [{} nodes]", self.nodes.len())
}
}

#[derive(Serialize, Deserialize, Clone, PartialEq)]
pub enum Node {
// Terminals:
Expand Down

0 comments on commit c524852

Please sign in to comment.