]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud/debugger/trepan8/init.el
a6ba3d4036210fdd10be8ab819689ddc02c44114
[gnu-emacs-elpa] / packages / realgud / realgud / debugger / trepan8 / init.el
1 ;;; Copyright (C) 2010, 2011 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:trepan8-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 trepan8 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:trepan8-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 trepan8 command prompt
28 ;; For example:
29 ;; (trepan8):
30 ;; ((trepan8)):
31 (setf (gethash "prompt" realgud:trepan8-pat-hash)
32 (make-realgud-loc-pat
33 :regexp "^(+trepan8\\(@[0-9]+\\|@main\\)?)+: "
34 ))
35
36 ;; Regular expression that describes a MRI 1.8 Ruby backtrace line.
37 (setf (gethash "lang-backtrace" realgud:trepan8-pat-hash)
38 realgud-ruby-backtrace-loc-pat)
39
40 ;; Regular expression that describes a ruby $! backtrace
41 (setf (gethash "dollar-bang-backtrace" realgud:trepan8-pat-hash)
42 realgud-ruby-dollar-bang-loc-pat)
43
44 ;; Regular expression that describes a "breakpoint set" line
45 ;; For example:
46 ;; Set breakpoint 1: /tmp/fact.rb:1 (@0)
47 (setf (gethash "brkpt-set" realgud:trepan8-pat-hash)
48 (make-realgud-loc-pat
49 :regexp "^Set breakpoint \\([0-9]+\\): .+ at \\(.+\\):\\([0-9]+\\) (@[0-9]+)"
50 :num 1
51 :file-group 2
52 :line-group 3))
53
54 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
55 ;; For example:'
56 ;; Deleted breakpoint 1.
57 (setf (gethash "brkpt-del" realgud:trepan8-pat-hash)
58 (make-realgud-loc-pat
59 :regexp "^Deleted breakpoint \\([0-9]+\\).\n"
60 :num 1))
61
62 ;; Regular expression that describes a Ruby $! string
63 (setf (gethash "dollar-bang" realgud:trepan8-pat-hash)
64 realgud-ruby-dollar-bang-loc-pat)
65
66 (setf (gethash "trepan8" realgud-pat-hash) realgud:trepan8-pat-hash)
67
68 (defconst realgud:trepan8-frame-file-line-regexp
69 " at \\(.*\\):\\([0-9]+\\)$")
70
71 (defconst realgud:trepan8-frame-start-regexp realgud:trepan-frame-start-regexp)
72 (defconst realgud:trepan8-frame-num-regexp realgud:trepan-frame-start-regexp)
73
74 ;; Regular expression that describes a debugger "backtrace" command line.
75 ;; e.g.
76 ;; --> #0 at line /usr/bin/irb:12
77 ;; #1 main.__script__ at /tmp/fact.rb:1
78 ;; #1 main.__script__ at /tmp/fact.rb:1
79 ;; #0 IRB.start(ap_path#String) at line /usr/lib/ruby/1.8/irb.rb:52
80 (setf (gethash "debugger-backtrace" realgud:trepan8-pat-hash)
81 (make-realgud-loc-pat
82 :regexp (concat realgud:trepan8-frame-start-regexp " "
83 realgud:trepan8-frame-num-regexp
84 "\\(?: \\(?:\\(.+\\)(\\(.*\\))\\)\\)?"
85 realgud:trepan8-frame-file-line-regexp
86 )
87 :num 2
88 :file-group 5
89 :line-group 6)
90 )
91
92 ;; Regular expression that for a termination message.
93 (setf (gethash "termination" realgud:trepan8-pat-hash)
94 "^trepan8: That's all, folks...\n")
95
96 (setf (gethash "font-lock-keywords" realgud:trepan8-pat-hash)
97 '(
98 ;; Parameters and first type entry. E.g Object.gcd(a#Fixnum, b#Fixnum)
99 ;; ^-^^^^^^ ^-^^^^^^
100 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)#\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\>"
101 (1 font-lock-variable-name-face)
102 (2 font-lock-constant-face))
103
104 ;; "::Type", which occurs in class name of function and in
105 ;; parameter list.
106 ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
107 (1 font-lock-type-face))
108
109 ;; The frame number and first type name, if present.
110 ;; E.g. --> #0 Object.gcd(a#Fixnum, b#Fixnum)
111 ;; -----^-^^^^^^.^^^
112 ("^\\(-->\\)? *#\\([0-9]+\\) *\\(\\([a-zA-Z_][a-zA-Z0-9_]*\\)[.:]\\)?"
113 (2 realgud-backtrace-number-face)
114 (4 font-lock-constant-face nil t)) ; t means optional.
115
116 ;; File name and line number. E.g. at line /test/gcd.rb:6
117 ;; -------^^^^^^^^^^^^^-^
118 ("at line \\(.*\\):\\([0-9]+\\)$"
119 (1 realgud-file-name-face)
120 (2 realgud-line-number-face))
121
122 ;; Function name.
123 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
124 (1 font-lock-type-face)
125 (2 font-lock-function-name-face))
126 ;; (trepan-frames-match-current-line
127 ;; (0 trepan-frames-current-frame-face append))
128 ))
129
130 (setf (gethash "trepan8" realgud-pat-hash) realgud:trepan8-pat-hash)
131
132 (defvar realgud:trepan8-command-hash (make-hash-table :test 'equal)
133 "Hash key is command name like 'quit' and the value is
134 the trepan8 command to use, like 'quit!'")
135
136 (setf (gethash "quit" realgud:trepan8-command-hash) "quit!")
137 (setf (gethash "shell" realgud:trepan8-command-hash) "irb")
138 (setf (gethash "trepan8" realgud-command-hash) realgud:trepan8-command-hash)
139
140 (provide-me "realgud:trepan8-")