1 ;;; Copyright (C) 2010-2011, 2014 Rocky Bernstein <rocky@gnu.org>
2 (eval-when-compile (require 'cl))
4 (require 'load-relative)
5 (require-relative-list '("../../common/regexp" "../../common/loc") "realgud-")
6 (require-relative-list '("../../lang/ruby") "realgud-lang-")
8 (defvar realgud-pat-hash)
9 (declare-function make-realgud-loc-pat (realgud-loc))
11 (defvar realgud:trepanx-pat-hash (make-hash-table :test 'equal)
12 "Hash key is the what kind of pattern we want to match:
13 backtrace, prompt, etc. The values of a hash entry is a
14 realgud-loc-pat struct")
16 ;; Regular expression that describes a trepanx location generally shown
17 ;; before a command prompt.
19 ;; -> (/tmp/fact.rb:1)
20 ;; -- (kernel/common/scope.rb:134 remapped /tmp/scope.rb:134)
21 (setf (gethash "loc" realgud:trepanx-pat-hash)
23 :regexp ".. (\\(?:.+ \\(?:via\\|remapped\\) \\)?\\(.+\\):\\([0-9]+\\)\\(?: @[0-9]+\\)?)"
27 ;; Regular expression that describes a trepanx command prompt
31 (setf (gethash "prompt" realgud:trepanx-pat-hash)
33 :regexp "^(+trepanx\\(@[0-9]+\\|@main\\)?)+: "
36 ;; Regular expression that describes a Rubinius backtrace line.
37 (setf (gethash "lang-backtrace" realgud:trepanx-pat-hash)
38 realgud-rubinius-backtrace-loc-pat)
40 ;; Regular expression that describes a ruby $! backtrace
41 (setf (gethash "dollar-bang-backtrace" realgud:trepanx-pat-hash)
42 realgud-ruby-dollar-bang-loc-pat)
44 ;; Regular expression that describes a Rubinius X-agent backtrace
46 (setf (gethash "rubinius-backtrace-Xagent" realgud:trepanx-pat-hash)
47 realgud-rubinius-Xagent-backtrace-loc-pat)
49 ;; Regular expression that describes a "breakpoint set" line
51 ;; Set breakpoint 1: /tmp/fact.rb:1 (@0)
52 (setf (gethash "brkpt-set" realgud:trepanx-pat-hash)
54 :regexp "^Set breakpoint \\([0-9]+\\): .+ at \\(.+\\):\\([0-9]+\\) (@[0-9]+)"
59 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
61 ;; Deleted breakpoint 1.
62 (setf (gethash "brkpt-del" realgud:trepanx-pat-hash)
64 :regexp "^Deleted breakpoint \\([0-9]+\\).\n"
67 ;; Regular expression that describes a Ruby $! string
68 (setf (gethash "dollar-bang" realgud:trepanx-pat-hash)
69 realgud-ruby-dollar-bang-loc-pat)
71 (setf (gethash "trepanx" realgud-pat-hash) realgud:trepanx-pat-hash)
73 (defconst realgud:trepanx-frame-file-line-regexp
74 " at \\(.*\\):\\([0-9]+\\)$")
76 (defconst realgud:trepanx-frame-start-regexp realgud:trepan-frame-start-regexp)
77 (defconst realgud:trepanx-frame-num-regexp realgud:trepan-frame-start-regexp)
79 ;; Regular expression that describes a debugger "backtrace" command line.
81 ;; --> #0 Rubinius::Scope#my_method at kernel/common/variable_scope.rb:134
82 ;; #1 main.__script__ at /tmp/fact.rb:1
83 (setf (gethash "debugger-backtrace" realgud:trepanx-pat-hash)
85 :regexp (concat realgud:trepanx-frame-start-regexp " "
86 realgud:trepanx-frame-num-regexp " "
87 "\\([A-Z_][a-zA-Z0-9_:]*\\)[#.]\\(.*\\)"
88 realgud:trepanx-frame-file-line-regexp
95 ;; Regular expression that for a termination message.
96 (setf (gethash "termination" realgud:trepanx-pat-hash)
97 "^trepanx: That's all, folks...\n")
99 (setf (gethash "font-lock-keywords" realgud:trepanx-pat-hash)
101 ;; File name and line number. E.g. at /test/gcd.rb:6
103 (" at \\(.*\\):\\([0-9]+\\)$"
104 (1 realgud-file-name-face)
105 (2 realgud-line-number-face))
107 ;; The frame number and first type name, if present.
108 ("^\\(-->\\| \\)? #\\([0-9]+\\) \\([a-zA-Z_][a-zA-Z0-9_]*\\).*\\(\\([#.]\\)?\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?\\)?"
109 (2 realgud-backtrace-number-face)
110 (3 font-lock-constant-face) ; e.g. Object
111 (6 font-lock-function-name-face nil t)) ; t means optional
113 ;; The frame number and first type name, if present.
114 ("^ +\\([0-9]+\\) *\\([a-zA-Z_][a-zA-Z0-9_]*\\).*\\(\\([#.]\\)?\\([a-zA-Z_][a-zA-Z_[0-9]]*\\)?\\)?"
115 (1 realgud-backtrace-number-face)
116 (2 font-lock-constant-face) ; e.g. Object
117 (5 font-lock-function-name-face nil t)) ; t means optional
118 ;; Parameter sequence
120 (1 font-lock-variable-name-face))
121 ;; "::Type", which occurs in class name of function and in parameter list.
122 ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
123 (1 font-lock-type-face))
126 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
127 (1 font-lock-type-face)
128 (2 font-lock-function-name-face))
129 ;; (trepan-frames-match-current-line
130 ;; (0 trepan-frames-current-frame-face append))
133 (setf (gethash "trepanx" realgud-pat-hash) realgud:trepanx-pat-hash)
135 (defvar realgud:trepanx-command-hash (make-hash-table :test 'equal)
136 "Hash key is command name like 'quit' and the value is
137 the trepanx command to use, like 'quit!'")
139 (setf (gethash "quit" realgud:trepanx-command-hash) "quit!")
140 (setf (gethash "shell" realgud:trepanx-command-hash) "irb")
141 (setf (gethash "trepanx" realgud-command-hash) realgud:trepanx-command-hash)
143 (provide-me "realgud:trepanx-")