1 ;;; Copyright (C) 2010, 2011 Rocky Bernstein <rocky@gnu.org>
2 ;;; pydbgr: Python 2.5 and beyond
4 (eval-when-compile (require 'cl))
6 (require 'load-relative)
7 (require-relative-list '("../../common/regexp"
11 (require-relative-list '("../../lang/python") "dbgr-lang-")
13 (defvar dbgr-pat-hash)
14 (declare-function make-dbgr-loc-pat (dbgr-loc))
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
21 (declare-function make-dbgr-loc "dbgr-loc" (a b c d e f))
23 ;; Regular expression that describes a pydbgr location generally shown
24 ;; before a command prompt.
26 ;; Program-location lines look like this:
27 ;; (/usr/bin/zonetab2pot.py:15): <module>
29 ;; (c:\\mydirectory\\gcd.py:10): <module>
30 ;; and in backtrace like this:
31 ;; (/usr/bin/zonetab2pot.py:15)
32 (setf (gethash "loc" dbgr-pydbgr-pat-hash)
34 :regexp "^(\\(\\(?:[a-zA-Z]:\\)?[-a-zA-Z0-9_/.\\\\ ]+\\):\\([0-9]+\\))"
38 (setf (gethash "prompt" dbgr-pydbgr-pat-hash)
43 ;; Regular expression that describes a Python backtrace line.
44 (setf (gethash "lang-backtrace" dbgr-pydbgr-pat-hash)
45 dbgr-python-backtrace-loc-pat)
47 ;; Regular expression that describes a "breakpoint set" line
48 (setf (gethash "brkpt-set" dbgr-pydbgr-pat-hash)
50 :regexp "^Breakpoint \\([0-9]+\\) set at line \\([0-9]+\\)[ \t\n]+of file \\(.+\\)\\(\n\\|$\\)"
55 ;; Regular expression that describes a "delete breakpoint" line
56 (setf (gethash "brkpt-del" dbgr-pydbgr-pat-hash)
58 :regexp "^Deleted breakpoint \\([0-9]+\\)\n"
61 (setf (gethash "font-lock-keywords" dbgr-pydbgr-pat-hash)
63 ;; The frame number and first type name, if present.
64 ("^\\(->\\|##\\)\\([0-9]+\\) \\(<module>\\)? *\\([a-zA-Z_][a-zA-Z0-9_]*\\)(\\(.+\\))?"
65 (2 dbgr-backtrace-number-face)
66 (4 font-lock-function-name-face nil t)) ; t means optional.
68 ;; Parameter sequence, E.g. gcd(a=3, b=5)
71 (1 font-lock-variable-name-face))
73 ;; File name. E.g file '/test/gcd.py'
74 ;; ------^^^^^^^^^^^^-
75 ("[ \t]+file '\\([^ ]+*\\)'"
76 (1 dbgr-file-name-face))
78 ;; Line number. E.g. at line 28
80 ("[ \t]+at line \\([0-9]+\\)$"
81 (1 dbgr-line-number-face))
84 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
85 (1 font-lock-type-face)
86 (2 font-lock-function-name-face))
87 ;; (pydbgr-frames-match-current-line
88 ;; (0 pydbgr-frames-current-frame-face append))
91 (setf (gethash "pydbgr" dbgr-pat-hash) dbgr-pydbgr-pat-hash)
93 (defvar dbgr-pydbgr-command-hash (make-hash-table :test 'equal)
94 "Hash key is command name like 'shell' and the value is
95 the pydbgr command to use, like 'python'")
97 (setf (gethash "shell" dbgr-pydbgr-command-hash) "python")
98 (setf (gethash "pydbgr" dbgr-command-hash) dbgr-pydbgr-command-hash)
100 (provide-me "dbgr-pydbgr-")