From 0c551f039e6dd2e3208c9ae65d5e9236a503ab5f Mon Sep 17 00:00:00 2001 From: ydah Date: Wed, 1 Jan 2025 21:27:28 +0900 Subject: [PATCH] Add RBS type signatures for TraceReporter and generate RBS file --- Steepfile | 1 + lib/lrama/trace_reporter.rb | 6 ++++++ sig/generated/lrama/trace_reporter.rbs | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 sig/generated/lrama/trace_reporter.rbs diff --git a/Steepfile b/Steepfile index 0c34556c..b95fab00 100644 --- a/Steepfile +++ b/Steepfile @@ -18,5 +18,6 @@ target :lib do check "lib/lrama/digraph.rb" check "lib/lrama/grammar.rb" check "lib/lrama/options.rb" + check "lib/lrama/trace_reporter.rb" check "lib/lrama/warning.rb" end diff --git a/lib/lrama/trace_reporter.rb b/lib/lrama/trace_reporter.rb index 87c01a4c..7a6fd326 100644 --- a/lib/lrama/trace_reporter.rb +++ b/lib/lrama/trace_reporter.rb @@ -1,27 +1,33 @@ +# rbs_inline: enabled # frozen_string_literal: true module Lrama class TraceReporter + # @rbs (Lrama::Grammar grammar) -> void def initialize(grammar) @grammar = grammar end + # @rbs (**Hash[Symbol, bool] options) -> void def report(**options) _report(**options) end private + # @rbs rules: (bool rules, bool actions, **untyped _) -> void def _report(rules: false, actions: false, **_) report_rules if rules report_actions if actions end + # @rbs () -> void def report_rules puts "Grammar rules:" @grammar.rules.each { |rule| puts rule.display_name } end + # @rbs () -> void def report_actions puts "Grammar rules with actions:" @grammar.rules.each { |rule| puts rule.with_actions } diff --git a/sig/generated/lrama/trace_reporter.rbs b/sig/generated/lrama/trace_reporter.rbs new file mode 100644 index 00000000..2d637df9 --- /dev/null +++ b/sig/generated/lrama/trace_reporter.rbs @@ -0,0 +1,22 @@ +# Generated from lib/lrama/trace_reporter.rb with RBS::Inline + +module Lrama + class TraceReporter + # @rbs (Lrama::Grammar grammar) -> void + def initialize: (Lrama::Grammar grammar) -> void + + # @rbs (**Hash[Symbol, bool] options) -> void + def report: (**Hash[Symbol, bool] options) -> void + + private + + # @rbs rules: (bool rules, bool actions, **untyped _) -> void + def _report: (?rules: untyped, ?actions: untyped, **untyped _) -> untyped + + # @rbs () -> void + def report_rules: () -> void + + # @rbs () -> void + def report_actions: () -> void + end +end