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

Get rid of anonymous eval calls #208

Merged
merged 1 commit into from
Jan 11, 2023
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
8 changes: 4 additions & 4 deletions lib/racc/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ def _racc_init_sysvars
# def next_token
# @q.shift
# end
class_eval %{
class_eval <<~RUBY, __FILE__, __LINE__ + 1
def do_parse
#{Racc_Main_Parsing_Routine}(_racc_setup(), false)
end
}
RUBY

# The method to fetch next token.
# If you use #do_parse method, you must implement #next_token.
Expand Down Expand Up @@ -322,11 +322,11 @@ def _racc_do_parse_rb(arg, in_debug)
#
# RECEIVER#METHOD_ID is a method to get next token.
# It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
class_eval %{
class_eval <<~RUBY, __FILE__, __LINE__ + 1
def yyparse(recv, mid)
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
end
}
RUBY

def _racc_yyparse_rb(recv, mid, arg, c_debug)
action_table, action_check, action_default, action_pointer,
Expand Down
4 changes: 2 additions & 2 deletions test/assets/cast.y
Original file line number Diff line number Diff line change
Expand Up @@ -636,14 +636,14 @@ restrict return short signed sizeof static struct switch typedef union

def self.feature(name)
attr_writer "#{name}_enabled"
class_eval <<-EOS
class_eval <<~RUBY, __FILE__, __LINE__ + 1
def enable_#{name}
@#{name}_enabled = true
end
def #{name}_enabled?
@#{name}_enabled
end
EOS
RUBY
end
private_class_method :feature

Expand Down
4 changes: 2 additions & 2 deletions test/regress/cast
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ restrict return short signed sizeof static struct switch typedef union

def self.feature(name)
attr_writer "#{name}_enabled"
class_eval <<-EOS
class_eval <<~RUBY, __FILE__, __LINE__ + 1
def enable_#{name}
@#{name}_enabled = true
end
def #{name}_enabled?
@#{name}_enabled
end
EOS
RUBY
end
private_class_method :feature

Expand Down