Skip to content

Commit

Permalink
Merge pull request #295 from yui-knk/rename_args
Browse files Browse the repository at this point in the history
Rename `ParameterizingRuleBuilder#args` to `#parameters`
  • Loading branch information
yui-knk authored Dec 15, 2023
2 parents 6655bcb + d12356b commit edc1463
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions lib/lrama/grammar/parameterizing_rule_builder.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module Lrama
class Grammar
class ParameterizingRuleBuilder
attr_reader :name, :args, :rhs
attr_reader :name, :parameters, :rhs

def initialize(name, args, rhs)
def initialize(name, parameters, rhs)
@name = name
@args = args
@parameters = parameters
@rhs = rhs
@required_args_count = args.count
@required_parameters_count = parameters.count
end

def build_rules(token, rule_counter, lhs_tag, line)
Expand All @@ -23,8 +23,8 @@ def build_rules(token, rule_counter, lhs_tag, line)
private

def validate_argument_number!(token)
unless @required_args_count == token.args.count
raise "Invalid number of arguments. expect: #{@required_args_count} actual: #{token.args.count}"
unless @required_parameters_count == token.args.count
raise "Invalid number of arguments. expect: #{@required_parameters_count} actual: #{token.args.count}"
end
end

Expand All @@ -34,7 +34,7 @@ def lhs_token(token)

def rhs_token(token, rhs)
rhs.symbols.map do |sym|
idx = @args.index { |arg| arg.s_value == sym.s_value }
idx = @parameters.index { |parameter| parameter.s_value == sym.s_value }
if idx.nil?
sym
else
Expand Down
6 changes: 3 additions & 3 deletions sig/lrama/grammar/parameterizing_rule_builder.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ module Lrama
class Grammar
class ParameterizingRuleBuilder
attr_reader name: String
attr_reader args: Array[Lexer::Token]
attr_reader parameters: Array[Lexer::Token]
attr_reader rhs: Array[Grammar::ParameterizingRuleRhsBuilder]

@required_args_count: Integer
@required_parameters_count: Integer

def initialize: (String name, Array[Lexer::Token] args, Array[Grammar::ParameterizingRuleRhsBuilder] rhs) -> void
def initialize: (String name, Array[Lexer::Token] parameters, Array[Grammar::ParameterizingRuleRhsBuilder] rhs) -> void
def build_rules: (Lexer::Token::Parameterizing token, Counter rule_counter, untyped lhs_tag, Integer? line) -> Grammar::ParameterizingRule

private
Expand Down

0 comments on commit edc1463

Please sign in to comment.