]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud/debugger/pydbgr/init.el
5778fc878bffbfc80002f41106893e2da8a6d373
[gnu-emacs-elpa] / packages / realgud / realgud / debugger / pydbgr / init.el
1 ;;; Copyright (C) 2010-2012 Rocky Bernstein <rocky@gnu.org>
2 ;;; pydbgr: Python 2.5 but less than 3K
3
4 (eval-when-compile (require 'cl))
5
6 (require 'load-relative)
7 (require-relative-list '("../../common/regexp"
8 "../../common/loc"
9 "../../common/init")
10 "realgud-")
11 (require-relative-list '("../../lang/python") "realgud-lang-")
12
13 (defvar realgud-pat-hash)
14 (declare-function make-realgud-loc-pat (realgud-loc))
15
16 (defvar realgud-pydbgr-pat-hash (make-hash-table :test 'equal)
17 "Hash key is the what kind of pattern we want to match:
18 backtrace, prompt, etc. The values of a hash entry is a
19 realgud-loc-pat struct")
20
21 (declare-function make-realgud-loc "realgud-loc" (a b c d e f))
22
23 ;; Regular expression that describes a pydbgr location generally shown
24 ;; before a command prompt.
25 ;;
26 ;; For example:
27 ;; (/usr/bin/zonetab2pot.py:15): <module>
28 ;; (/usr/bin/zonetab2pot.py:15 remapped <string>): <module>
29 ;; or MS Windows:
30 ;; (c:\\mydirectory\\gcd.py:10): <module>
31 (setf (gethash "loc" realgud-pydbgr-pat-hash)
32 (make-realgud-loc-pat
33 :regexp "^(\\(\\(?:[a-zA-Z]:\\)?[-a-zA-Z0-9_/.\\\\ ]+\\):\\([0-9]+\\)\\(?: remapped .*\\)?)"
34 :file-group 1
35 :line-group 2))
36
37 (setf (gethash "prompt" realgud-pydbgr-pat-hash)
38 (make-realgud-loc-pat
39 :regexp "^(Pydbgr) "
40 ))
41
42 ;; Regular expression that describes a Python backtrace line.
43 (setf (gethash "lang-backtrace" realgud-pydbgr-pat-hash)
44 realgud-python-backtrace-loc-pat)
45
46 ;; Regular expression that describes a "breakpoint set" line
47 (setf (gethash "brkpt-set" realgud-pydbgr-pat-hash)
48 (make-realgud-loc-pat
49 :regexp "^Breakpoint \\([0-9]+\\) set at line \\([0-9]+\\)[ \t\n]+of file \\(.+\\)\\(\n\\|$\\)"
50 :num 1
51 :file-group 3
52 :line-group 2))
53
54 ;; Regular expression that describes a "delete breakpoint" line
55 (setf (gethash "brkpt-del" realgud-pydbgr-pat-hash)
56 (make-realgud-loc-pat
57 :regexp "^Deleted breakpoint \\([0-9]+\\)\n"
58 :num 1))
59
60 (setf (gethash "font-lock-keywords" realgud-pydbgr-pat-hash)
61 '(
62 ;; The frame number and first type name, if present.
63 ("^\\(->\\|##\\)\\([0-9]+\\) \\(<module>\\)? *\\([a-zA-Z_][a-zA-Z0-9_]*\\)(\\(.+\\))?"
64 (2 realgud-backtrace-number-face)
65 (4 font-lock-function-name-face nil t)) ; t means optional.
66
67 ;; Parameter sequence, E.g. gcd(a=3, b=5)
68 ;; ^^^^^^^^^
69 ("(\\(.+\\))"
70 (1 font-lock-variable-name-face))
71
72 ;; File name. E.g file '/test/gcd.py'
73 ;; ------^^^^^^^^^^^^-
74 ("[ \t]+file '\\([^ ]+*\\)'"
75 (1 realgud-file-name-face))
76
77 ;; Line number. E.g. at line 28
78 ;; ---------^^
79 ("[ \t]+at line \\([0-9]+\\)$"
80 (1 realgud-line-number-face))
81
82 ;; Function name.
83 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
84 (1 font-lock-type-face)
85 (2 font-lock-function-name-face))
86 ;; (pydbgr-frames-match-current-line
87 ;; (0 pydbgr-frames-current-frame-face append))
88 ))
89
90 (setf (gethash "pydbgr" realgud-pat-hash) realgud-pydbgr-pat-hash)
91
92 (defvar realgud-pydbgr-command-hash (make-hash-table :test 'equal)
93 "Hash key is command name like 'shell' and the value is
94 the pydbgr command to use, like 'python'")
95
96 (setf (gethash "shell" realgud-pydbgr-command-hash) "python")
97 (setf (gethash "pydbgr" realgud-command-hash) realgud-pydbgr-command-hash)
98
99 (provide-me "realgud-pydbgr-")