1 ;;; Copyright (C) 2011, 2014-2015 Rocky Bernstein <rocky@gnu.org>
2 ;;; Common Python constants and regular expressions.
3 (eval-when-compile (require 'cl))
5 (require 'load-relative)
6 (require-relative-list '("../common/regexp" "../common/loc" "../common/track")
9 (defconst realgud-python-backtrace-loc-pat
11 :regexp "^[ \t]+File \"\\(.+\\)\", line \\([0-9]+\\)"
14 "A realgud-loc-pat struct that describes a Python backtrace (or
17 ;; Regular expression that pseudo-files in caller. For example:
19 (defconst realgud-python-ignore-file-re "<string>"
20 "Regular expression that pseudo-files of caller()")
22 (defun realgud-python-populate-command-keys (&optional map)
23 "Bind the debugger function key layout used by many debuggers.
25 \\{realgud-example-map-standard}"
26 (define-key map (kbd "C-c !b") 'realgud:goto-debugger-backtrace-line)
27 (define-key map (kbd "C-c !!") 'realgud:goto-lang-backtrace-line)
31 ;; Things common to the trepan Python debuggers
33 (defconst realgud:python-trepan-frame-start-regexp
34 "\\(?:^\\|\n\\)\\(->\\|##\\)")
36 (defconst realgud:python-trepan-frame-num-regexp
39 ;; Regular expression that describes a trepan2/3k location generally shown
40 ;; before a command prompt.
43 ;; (/usr/bin/zonetab2pot.py:15): <module>
44 ;; (/usr/bin/zonetab2pot.py:15 remapped <string>): <module>
46 ;; (c:\\mydirectory\\gcd.py:10): <module>
48 (defconst realgud:python-trepan-loc-pat
50 :regexp "^(\\(\\(?:[a-zA-Z]:\\)?[-a-zA-Z0-9_/.\\\\ ]+\\):\\([0-9]+\\)\\(?: remapped .*?\\)?): \\(?:<module>\\)?\\(?:\n.. [0-9]+ \\(.*?\\)\n\\)?"
54 :ignore-file-re realgud-python-ignore-file-re)
55 "A realgud-loc-pat struct that describes a Python trepan
58 ;; Regular expression that describes a trepan2/3k backtrace line.
60 ;; ->0 get_distribution(dist='trepan==0.3.9')
61 ;; called from file '/python2.7/dist-packages/pkg_res.py' at line 341
62 ;; ##1 load_entry_point(dist='tr=0.3.9', group='console_scripts', name='tr')
63 ;; called from file '/python2.7/dist-packages/pkg_res.py' at line 351
64 ;; ##2 <module> exec()
66 (defconst realgud:python-trepan-backtrace-pat
69 realgud:python-trepan-frame-start-regexp
70 realgud:python-trepan-frame-num-regexp "[ ]"
71 "\\(?:.*?)\\)\\(?:[\n\t ]+?\\)"
72 "\\(?:called from file \\)?'\\([^:]+?\\)' at line \\([0-9]+\\)")
76 :ignore-file-re realgud-python-ignore-file-re)
77 "A realgud-loc-pat struct that describes a Python trepan
78 backtrace location line." )
80 ;; Regular expression that describes a "breakpoint set" line
81 (defconst realgud:python-trepan-brkpt-set-pat
83 :regexp "^Breakpoint \\([0-9]+\\) set at line \\([0-9]+\\)[ \t\n]+of file \\(.+\\)\\(\n\\|$\\)"
88 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
89 (defconst realgud:python-trepan-brkpt-del-pat
91 :regexp "^Deleted breakpoint \\([0-9]+\\)\n"
94 (defconst realgud:python-debugger-font-lock-keywords
96 ;; The frame number and first type name, if present.
97 ("^\\(->\\|##\\)\\([0-9]+\\) \\(<module>\\)? *\\([a-zA-Z_][a-zA-Z0-9_]*\\)(\\(.+\\))?"
98 (2 realgud-backtrace-number-face)
99 (4 font-lock-function-name-face nil t)) ; t means optional.
101 ;; Parameter sequence, E.g. gcd(a=3, b=5)
104 (1 font-lock-variable-name-face))
106 ;; File name. E.g file '/test/gcd.py'
107 ;; ------^^^^^^^^^^^^-
108 ("[ \t]+file '\\([^ ]+*\\)'"
109 (1 realgud-file-name-face))
111 ;; Line number. E.g. at line 28
113 ("[ \t]+at line \\([0-9]+\\)$"
114 (1 realgud-line-number-face))
117 ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
118 (1 font-lock-type-face)
119 (2 font-lock-function-name-face))
120 ;; (trepan2-frames-match-current-line
121 ;; (0 trepan2-frames-current-frame-face append))
126 (provide-me "realgud-lang-")