Skip to content

Commit

Permalink
Merge pull request #314 from yui-knk/alias
Browse files Browse the repository at this point in the history
Define alias method for readability
  • Loading branch information
yui-knk authored Dec 24, 2023
2 parents ce8a8d9 + 0cc20ec commit 5109616
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lrama/grammar/rule_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def process_rhs(parameterizing_resolver)
when Lrama::Lexer::Token::Ident
@replaced_rhs << token
when Lrama::Lexer::Token::InstantiateRule
if parameterizing_resolver.defined?(token.s_value)
if parameterizing_resolver.defined?(token.rule_name)
parameterizing = parameterizing_resolver.build_rules(token, @rule_counter, @lhs_tag, line)
@parameterizing_rules = @parameterizing_rules + parameterizing.map(&:rules).flatten
@replaced_rhs = @replaced_rhs + parameterizing.map(&:token).flatten.uniq
Expand Down
4 changes: 4 additions & 0 deletions lib/lrama/lexer/token/instantiate_rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def initialize(s_value:, alias_name: nil, location: nil, args: [])
super s_value: s_value, alias_name: alias_name, location: location
@args = args
end

def rule_name
s_value
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions sig/lrama/lexer/token/instantiate_rule.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Lrama
attr_accessor args: Array[Lexer::Token]

def initialize: (s_value: String, ?alias_name: String, ?location: Location, ?args: Array[Lexer::Token]) -> void
def rule_name: () -> String
end
end
end
Expand Down

0 comments on commit 5109616

Please sign in to comment.