]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud/debugger/trepanx/init.el
9f0338569f247103ae4121597c4dd4201b063c00
[gnu-emacs-elpa] / packages / realgud / realgud / debugger / trepanx / init.el
1 ;;; Copyright (C) 2010-2011, 2014 Rocky Bernstein <rocky@gnu.org>
2 (eval-when-compile (require 'cl))
3
4 (require 'load-relative)
5 (require-relative-list '("../../common/regexp" "../../common/loc") "realgud-")
6 (require-relative-list '("../../lang/ruby") "realgud-lang-")
7
8 (defvar realgud-pat-hash)
9 (declare-function make-realgud-loc-pat (realgud-loc))
10
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")
15
16 ;; Regular expression that describes a trepanx location generally shown
17 ;; before a command prompt.
18 ;; For example:
19 ;; -> (/tmp/fact.rb:1)
20 ;; -- (kernel/common/scope.rb:134 remapped /tmp/scope.rb:134)
21 (setf (gethash "loc" realgud:trepanx-pat-hash)
22 (make-realgud-loc-pat
23 :regexp ".. (\\(?:.+ \\(?:via\\|remapped\\) \\)?\\(.+\\):\\([0-9]+\\)\\(?: @[0-9]+\\)?)"
24 :file-group 1
25 :line-group 2))
26
27 ;; Regular expression that describes a trepanx command prompt
28 ;; For example:
29 ;; (trepanx):
30 ;; ((trepanx)):
31 (setf (gethash "prompt" realgud:trepanx-pat-hash)
32 (make-realgud-loc-pat
33 :regexp "^(+trepanx\\(@[0-9]+\\|@main\\)?)+: "
34 ))
35
36 ;; Regular expression that describes a Rubinius backtrace line.
37 (setf (gethash "lang-backtrace" realgud:trepanx-pat-hash)
38 realgud-rubinius-backtrace-loc-pat)
39
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)
43
44 ;; Regular expression that describes a Rubinius X-agent backtrace
45 ;; line.
46 (setf (gethash "rubinius-backtrace-Xagent" realgud:trepanx-pat-hash)
47 realgud-rubinius-Xagent-backtrace-loc-pat)
48
49 ;; Regular expression that describes a "breakpoint set" line
50 ;; For example:
51 ;; Set breakpoint 1: /tmp/fact.rb:1 (@0)
52 (setf (gethash "brkpt-set" realgud:trepanx-pat-hash)
53 (make-realgud-loc-pat
54 :regexp "^Set breakpoint \\([0-9]+\\): .+ at \\(.+\\):\\([0-9]+\\) (@[0-9]+)"
55 :num 1
56 :file-group 2
57 :line-group 3))
58
59 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
60 ;; For example:'
61 ;; Deleted breakpoint 1.
62 (setf (gethash "brkpt-del" realgud:trepanx-pat-hash)
63 (make-realgud-loc-pat
64 :regexp "^Deleted breakpoint \\([0-9]+\\).\n"
65 :num 1))
66
67 ;; Regular expression that describes a Ruby $! string
68 (setf (gethash "dollar-bang" realgud:trepanx-pat-hash)
69 realgud-ruby-dollar-bang-loc-pat)
70
71 (setf (gethash "trepanx" realgud-pat-hash) realgud:trepanx-pat-hash)
72
73 (defconst realgud:trepanx-frame-file-line-regexp
74 " at \\(.*\\):\\([0-9]+\\)$")
75
76 (defconst realgud:trepanx-frame-start-regexp realgud:trepan-frame-start-regexp)
77 (defconst realgud:trepanx-frame-num-regexp realgud:trepan-frame-start-regexp)
78
79 ;; Regular expression that describes a debugger "backtrace" command line.
80 ;; e.g.
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)
84 (make-realgud-loc-pat
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
89 )
90 :num 2
91 :file-group 6
92 :line-group 7)
93 )
94
95 ;; Regular expression that for a termination message.
96 (setf (gethash "termination" realgud:trepanx-pat-hash)
97 "^trepanx: That's all, folks...\n")
98
99 (setf (gethash "font-lock-keywords" realgud:trepanx-pat-hash)
100 '(
101 ;; File name and line number. E.g. at /test/gcd.rb:6
102 ;; ---^^^^^^^^^^^^-^
103 (" at \\(.*\\):\\([0-9]+\\)$"
104 (1 realgud-file-name-face)
105 (2 realgud-line-number-face))
106
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
112
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
119 ("(\\(.+\\))"
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))
124
125 ;; Function name.
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))
131 ))
132
133 (setf (gethash "trepanx" realgud-pat-hash) realgud:trepanx-pat-hash)
134
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!'")
138
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)
142
143 (provide-me "realgud:trepanx-")