Skip to content

Commit bf9f083

Browse files
authored
Merge pull request #1936 from OpenC3/ruby33
Switch to Ruby Prism parser
2 parents 48d8703 + a1541f2 commit bf9f083

File tree

4 files changed

+195
-337
lines changed

4 files changed

+195
-337
lines changed

openc3-cosmos-script-runner-api/app/models/running_script.rb

+8-11
Original file line numberDiff line numberDiff line change
@@ -730,22 +730,21 @@ def self.instrument_script(text, filename, mark_private = false)
730730
instrumented_text = ''
731731

732732
@cancel_instrumentation = false
733-
comments_removed_text = ruby_lex_utils.remove_comments(text)
734-
num_lines = comments_removed_text.num_lines.to_f
733+
num_lines = text.num_lines.to_f
735734
num_lines = 1 if num_lines < 1
736735
instrumented_text =
737736
instrument_script_implementation(ruby_lex_utils,
738-
comments_removed_text,
739-
num_lines,
740-
filename,
741-
mark_private)
737+
text,
738+
num_lines,
739+
filename,
740+
mark_private)
742741

743742
raise OpenC3::StopScript if @cancel_instrumentation
744743
instrumented_text
745744
end
746745

747746
def self.instrument_script_implementation(ruby_lex_utils,
748-
comments_removed_text,
747+
text,
749748
_num_lines,
750749
filename,
751750
mark_private = false)
@@ -755,14 +754,12 @@ def self.instrument_script_implementation(ruby_lex_utils,
755754
instrumented_text = ''
756755
end
757756

758-
ruby_lex_utils.each_lexed_segment(comments_removed_text) do |segment, instrumentable, inside_begin, line_no|
757+
ruby_lex_utils.each_lexed_segment(text) do |segment, instrumentable, inside_begin, line_no|
759758
return nil if @cancel_instrumentation
760759
instrumented_line = ''
761760
if instrumentable
762761
# Add a newline if it's empty to ensure the instrumented code has
763-
# the same number of lines as the original script. Note that the
764-
# segment could have originally had comments but they were stripped in
765-
# ruby_lex_utils.remove_comments
762+
# the same number of lines as the original script
766763
if segment.strip.empty?
767764
instrumented_text << "\n"
768765
next

0 commit comments

Comments
 (0)