rbx-trepanning 0.0.7-universal-rubinius-1.2 → 0.0.8-universal-rubinius-1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/ChangeLog +236 -0
  2. data/NEWS +16 -0
  3. data/Rakefile +60 -11
  4. data/app/breakpoint.rb +5 -1
  5. data/app/brkptmgr.rb +5 -0
  6. data/app/cmd_parse.kpeg +225 -0
  7. data/app/cmd_parse.rb +209 -0
  8. data/app/cmd_parser.rb +1894 -0
  9. data/app/default.rb +0 -1
  10. data/app/method.rb +12 -8
  11. data/app/options.rb +2 -9
  12. data/app/validate.rb +2 -2
  13. data/bin/trepanx +3 -3
  14. data/lib/trepanning.rb +9 -6
  15. data/processor/breakpoint.rb +5 -19
  16. data/processor/command/alias.rb +4 -5
  17. data/processor/command/base/submgr.rb +2 -2
  18. data/processor/command/break.rb +44 -66
  19. data/processor/command/condition.rb +2 -0
  20. data/processor/command/continue.rb +11 -41
  21. data/processor/command/disassemble.rb +2 -0
  22. data/processor/command/eval.rb +20 -8
  23. data/processor/command/exit.rb +3 -2
  24. data/{doc → processor/command/help}/.gitignore +0 -0
  25. data/processor/command/help/command.txt +48 -0
  26. data/processor/command/help/filename.txt +40 -0
  27. data/processor/command/help/location.txt +37 -0
  28. data/processor/command/help.rb +52 -73
  29. data/processor/command/info_subcmd/breakpoints.rb +35 -13
  30. data/processor/command/info_subcmd/files.rb +34 -25
  31. data/processor/command/info_subcmd/frame.rb +67 -0
  32. data/processor/command/kill.rb +0 -1
  33. data/processor/command/restart.rb +8 -8
  34. data/processor/command/save.rb +58 -0
  35. data/processor/command/set_subcmd/trace_subcmd/buffer.rb +1 -1
  36. data/processor/command/set_subcmd/trace_subcmd/print.rb +1 -1
  37. data/processor/command/show.rb +7 -6
  38. data/processor/command/step.rb +16 -3
  39. data/processor/command/tbreak.rb +1 -1
  40. data/processor/disassemble.rb +1 -1
  41. data/processor/help.rb +20 -0
  42. data/processor/load_cmds.rb +53 -4
  43. data/processor/location.rb +47 -1
  44. data/processor/main.rb +4 -9
  45. data/processor/mock.rb +3 -3
  46. data/processor/running.rb +16 -17
  47. data/processor/validate.rb +171 -159
  48. data/rbx-trepanning.gemspec +1 -1
  49. data/test/example/debugger-stop.rb +16 -0
  50. data/test/functional/test-break-name.rb +1 -1
  51. data/test/functional/test-eval.rb +115 -0
  52. data/test/functional/test-tbreak.rb +1 -1
  53. data/test/integration/helper.rb +5 -2
  54. data/test/unit/cmd-helper.rb +1 -1
  55. data/test/unit/test-app-cmd_parse.rb +97 -0
  56. data/test/unit/test-app-cmd_parser.rb +22 -0
  57. data/test/unit/test-app-options.rb +1 -0
  58. data/test/unit/test-app-validate.rb +2 -2
  59. data/test/unit/test-cmd-break.rb +47 -5
  60. data/test/unit/test-completion.rb +2 -1
  61. data/test/unit/test-proc-location.rb +11 -0
  62. data/test/unit/test-proc-validate.rb +68 -30
  63. metadata +26 -11
  64. data/doc/debugger.html +0 -108
data/ChangeLog CHANGED
@@ -1,3 +1,239 @@
1
+ 2011-03-12 rocky <rockyb@rubyforge.org>
2
+
3
+ * processor/command/help.rb, processor/command/help/command.txt,
4
+ processor/command/help/filename.txt,
5
+ processor/command/help/filenames.txt,
6
+ processor/command/help/location.txt: sync with rb-trepanning.
7
+
8
+ 2011-03-12 rocky <rockyb@rubyforge.org>
9
+
10
+ * processor/command/help.rb, processor/command/help/command.txt,
11
+ processor/command/help/filenames.txt,
12
+ processor/command/help/syntax.txt, processor/help.rb,
13
+ test/unit/test-completion.rb: Start multi-level "help syntax"
14
+
15
+ 2011-03-12 rocky <rockyb@rubyforge.org>
16
+
17
+ * processor/command/info_subcmd/files.rb: info files: iseq -> cm.
18
+ Document it.
19
+
20
+ 2011-03-12 rocky <rockyb@rubyforge.org>
21
+
22
+ * processor/command/info_subcmd/files.rb: Show compiled method
23
+ status in "info files" .
24
+
25
+ 2011-03-12 rocky <rockyb@rubyforge.org>
26
+
27
+ * processor/command/info_subcmd/files.rb, processor/location.rb,
28
+ processor/main.rb, processor/validate.rb: Handle more cases of
29
+ file/line breakpoints. Improve "info files" more.
30
+
31
+ 2011-03-11 rocky <rockyb@rubyforge.org>
32
+
33
+ * app/method.rb, processor/command/info_subcmd/files.rb,
34
+ processor/location.rb, processor/validate.rb: Better "info file"
35
+ display. Start to handle filenames other than current one by using
36
+ LineCache saving the top compile method.
37
+
38
+ 2011-03-11 rocky <rockyb@rubyforge.org>
39
+
40
+ * app/cmd_parse.kpeg, app/cmd_parser.rb,
41
+ processor/command/help/filenames.txt,
42
+ processor/command/help/location.txt,
43
+ test/unit/test-app-cmd_parser.rb: Clean up filename parsing
44
+ somewhat.
45
+
46
+ 2011-03-10 rocky <rockyb@rubyforge.org>
47
+
48
+ * app/cmd_parse.rb, app/cmd_parser.rb, processor/command/help.rb,
49
+ processor/command/help/.gitignore,
50
+ processor/command/help/location.txt,
51
+ processor/command/help/syntax.txt: Start moving text help, to text
52
+ file.
53
+
54
+ 2011-03-10 rocky <rockyb@rubyforge.org>
55
+
56
+ * processor/command/save.rb, processor/validate.rb,
57
+ test/unit/test-proc-validate.rb: Cutover to KPEG for breakpoints
58
+ complete. What a relief! save.rb: save debugger settings for
59
+ restart.
60
+
61
+ 2011-03-10 rocky <rockyb@rubyforge.org>
62
+
63
+ * app/breakpoint.rb, app/cmd_parse.kpeg, app/cmd_parse.rb,
64
+ app/cmd_parser.rb, lib/trepanning.rb, processor/breakpoint.rb,
65
+ processor/command/break.rb, processor/command/condition.rb,
66
+ processor/command/continue.rb,
67
+ processor/command/info_subcmd/breakpoints.rb,
68
+ processor/command/tbreak.rb, processor/mock.rb,
69
+ processor/validate.rb, test/unit/cmd-helper.rb,
70
+ test/unit/test-app-cmd_parse.rb, test/unit/test-cmd-break.rb:
71
+ Towards getting breakpoint refactoring complete.
72
+
73
+ 2011-03-09 rocky <rockyb@rubyforge.org>
74
+
75
+ Merge branch 'master' of github.com:rocky/rbx-trepanning
76
+
77
+ 2011-03-09 rocky <rockyb@rubyforge.org>
78
+
79
+ * processor/load_cmds.rb, processor/main.rb: Small changes.
80
+
81
+ 2011-03-08 rocky <rockyb@rubyforge.org>
82
+
83
+ * Rakefile, processor/command/info_subcmd/frame.rb: Add "info frame"
84
+ command Revise "rake cmd_parse" to use TempDir.
85
+
86
+ 2011-03-07 rocky <rockyb@rubyforge.org>
87
+
88
+ Merge branch 'master' of github.com:rocky/rbx-trepanning
89
+
90
+ 2011-03-06 rocky <rockyb@rubyforge.org>
91
+
92
+ * Rakefile, app/cmd_parse.kpeg, app/cmd_parser.rb,
93
+ processor/location.rb, processor/main.rb,
94
+ test/example/debugger-stop.rb, test/integration/helper.rb,
95
+ test/unit/test-proc-location.rb: Largely sync with rb-trepanning -
96
+ no bug fixes or completed enhancements cmd_parse.kpeg: fill out for
97
+ location. More complete. Rakefile: add descriptions to some tasks
98
+ helper.rb: add feed_input option test: test some bugs that were in
99
+ rb-trepanning but here.
100
+
101
+ 2011-03-05 rvm <rocky@gnu.org>
102
+
103
+ * test/unit/test-app-options.rb: Remove tempfile in unit test
104
+
105
+ 2011-03-05 rvm <rocky@gnu.org>
106
+
107
+ * app/default.rb, app/options.rb, bin/trepanx, lib/trepanning.rb,
108
+ processor/command/base/submgr.rb, processor/command/restart.rb,
109
+ processor/command/set_subcmd/trace_subcmd/buffer.rb,
110
+ processor/command/set_subcmd/trace_subcmd/print.rb,
111
+ processor/load_cmds.rb: Save/restore of debugger state across a
112
+ restart finally works!
113
+
114
+ 2011-03-04 rocky <rockyb@rubyforge.org>
115
+
116
+ * Rakefile, app/cmd_parse.kpeg: Sync Rakefile with rb-trepanning
117
+
118
+ 2011-03-04 rocky <rockyb@rubyforge.org>
119
+
120
+ * app/cmd_parse.citrus, app/cmd_parse.kpeg, app/cmd_parser.rb:
121
+ Citrus -> KPeg: Forgot to add new files and remove old ones
122
+
123
+ 2011-03-04 rocky <rockyb@rubyforge.org>
124
+
125
+ * app/cmd_parse.rb, processor/validate.rb, rbx-trepanning.gemspec,
126
+ test/unit/test-app-cmd_parse.rb: Switch from Citrus to KPeg. Thanks
127
+ Evan!
128
+
129
+ 2011-03-02 rocky <rockyb@rubyforge.org>
130
+
131
+ Merge branch 'master' of github.com:rocky/rbx-trepanning
132
+
133
+ 2011-03-02 rocky <rockyb@rubyforge.org>
134
+
135
+ * processor/command/eval.rb, test/functional/test-eval.rb: Add to
136
+ eval? stripping "unless" and optional "then".
137
+
138
+ 2011-03-01 rvm <rocky@gnu.org>
139
+
140
+ * Rakefile, app/cmd_parse.citrus, app/cmd_parse.rb, doc/.gitignore,
141
+ doc/debugger.html, test/unit/test-app-cmd_parse.rb: Sync with
142
+ rb-trepanning: move forward in location parsing. Rakefile: add task
143
+ to remove patch residue files.
144
+
145
+ 2011-03-01 rocky <rockyb@rubyforge.org>
146
+
147
+ Merge branch 'master' of github.com:rocky/rbx-trepanning
148
+
149
+ 2011-02-28 rvm <rocky@gnu.org>
150
+
151
+ * app/brkptmgr.rb, processor/command/eval.rb: In "eval?" extract
152
+ expression in "case", and echo that.
153
+
154
+ 2011-02-25 rocky <rockyb@rubyforge.org>
155
+
156
+ * app/cmd_parse.citrus, app/cmd_parse.rb,
157
+ test/unit/test-app-cmd_parse.rb: Start filling out location parsing.
158
+
159
+
160
+ 2011-02-25 rocky <rockyb@rubyforge.org>
161
+
162
+ * app/cmd_parse.citrus, app/cmd_parse.rb, app/method_name.citrus,
163
+ app/method_name.rb, processor/validate.rb,
164
+ test/unit/test-app-cmd_parse.rb, test/unit/test-app-method_name.rb:
165
+ method_name -> cmd_parse to allow expansion
166
+
167
+ 2011-02-25 rvm <rocky@gnu.org>
168
+
169
+ * processor/command/eval.rb, test/functional/test-eval.rb: In eval?
170
+ we now also strip a leading 'return'.
171
+
172
+ 2011-02-25 rocky <rockyb@rubyforge.org>
173
+
174
+ * app/method_name.rb: Use bind instead of binding for binding
175
+ variable name. I think it is less likely to be confused with
176
+ Kernel#bind
177
+
178
+ 2011-02-25 rocky <rockyb@rubyforge.org>
179
+
180
+ * app/method_name.rb, app/validate.rb, lib/trepanning.rb,
181
+ processor/breakpoint.rb, processor/command/break.rb,
182
+ processor/validate.rb, test/functional/test-break-name.rb,
183
+ test/functional/test-tbreak.rb, test/unit/test-app-validate.rb,
184
+ test/unit/test-cmd-break.rb, test/unit/test-proc-validate.rb: Get
185
+ rid of the all-to-hacky # vs . notation for breakpoints. Also,
186
+ offsets are now specified with '@' rather than 'O' or 'o'. Some
187
+ other breakpoint bugs fixed.
188
+
189
+ 2011-02-24 rocky <rockyb@rubyforge.org>
190
+
191
+ Merge branch 'master' of github.com:rocky/rbx-trepanning
192
+
193
+ 2011-02-24 rocky <rockyb@rubyforge.org>
194
+
195
+ * app/method_name.citrus, app/method_name.rb,
196
+ processor/command/break.rb, processor/command/disassemble.rb,
197
+ processor/validate.rb, rbx-trepanning.gemspec,
198
+ test/unit/test-app-method_name.rb, test/unit/test-proc-validate.rb:
199
+ Use a PEG parser (citrus) to parse method names. This weay we can
200
+ get the method in a controlled way without having to eval and hope
201
+ we didn't do any damage.
202
+
203
+ 2011-02-23 rocky <rockyb@rubyforge.org>
204
+
205
+ * processor/command/step.rb, processor/disassemble.rb,
206
+ processor/main.rb, processor/running.rb: Add "step until"
207
+
208
+ 2011-02-23 rocky <rockyb@rubyforge.org>
209
+
210
+ * app/options.rb, processor/command/alias.rb,
211
+ processor/command/exit.rb, processor/command/kill.rb,
212
+ processor/command/restart.rb, processor/command/show.rb: Call
213
+ cmdproc finalization routine on exit and restart. Mention "show
214
+ alias" in alias help.
215
+
216
+ 2011-02-22 rocky <rockyb@rubyforge.org>
217
+
218
+ * app/options.rb: Update version for release.
219
+
220
+ 2011-02-22 rocky <rockyb@rubyforge.org>
221
+
222
+ * processor/command/base/subsubcmd.rb,
223
+ processor/command/show_subcmd/trace_subcmd/buffer.rb,
224
+ processor/main.rb, test/unit/test-base-subsubcmd.rb: Mark stopping
225
+ boundaries in event buffer. Test setting command CMD, NAME and
226
+ PREFIX. Make main more like rb-trepanning.
227
+
228
+ 2011-02-22 rocky <rockyb@rubyforge.org>
229
+
230
+ * ChangeLog, NEWS, Rakefile,
231
+ processor/command/info_subcmd/breakpoints.rb,
232
+ processor/command/show_subcmd/trace_subcmd/buffer.rb,
233
+ processor/eventbuf.rb, processor/location.rb: Now shows trace buffer
234
+ events and locations properly. How number of breakpoint hits. Get
235
+ ready for release.
236
+
1
237
  2011-02-22 rocky <rockyb@rubyforge.org>
2
238
 
3
239
  * app/breakpoint.rb, app/brkptmgr.rb, lib/trepanning.rb,
data/NEWS CHANGED
@@ -1,3 +1,19 @@
1
+ March 15, 2011 (0.0.8)
2
+
3
+ - Revise breakpoint location parsing
4
+ * Add: break <location> if/unless <condition>
5
+ * Add: step until <condition>
6
+ * VM offsets are now specified via @ rather than o or O
7
+ * Filenames can be quoted and blanks and characters inside escaped
8
+ - Document command syntax by adding it as a new category with sub help
9
+ - More controlled parsing of method names
10
+ - improvements to "info files"
11
+ show if we have a compiled method object for the file
12
+ - eval? now strips more:
13
+ * leading "return" or "case", or "unless"
14
+ * trailing "then"
15
+ - Save and restore some debugger state across a restart
16
+
1
17
  Feb 22, 2011 (0.0.7)
2
18
  - Add gdb "condition" command
3
19
  - More complete command completion
data/Rakefile CHANGED
@@ -6,9 +6,6 @@ raise RuntimeError, 'This package is for Rubinius 1.2.x only!' unless
6
6
  Rubinius::VERSION =~ /1\.2.+/
7
7
 
8
8
  require 'rubygems'
9
- require 'rake/gempackagetask'
10
- require 'rake/rdoctask'
11
- require 'rake/testtask'
12
9
 
13
10
  ROOT_DIR = File.dirname(__FILE__)
14
11
  Gemspec_filename = 'rbx-trepanning.gemspec'
@@ -18,13 +15,14 @@ def gemspec
18
15
  @gemspec ||= eval(File.read(Gemspec_filename), binding, Gemspec_filename)
19
16
  end
20
17
 
18
+ require 'rake/gempackagetask'
21
19
  desc "Build the gem"
22
20
  task :package=>:gem
23
21
  task :gem=>:gemspec do
24
22
  Dir.chdir(ROOT_DIR) do
25
23
  sh "gem build #{Gemspec_filename}"
26
24
  FileUtils.mkdir_p 'pkg'
27
- FileUtils.mv("#{gemspec.file_name}", "pkg/")
25
+ FileUtils.mv gemspec.file_name, 'pkg'
28
26
  end
29
27
  end
30
28
 
@@ -35,6 +33,18 @@ task :install => :gem do
35
33
  end
36
34
  end
37
35
 
36
+ require 'rake/testtask'
37
+ desc "Test everything."
38
+ Rake::TestTask.new(:test) do |t|
39
+ t.libs << './lib'
40
+ t.pattern = 'test/test-*.rb'
41
+ t.verbose = true
42
+ end
43
+ task :test => :lib
44
+
45
+ desc "same as test"
46
+ task :check => :test
47
+
38
48
  require 'rbconfig'
39
49
  RUBY_PATH = File.join(RbConfig::CONFIG['bindir'],
40
50
  RbConfig::CONFIG['RUBY_INSTALL_NAME'])
@@ -47,7 +57,7 @@ def run_standalone_ruby_files(list)
47
57
  end
48
58
 
49
59
  def run_standalone_ruby_file(directory, opts={})
50
- puts ('*' * 10) + ' ' + directory + ' ' + ('*' * 10)
60
+ puts(('*' * 10) + ' ' + directory + ' ' + ('*' * 10))
51
61
  Dir.chdir(directory) do
52
62
  Dir.glob('*.rb').each do |ruby_file|
53
63
  puts(('-' * 20) + ' ' + ruby_file + ' ' + ('-' * 20))
@@ -82,7 +92,6 @@ Rake::TestTask.new(:'test:integration') do |t|
82
92
  end
83
93
 
84
94
  desc 'Test everything - unit tests for now.'
85
- task :default => :test
86
95
  task :test do
87
96
  exceptions = %w(test:unit test:functional test:integration).collect do |task|
88
97
  begin
@@ -115,20 +124,55 @@ task :'check:sub:commands' do
115
124
  end
116
125
  end
117
126
 
127
+ desc "Run each of the sub-sub commands in standalone mode."
128
+ task :'check:subsub:commands' do
129
+ subsub_files = FileList["#{ROOT_DIR}/processor/command/*_subcmd/*_subcmd/*.rb"]
130
+ run_standalone_ruby_files(subsub_files)
131
+ end
132
+
133
+ desc "Run each processor Ruby file in standalone mode."
134
+ task :'check:lib' do
135
+ run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} lib)))
136
+ end
137
+
118
138
  desc "Run each processor Ruby file in standalone mode."
119
139
  task :'check:processor' do
120
140
  run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} processor)))
121
141
  end
122
142
 
143
+ desc "Run each processor Ruby file in standalone mode."
144
+ task :'check:unit' do
145
+ run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test unit)))
146
+ end
147
+
148
+ desc "Run functional tests in standalone mode."
123
149
  task :'check:functional' do
124
150
  run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test functional)))
125
151
  end
126
152
 
127
- desc "Run each unit test in standalone mode."
128
- task :'check:unit' do
129
- run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test unit)))
153
+ desc "Run command parser grammar."
154
+ task :'check:cmd_parse' do
155
+ sh "kpeg --test --debug #{File.join(ROOT_DIR, %w(app cmd_parse.kpeg))}"
156
+ end
157
+
158
+ desc "Generate command parser."
159
+ task :'cmd_parse' do
160
+ require 'tmpdir'
161
+ temp_file = File.join(Dir.tmpdir, "cmd_parser_#{$$}.rb")
162
+ sh("kpeg --name CmdParse --verbose --stand-alone " +
163
+ "#{File.join(ROOT_DIR, %w(app cmd_parse.kpeg))} " +
164
+ "--output #{temp_file}")
130
165
  end
131
166
 
167
+ task :'check:integration' do
168
+ run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test integration)))
169
+ end
170
+
171
+ task :check => %w(check:lib check:processor check:commands).map{|c| c.to_sym}
172
+
173
+ desc "Test everything - same as test."
174
+ task :default => :test
175
+
132
176
  desc "Generate the gemspec"
133
177
  task :generate do
134
178
  puts gemspec.to_ruby
@@ -140,10 +184,11 @@ task :gemspec do
140
184
  end
141
185
 
142
186
  # --------- RDoc Documentation ------
187
+ require 'rake/rdoctask'
143
188
  desc "Generate rdoc documentation"
144
189
  Rake::RDocTask.new("rdoc") do |rdoc|
145
190
  rdoc.rdoc_dir = 'doc'
146
- rdoc.title = "rbx-trepaning #{Trepan::VERSION} Documentation"
191
+ rdoc.title = "Trepanning #{Trepan::VERSION} Documentation"
147
192
 
148
193
  rdoc.rdoc_files.include(%w(lib/trepanning.rb processor/*.rb
149
194
  processor/command/*.rb
@@ -162,5 +207,9 @@ task :clobber_rdoc do
162
207
  FileUtils.rm_rf File.join(ROOT_DIR, 'doc')
163
208
  end
164
209
 
210
+ task :rm_patch_residue do
211
+ FileUtils.rm_rf FileList['**/*.{rej,orig}'].to_a
212
+ end
213
+
165
214
  desc "Remove built files"
166
- task :clean => [:clobber_package, :clobber_rdoc]
215
+ task :clean => [:clobber_package, :clobber_rdoc, :rm_patch_residue]
data/app/breakpoint.rb CHANGED
@@ -15,12 +15,16 @@ class Trepan
15
15
  attr_reader :id # Fixnum. Name of breakpoint
16
16
  attr_reader :ignore # Fixnum. How many more times do we have
17
17
  # to encounter the breakpoint before we stop?
18
+ attr_reader :negate # Boolean. Negate sense of condition. Used in
19
+ # break if .. and break unless ..
20
+ # breakpoint
18
21
  @@next_id = 1
19
22
 
20
23
  BRKPT_DEFAULT_SETTINGS = {
21
24
  :condition => 'true',
22
25
  :enabled => 'true',
23
26
  :ignore => 0,
27
+ :negate => false,
24
28
  :temp => false,
25
29
  :event => :Unknown,
26
30
  } unless defined?(BRKPT_DEFAULT_SETTINGS)
@@ -106,7 +110,7 @@ class Trepan
106
110
  end
107
111
 
108
112
  def condition?(bind)
109
- if eval(@condition, bind)
113
+ if @negate != eval(@condition, bind)
110
114
  if @ignore > 0
111
115
  @ignore -= 1
112
116
  return false
data/app/brkptmgr.rb CHANGED
@@ -9,6 +9,10 @@ class Trepan
9
9
  attr_reader :set
10
10
 
11
11
  def initialize
12
+ clear
13
+ end
14
+
15
+ def clear
12
16
  @list = []
13
17
  @set = Set.new
14
18
  end
@@ -19,6 +23,7 @@ class Trepan
19
23
  bp.related_bp.each { |bp| bp.remove! }
20
24
  bp.remove!
21
25
  end
26
+ clear
22
27
  end
23
28
 
24
29
  def <<(brkpt)
@@ -0,0 +1,225 @@
1
+ # -*- Ruby -*-
2
+
3
+ %% {
4
+ #####################################################
5
+ # Structure to hold composite method names
6
+ SymbolEntry = Struct.new(:type, :name, :chain)
7
+
8
+
9
+ # Structure to hold position information
10
+ Position = Struct.new(:container_type, :container,
11
+ :position_type, :position)
12
+
13
+ # Structure to hold breakpoint information
14
+ Breakpoint = Struct.new(:position, :negate, :condition)
15
+
16
+ # Structure to hold list information
17
+ List = Struct.new(:position, :num)
18
+
19
+ }
20
+ #####################################################
21
+
22
+ upcase_letter = /[A-Z]/
23
+ downcase_letter = /[a-z]/
24
+ suffix_letter = /[=!?]/
25
+ letter = upcase_letter
26
+ | downcase_letter
27
+ id_symbol = letter | "_" | [0-9]
28
+
29
+
30
+ # An variable or a method identifier
31
+ # Examples:
32
+ # var1
33
+ # my_var?
34
+ # But not: Variable or @var
35
+ vm_identifier = < (downcase_letter | "_") id_symbol* suffix_letter? >
36
+ {
37
+ SymbolEntry.new(:variable, text)
38
+ }
39
+
40
+ # Examples:
41
+ # var1
42
+ # But not: my_var?, my_var!
43
+ variable_identifier = < (downcase_letter | "_") id_symbol* >
44
+ {
45
+ SymbolEntry.new(:variable, text)
46
+ }
47
+
48
+ # Examples:
49
+ # MY_CONSTANT
50
+ # MyConstant_01
51
+ # But not:
52
+ # MyConstant_01?
53
+ constant_identifier = < upcase_letter id_symbol* >
54
+ {
55
+ SymbolEntry.new(:constant, text)
56
+ }
57
+
58
+ # Examples:
59
+ # $global_variable
60
+ # We won't try for funny global names like $$, $? $:, $', etc
61
+ global_identifier = < "$" (constant_identifier | variable_identifier) >
62
+ {
63
+ SymbolEntry.new(:global, text)
64
+ }
65
+
66
+ # Examples:
67
+ # Foo
68
+ # foo
69
+ # But not:
70
+ # foo!, @foo, Class.foo
71
+ local_internal_identifier = constant_identifier | variable_identifier
72
+
73
+ # Examples:
74
+ # Foo, foo, foo!
75
+ # foo
76
+ # But not:
77
+ # @foo, Class.foo
78
+ local_identifier = constant_identifier | vm_identifier
79
+
80
+ # Example: @foo
81
+ instance_identifier = < '@' local_identifier >
82
+ {
83
+ SymbolEntry.new(:instance, text)
84
+ }
85
+
86
+
87
+ # Example: @@foo
88
+ classvar_identifier = ('@@' local_identifier:id )
89
+ {
90
+ SymbolEntry.new(:classvar, id)
91
+ }
92
+
93
+ identifier = global_identifier
94
+ | instance_identifier
95
+ | classvar_identifier
96
+ | local_identifier
97
+
98
+ id_separator = < '::'|'.' > { text }
99
+
100
+ # Like of class_module_chain *after* the first name. So we don't
101
+ # allow sigils in the initial id. That is we don't allow:
102
+ # Class.@name1.@@name2.$name3
103
+ # But we do allow final sigils:
104
+ # class.name!, class.name=
105
+ internal_class_module_chain =
106
+ < local_internal_identifier:parent id_separator:sep
107
+ internal_class_module_chain:child >
108
+ {
109
+ SymbolEntry.new(parent.type, text, [parent, child, sep])
110
+ }
111
+ | local_identifier
112
+
113
+
114
+ # I think strict Ruby rules are that once one goes from :: to .
115
+ # There is no going back. That is, A.B::C is invalid.
116
+ #
117
+ # Also I think method names can't be constants. But such
118
+ # subtleties we'll handle when we process the final structure.
119
+ # Examples:
120
+ # Object, A::B, A.b @@foo.bar, $foo.bar.baz?
121
+
122
+ class_module_chain =
123
+ < identifier:parent id_separator:sep internal_class_module_chain:child >
124
+ {
125
+ SymbolEntry.new(parent.type, text, [parent, child, sep])
126
+ }
127
+ | identifier
128
+
129
+ ##############################################################
130
+ # Location-specific things. This is used in conjunction with
131
+ # method-like things above.
132
+ sp = /[ \t]/
133
+ - = sp+
134
+ dbl_escapes = "\\\"" { '"' }
135
+ | "\\n" { "\n" }
136
+ | "\\t" { "\t" }
137
+ | "\\\\" { "\\" }
138
+ escapes = "\\\"" { '"' }
139
+ | "\\n" { "\n" }
140
+ | "\\t" { "\t" }
141
+ | "\\ " { " " }
142
+ | "\\:" { ":" }
143
+ | "\\\\" { "\\" }
144
+ dbl_seq = < /[^\\"]+/ > { text }
145
+ dbl_not_quote = (dbl_escapes | dbl_seq)+:ary { ary }
146
+ dbl_string = "\"" dbl_not_quote:ary "\"" { ary.join }
147
+ not_space_colon = escapes
148
+ | < /[^ \t\n:]/ > { text }
149
+ not_space_colons = ( not_space_colon )+:ary { ary.join }
150
+ filename = dbl_string | not_space_colons
151
+ file_pos_sep = sp+ | ':'
152
+ integer = </[0-9]+/> { text.to_i }
153
+ line_number = integer
154
+
155
+ vm_offset = '@' integer:int
156
+ {
157
+ Position.new(nil, nil, :offset, int)
158
+ }
159
+
160
+ # Examples:
161
+ # @43
162
+ # 5
163
+ position =
164
+ vm_offset
165
+ | line_number:l {
166
+ Position.new(nil, nil, :line, l)
167
+ }
168
+
169
+ file_colon_line = file_no_colon:file &{ File.exist?(file) } ':' position:pos {
170
+ Position.new(:file, file, pos.position_type, pos.position)
171
+ }
172
+
173
+ # Examples:
174
+ # Myclass.fn @5 # bytecode offset 5 of fn
175
+ # Myclass.fn:@5 # same as above
176
+ # Myclass.fn 5 # line number 5 of fn
177
+ # Note: Myclass.fn could be either a filename or a method name
178
+
179
+ # The below ordering is important.
180
+ # 1. Numbers can't be method names they are first. If there's a
181
+ # file with that name, later we'll allow quoting to indicate filename.
182
+ # 2. filename:position can't also be a method so that's next
183
+ # 3. It is possible a filename can be a method name, but we
184
+ # test using File.exist? so we want to put this first.
185
+ # Later "quoting" will skip the File.exist?
186
+ # 4. Class module *with* a position is next and has to be before
187
+ # without a position, else we would stop early before handling
188
+ # the position.
189
+
190
+ location =
191
+ position
192
+ | <filename>:file &{ File.exist?(file) } file_pos_sep position:pos {
193
+ Position.new(:file, file, pos.position_type, pos.position)
194
+ }
195
+ | <filename>:file &{ File.exist?(file) } {
196
+ Position.new(:file, file, nil, nil)
197
+ }
198
+ | class_module_chain?:fn file_pos_sep position:pos {
199
+ Position.new(:fn, fn, pos.position_type, pos.position)
200
+ }
201
+ | class_module_chain?:fn {
202
+ Position.new(:fn, fn, nil, nil)
203
+ }
204
+
205
+ if_unless = <"if" | "unless"> { text }
206
+ condition = </.+/> { text}
207
+
208
+ breakpoint_stmt_no_condition = location:loc {
209
+ Breakpoint.new(loc, false, 'true')
210
+ }
211
+
212
+ # Note that the first word "break" is handled in the command.
213
+ # Also, "break" with nothing else is handled there as well
214
+ breakpoint_stmt = location:loc - if_unless:iu - condition:cond {
215
+ Breakpoint.new(loc, iu == 'unless', cond)
216
+ }
217
+ | breakpoint_stmt_no_condition
218
+
219
+ # Note that the first word "list", "list>" or handled in
220
+ # the command. Also, "list" with nothing else is
221
+ # handled there as well
222
+ list_special_targets = <'.' '-'> { text }
223
+ list_stmt = (list_special_target | location):loc - (integer:int)? {
224
+ List.new(loc, int)
225
+ }