Skip to content

Commit

Permalink
Rename on_comment_parsed method to on_comment for consistency acr…
Browse files Browse the repository at this point in the history
…oss grammar traits
  • Loading branch information
jsinger67 committed Dec 22, 2024
1 parent 88f6eaa commit 4336978
Show file tree
Hide file tree
Showing 22 changed files with 65 additions and 65 deletions.
2 changes: 1 addition & 1 deletion crates/parol-ls/src/parol_ls_grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ impl ParolLsGrammarTrait for ParolLsGrammar {
Ok(())
}

fn on_comment_parsed(&mut self, token: Token<'_>) {
fn on_comment(&mut self, token: Token<'_>) {
self.comments.push_back(OwnedToken(token.into_owned()))
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/parol-ls/src/parol_ls_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub trait ParolLsGrammarTrait {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'_>) {}
fn on_comment(&mut self, _token: Token<'_>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -3235,7 +3235,7 @@ impl<'t> UserActionsTrait<'t> for ParolLsGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
16 changes: 8 additions & 8 deletions crates/parol/src/generators/grammar_type_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct GrammarTypeInfo {

/// The type id of the *semantic actions trait* that contains functions for each non-terminal of
/// the given grammar.
/// It also contains the function 'on_comment_parsed' that is called when a comment is parsed.
/// It also contains the function 'on_comment' that is called when a comment is parsed.
/// The user action trait is created in global scope.
/// The type name is <`GrammarName`>GrammarTrait
pub(crate) semantic_actions_trait_id: Option<SymbolId>,
Expand All @@ -48,8 +48,8 @@ pub struct GrammarTypeInfo {

/// The type id of the user action trait that contains only two functions.
/// The first calls the adapter functions in the adapter struct.
/// The second function 'on_comment_parsed' is called when a comment is parsed. This function
/// calls the user action function 'on_comment_parsed' in the semantic actions trait.
/// The second function 'on_comment' is called when a comment is parsed. This function
/// calls the user action function 'on_comment' in the semantic actions trait.
/// This trait created in global scope.
/// The type name is always 'UserActionsTrait' and it is the interface called by the parser.
pub(crate) parser_interface_trait_id: Option<SymbolId>,
Expand Down Expand Up @@ -130,14 +130,14 @@ impl GrammarTypeInfo {
.symbol_table
.insert_global_type("Token", TypeEntrails::Token)?;

// Insert the fix 'on_comment_parsed' function into the semantic actions trait to avoid name
// Insert the fix 'on_comment' function into the semantic actions trait to avoid name
// clashes with a possible non-terminal 'OnCommentParsed'
let on_comment_parsed_id = me.symbol_table.insert_type(
let on_comment_id = me.symbol_table.insert_type(
me.semantic_actions_trait_id.unwrap(),
"on_comment_parsed",
"on_comment",
TypeEntrails::Function(Function::default()),
)?;
let function_type_id = me.symbol_table.symbol_as_type(on_comment_parsed_id).my_id();
let function_type_id = me.symbol_table.symbol_as_type(on_comment_id).my_id();
me.symbol_table.insert_instance(
function_type_id,
"token",
Expand Down Expand Up @@ -243,7 +243,7 @@ impl GrammarTypeInfo {
)
.symbols
.iter()
.filter(|s| self.symbol_table.symbol(**s).name() != "on_comment_parsed")
.filter(|s| self.symbol_table.symbol(**s).name() != "on_comment")
.cloned()
.collect::<Vec<_>>()
}
Expand Down
10 changes: 5 additions & 5 deletions crates/parol/src/generators/template_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ impl std::fmt::Display for UserTraitData<'_> {
/// All functions have default implementations."
)?;
let user_trait_functions = user_trait_functions.join("\n\n");
let on_comment_parsed_comment = r"
let on_comment_comment = r"
/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
";
f.write_fmt(ume::ume! {
pub trait #trait_name #lifetime {
#user_trait_functions
#on_comment_parsed_comment
fn on_comment_parsed(&mut self, _token: Token #anonymous_lifetime) {}
#on_comment_comment
fn on_comment(&mut self, _token: Token #anonymous_lifetime) {}
}
})?;

Expand Down Expand Up @@ -351,8 +351,8 @@ impl std::fmt::Display for UserTraitData<'_> {
}
}
#blank_line
fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
})?;
Expand Down
6 changes: 3 additions & 3 deletions crates/parol/src/parser/parol_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ pub trait ParolGrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2950,7 +2950,7 @@ impl<'t> UserActionsTrait<'t> for ParolGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
2 changes: 1 addition & 1 deletion crates/parol_runtime/src/lr_parser/parser_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<'t> LRParser<'t> {
self.parse_tree_stack.push(LRParseTree::Terminal(t.clone()));
}
if t.is_comment_token() {
user_actions.on_comment_parsed(t);
user_actions.on_comment(t);
}
Ok::<(), ParolError>(())
})
Expand Down
2 changes: 1 addition & 1 deletion crates/parol_runtime/src/parser/parser_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ impl<'t> LLKParser<'t> {
})?;
}
if t.is_comment_token() {
user_actions.on_comment_parsed(t);
user_actions.on_comment(t);
}
Ok::<(), ParolError>(())
})
Expand Down
2 changes: 1 addition & 1 deletion crates/parol_runtime/src/parser/user_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ pub trait UserActionsTrait<'t> {
/// This can improve handling of comments that are not captured by the grammar definition
/// itself.
///
fn on_comment_parsed(&mut self, _token: Token<'t>);
fn on_comment(&mut self, _token: Token<'t>);
}
6 changes: 3 additions & 3 deletions examples/basic_interpreter/basic_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ pub trait BasicGrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2854,7 +2854,7 @@ impl<'t> UserActionsTrait<'t> for BasicGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/boolean_parser/boolean_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub trait BooleanGrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1271,7 +1271,7 @@ impl<'t> UserActionsTrait<'t> for BooleanGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/calc/calc_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub trait CalcGrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2099,7 +2099,7 @@ impl<'t> UserActionsTrait<'t> for CalcGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/calc_lr/calc_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub trait CalcGrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2096,7 +2096,7 @@ impl<'t> UserActionsTrait<'t> for CalcGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/json_parser/json_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub trait JsonGrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -801,7 +801,7 @@ impl<'t> UserActionsTrait<'t> for JsonGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/keywords/keywords_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub trait KeywordsGrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -557,7 +557,7 @@ impl<'t> UserActionsTrait<'t> for KeywordsGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/keywords2/keywords_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub trait KeywordsGrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -557,7 +557,7 @@ impl<'t> UserActionsTrait<'t> for KeywordsGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/list/list_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub trait ListGrammarTrait {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'_>) {}
fn on_comment(&mut self, _token: Token<'_>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -398,7 +398,7 @@ impl<'t> UserActionsTrait<'t> for ListGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/list_lr/list_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub trait ListGrammarTrait {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'_>) {}
fn on_comment(&mut self, _token: Token<'_>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -321,7 +321,7 @@ impl<'t> UserActionsTrait<'t> for ListGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/oberon2/oberon2_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ pub trait Oberon2GrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -7247,7 +7247,7 @@ impl<'t> UserActionsTrait<'t> for Oberon2GrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/oberon_0/oberon_0_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ pub trait Oberon0GrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -4847,7 +4847,7 @@ impl<'t> UserActionsTrait<'t> for Oberon0GrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/scanner_states/scanner_states_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub trait ScannerStatesGrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -666,7 +666,7 @@ impl<'t> UserActionsTrait<'t> for ScannerStatesGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
6 changes: 3 additions & 3 deletions examples/scanner_states_lr/scanner_states_grammar_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub trait ScannerStatesGrammarTrait<'t> {

/// This method provides skipped language comments.
/// If you need comments please provide your own implementation of this method.
fn on_comment_parsed(&mut self, _token: Token<'t>) {}
fn on_comment(&mut self, _token: Token<'t>) {}
}

// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -693,7 +693,7 @@ impl<'t> UserActionsTrait<'t> for ScannerStatesGrammarAuto<'t, '_> {
}
}

fn on_comment_parsed(&mut self, token: Token<'t>) {
self.user_grammar.on_comment_parsed(token)
fn on_comment(&mut self, token: Token<'t>) {
self.user_grammar.on_comment(token)
}
}
Loading

0 comments on commit 4336978

Please sign in to comment.