]> code.delx.au - gnu-emacs-elpa/blob - dbgr/debugger/pydbgr/init.el
Add stock Python debugger.
[gnu-emacs-elpa] / dbgr / debugger / pydbgr / init.el
1 ;;; Copyright (C) 2010, 2011, 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 "dbgr-")
11 (require-relative-list '("../../lang/python") "dbgr-lang-")
12
13 (defvar dbgr-pat-hash)
14 (declare-function make-dbgr-loc-pat (dbgr-loc))
15
16 (defvar dbgr-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 dbgr-loc-pat struct")
20
21 (declare-function make-dbgr-loc "dbgr-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 ;; or MS Windows:
29 ;; (c:\\mydirectory\\gcd.py:10): <module>
30 (setf (gethash "loc" dbgr-pydbgr-pat-hash)
31 (make-dbgr-loc-pat
32 :regexp "^(\\(\\(?:[a-zA-Z]:\\)?[-a-zA-Z0-9_/.\\\\ ]+\\):\\([0-9]+\\))"
33 :file-group 1
34 :line-group 2))
35
36 (setf (gethash "prompt" dbgr-pydbgr-pat-hash)
37 (make-dbgr-loc-pat
38 :regexp "^(Pydbgr) "
39 ))
40
41 ;; Regular expression that describes a Python backtrace line.
42 (setf (gethash "lang-backtrace" dbgr-pydbgr-pat-hash)
43 dbgr-python-backtrace-loc-pat)
44
45 ;; Regular expression that describes a "breakpoint set" line
46 (setf (gethash "brkpt-set" dbgr-pydbgr-pat-hash)
47 (make-dbgr-loc-pat
48 :regexp "^Breakpoint \\([0-9]+\\) set at line \\([0-9]+\\)[ \t\n]+of file \\(.+\\)\\(\n\\|$\\)"
49 :num 1
50 :file-group 3
51 :line-group 2))
52
53 ;; Regular expression that describes a "delete breakpoint" line
54 (setf (gethash "brkpt-del" dbgr-pydbgr-pat-hash)
55 (make-dbgr-loc-pat
56 :regexp "^Deleted breakpoint \\([0-9]+\\)\n"
57 :num 1))
58
59 (setf (gethash "font-lock-keywords" dbgr-pydbgr-pat-hash)
60 '(
61 ;; The frame number and first type name, if present.
62 ("^\\(->\\|##\\)\\([0-9]+\\) \\(<module>\\)? *\\([a-zA-Z_][a-zA-Z0-9_]*\\)(\\(.+\\))?"
63 (2 dbgr-backtrace-number-face)
64 (4 font-lock-function-name-face nil t)) ; t means optional.
65
66 ;; Parameter sequence, E.g. gcd(a=3, b=5)
67 ;; ^^^^^^^^^
68 ("(\\(.+\\))"
69 (1 font-lock-variable-name-face))
70
71 ;; File name. E.g file '/test/gcd.py'
72 ;; ------^^^^^^^^^^^^-
73 ("[ \t]+file '\\([^ ]+*\\)'"
74 (1 dbgr-file-name-face))
75
76 ;; Line number. E.g. at line 28
77 ;; ---------^^
78 ("[ \t]+at line \\([0-9]+\\)$"
79 (1 dbgr-line-number-face))
80
81 ;; Function name.
82 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
83 (1 font-lock-type-face)
84 (2 font-lock-function-name-face))
85 ;; (pydbgr-frames-match-current-line
86 ;; (0 pydbgr-frames-current-frame-face append))
87 ))
88
89 (setf (gethash "pydbgr" dbgr-pat-hash) dbgr-pydbgr-pat-hash)
90
91 (defvar dbgr-pydbgr-command-hash (make-hash-table :test 'equal)
92 "Hash key is command name like 'shell' and the value is
93 the pydbgr command to use, like 'python'")
94
95 (setf (gethash "shell" dbgr-pydbgr-command-hash) "python")
96 (setf (gethash "pydbgr" dbgr-command-hash) dbgr-pydbgr-command-hash)
97
98 (provide-me "dbgr-pydbgr-")