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 RBS type signatures for TraceReporter and generate RBS file #497

Merged
merged 1 commit into from
Jan 2, 2025
Merged
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 Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions lib/lrama/trace_reporter.rb
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
22 changes: 22 additions & 0 deletions sig/generated/lrama/trace_reporter.rbs
Original file line number Diff line number Diff line change
@@ -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
Loading