1 ;;; Copyright (C) 2010, 2014 Rocky Bernstein <rocky@gnu.org>
2 ;;; Common Ruby constants and regular expressions.
3 (eval-when-compile (require 'cl))
5 (require 'load-relative)
6 (require-relative-list '("../common/regexp" "../common/loc" "../common/track")
9 (declare-function realgud-goto-line-for-pt 'realgud-track)
11 (defconst realgud-rails-backtrace-loc-pat
13 :regexp "^\\([^:]+\\):\\([0-9]+\\)\\(?:[:]in `.*'\\)?"
16 "A realgud-loc-pat struct that describes a Rails backtrace (or
19 ;; Regular expression that describes a Ruby YARV 1.9 syntax error line.
20 ;; SyntaxError: /tmp/columnize.rb:270: syntax error, unexpected $end, ...
21 (defconst realgud-ruby-YARV-syntax-error-pat
23 :regexp "^SyntaxError: \\([^:]+\\):\\([0-9]+\\): syntax error"
26 "A realgud-loc-pat struct that describes a Ruby YARV syntax error message")
28 (defconst realgud-ruby-backtrace-loc-pat
30 :regexp "^[ \t]+from \\([^:]+\\):\\([0-9]+\\)\\(?: in `.*'\\)?"
33 "A realgud-loc-pat struct that describes a Ruby backtrace (or
36 (defconst realgud-rubinius-backtrace-loc-pat
38 :regexp "^\\(?:
\e\\[0;3[1-4]m\\)?[ \t]+.* at \\([^:]+\\):\\([0-9]+\\)"
41 "A realgud-loc-pat struct that describes a Rubinius backtrace (or
44 (defconst realgud-rubinius-Xagent-backtrace-loc-pat
46 :regexp "^\\(?:
\e\\[0;3[1-4]m\\)?0x[a-f0-9]\\{8\\}: .* in \\([^:]+\\):\\([0-9]+\\) ([+][0-9]+)"
49 "A realgud-loc-pat struct that describes a Rubinius Xagent backtrace (or
52 (defconst realgud-ruby-dollar-bang-loc-pat
54 :regexp "^[ \t]*[[]?\\(.+\\):\\([0-9]+\\):in `.*'"
57 "A realgud-loc-pat that struct that describes a Ruby $! string."
60 ;; FIXME: there is probably a less redundant way to do the following
62 (defun realgud:rails-goto-backtrace-line (pt)
63 "Display the location mentioned by the Rails backtrace line
66 (realgud-goto-line-for-pt pt "rails-backtrace"))
68 (defun realgud:rubinius-goto-Xagent-backtrace-line (pt)
69 "Display the location mentioned by the Rubinius Xagent- backtrace line
72 (realgud-goto-line-for-pt pt "rubinius-backtrace-Xagent"))
74 (defun realgud:ruby-goto-backtrace-line (pt)
75 "Display the location mentioned by the Ruby backtrace line
78 (realgud-goto-line-for-pt pt "lang-backtrace"))
80 (defun realgud:ruby-goto-dollar-bang-line (pt)
81 "Display the location mentioned by the Ruby backtrace line
84 (realgud-goto-line-for-pt pt "dollar-bang-backtrace"))
86 (defun realgud:ruby-populate-command-keys (&optional map)
87 "Bind the debugger function key layout used by many debuggers.
89 \\{realgud-example-map-standard}"
90 (define-key map (kbd "C-c !l") 'realgud:goto-lang-backtrace-line)
91 (define-key map (kbd "C-c !!") 'realgud:ruby-goto-dollar-bang-line)
92 (define-key map (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
93 (define-key map (kbd "C-c !r") 'realgud:rails-goto-backtrace-line)
97 ;; Some things common to all trepan debuggers (Rubinius and Ruby 1.9.2)
98 (defconst realgud:trepan-frame-start-regexp
99 "\\(?:^\\|\n\\)\\(-->\\| \\)")
101 (defconst realgud:trepan-frame-num-regexp
104 (defconst realgud:trepan-frame-line-regexp
105 "[ \t\n]+at line \\([0-9]+\\)\\(?:\n\\|$\\)")
108 (provide-me "realgud-lang-")