1 ;;; Copyright (C) 2010 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"
12 (defvar dbgr-pat-hash)
13 (declare-function make-dbgr-loc-pat (dbgr-loc))
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
20 (declare-function make-dbgr-loc "dbgr-loc" (a b c d e f))
22 ;; Regular expression that describes a pydbgr location generally shown
23 ;; before a command prompt.
25 ;; Program-location lines look like this:
26 ;; (/usr/bin/zonetab2pot.py:15): <module>
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)
33 :regexp "^(\\(\\(?:[a-zA-Z]:\\)?[-a-zA-Z0-9_/.\\\\ ]+\\):\\([0-9]+\\))"
37 (setf (gethash "prompt" dbgr-pydbgr-pat-hash)
42 ;; Regular expression that describes a Python backtrace line.
43 (setf (gethash "backtrace" dbgr-pydbgr-pat-hash)
45 :regexp "^[ \t]+File \"\\(.+\\)\", line \\([0-9]+\\)"
49 ;; Regular expression that describes a "breakpoint set" line
50 (setf (gethash "brkpt-set" dbgr-pydbgr-pat-hash)
52 :regexp "^Breakpoint \\([0-9]+\\) set at line \\([0-9]+\\)[ \t\n]+of file \\(.+\\)\\(\n\\|$\\)"
57 ;; Regular expression that describes a "delete breakpoint" line
58 (setf (gethash "brkpt-del" dbgr-pydbgr-pat-hash)
60 :regexp "^Deleted breakpoint \\([0-9]+\\)\n"
63 (setf (gethash "font-lock-keywords" dbgr-pydbgr-pat-hash)
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.
70 ;; Parameter sequence, E.g. gcd(a=3, b=5)
73 (1 font-lock-variable-name-face))
75 ;; File name. E.g file '/test/gcd.py'
76 ;; ------^^^^^^^^^^^^-
77 ("[ \t]+file '\\([^ ]+*\\)'"
78 (1 dbgr-file-name-face))
80 ;; Line number. E.g. at line 28
82 ("[ \t]+at line \\([0-9]+\\)$"
83 (1 dbgr-line-number-face))
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))
93 (setf (gethash "pydbgr" dbgr-pat-hash) dbgr-pydbgr-pat-hash)
95 (provide-me "dbgr-pydbgr-")