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