Skip to content

Commit

Permalink
Merge pull request #200 from ydah/chore2
Browse files Browse the repository at this point in the history
Remove unnecessary assignments to variables
  • Loading branch information
yui-knk authored Nov 5, 2023
2 parents 259afa3 + be2f834 commit 871d3bc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions lib/lrama/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,8 @@ def compute_yydefgoto
# Index is sequence number of nterm, value is state id
# of a default nterm transition destination.
@yydefgoto = Array.new(@states.nterms.count, 0)
h = {}
# Mapping from nterm to next_states
nterm_to_next_states = {}
terms_count = @states.terms.count

@states.states.each do |state|
state.nterm_transitions.each do |shift, next_state|
Expand Down
4 changes: 2 additions & 2 deletions lib/lrama/grammar/code/initial_action_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class InitialActionCode < Code
def reference_to_c(ref)
case
when ref.type == :dollar && ref.value == "$" # $$
str = "yylval"
"yylval"
when ref.type == :at && ref.value == "$" # @$
str = "yylloc"
"yylloc"
when ref.type == :dollar # $n
raise "$#{ref.value} can not be used in initial_action."
when ref.type == :at # @n
Expand Down
4 changes: 2 additions & 2 deletions lib/lrama/grammar/code/printer_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def reference_to_c(ref)
case
when ref.type == :dollar && ref.value == "$" # $$
member = @tag.member
str = "((*yyvaluep).#{member})"
"((*yyvaluep).#{member})"
when ref.type == :at && ref.value == "$" # @$
str = "(*yylocationp)"
"(*yylocationp)"
when ref.type == :dollar # $n
raise "$#{ref.value} can not be used in #{type}."
when ref.type == :at # @n
Expand Down
8 changes: 4 additions & 4 deletions lib/lrama/grammar/code/rule_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ def reference_to_c(ref)
case
when ref.type == :dollar && ref.value == "$" # $$
member = ref.tag.member
str = "(yyval.#{member})"
"(yyval.#{member})"
when ref.type == :at && ref.value == "$" # @$
str = "(yyloc)"
"(yyloc)"
when ref.type == :dollar # $n
i = -ref.position_in_rhs + ref.value
member = ref.tag.member
str = "(yyvsp[#{i}].#{member})"
"(yyvsp[#{i}].#{member})"
when ref.type == :at # @n
i = -ref.position_in_rhs + ref.value
str = "(yylsp[#{i}])"
"(yylsp[#{i}])"
else
raise "Unexpected. #{self}, #{ref}"
end
Expand Down

0 comments on commit 871d3bc

Please sign in to comment.