]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud/debugger/nodejs/init.el
Add 'packages/realgud/' from commit 'd811316e6a0f4eeee8a1347f504c196c86baa2cb'
[gnu-emacs-elpa] / packages / realgud / realgud / debugger / nodejs / init.el
1 ;;; Copyright (C) 2014 Rocky Bernstein <rocky@gnu.org>
2 ;;; Regular expressions for nodejs Javascript debugger.
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 "realgud-")
11 (require-relative-list '("../../lang/posix-shell") "realgud-lang-")
12
13 (defvar realgud:nodejs-pat-hash)
14 (declare-function make-realgud-loc-pat (realgud-loc))
15
16 (defvar realgud:nodejs-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 realgud-loc-pat struct")
20
21 (defvar realgud:nodejs-term-escape "\e[[0-9]+[GKJ]"
22 "Escape sequence regular expression pattern nodejs often puts in around prompts")
23
24 ;; Regular expression that describes a nodejs location generally shown
25 ;; before a command prompt.
26 ;; For example:
27 ;; break in /home/indutny/Code/git/indutny/myscript.js:1
28 (setf (gethash "loc" realgud:nodejs-pat-hash)
29 (make-realgud-loc-pat
30 :regexp (format
31 "\\(?:%s\\)*break in \\([^:]+\\):\\([0-9]*\\)"
32 realgud:nodejs-term-escape)
33 :file-group 1
34 :line-group 2))
35
36 ;; Regular expression that describes a nodejs command prompt
37 ;; For example:
38 ;; debug>
39 (setf (gethash "prompt" realgud:nodejs-pat-hash)
40 (make-realgud-loc-pat
41 :regexp (format "^\\(?:%s\\)*debug> " realgud:nodejs-term-escape)
42 ))
43
44 ;; Regular expression that describes a "breakpoint set" line
45 ;; * 4 var count = 0;
46 (setf (gethash "brkpt-set" realgud:nodejs-pat-hash)
47 (make-realgud-loc-pat
48 :regexp "^[*] \\([0-9]+\\) "
49 :line-group 1))
50
51 ;; Regular expression that describes a debugger "delete" (breakpoint) response.
52 ;; For example:
53 ;; Removed 1 breakpoint(s).
54 (setf (gethash "brkpt-del" realgud:nodejs-pat-hash)
55 (make-realgud-loc-pat
56 :regexp "^Removed \\([0-9]+\\) breakpoint(s).\n"
57 :num 1))
58
59 ;; Regular expression that describes a debugger "backtrace" command line.
60 ;; For example:
61 ;; #0 module.js:380:17
62 ;; #1 dbgtest.js:3:9
63 ;; #2 Module._compile module.js:456:26
64 ;; #3 Module._extensions..js module.js:474:10
65 ;; #4 Module.load module.js:356:32
66 ;; #5 Module._load module.js:312:12
67 ;; #6 Module.runMain module.js:497:10
68 ; ;#7 timers.js:110:15
69
70 ;; (setf (gethash "debugger-backtrace" realgud:nodejs-pat-hash)
71 ;; (make-realgud-loc-pat
72 ;; :regexp (concat realgud-shell-frame-start-regexp
73 ;; realgud-shell-frame-num-regexp "[ ]?"
74 ;; "\\(.*\\)"
75 ;; realgud-shell-frame-file-regexp
76 ;; "\\(?:" realgud-shell-frame-line-regexp "\\)?"
77 ;; )
78 ;; :num 2
79 ;; :file-group 4
80 ;; :line-group 5)
81 ;; )
82
83 ;; ;; Regular expression that for a termination message.
84 ;; (setf (gethash "termination" realgud:nodejs-pat-hash)
85 ;; "^nodejs: That's all, folks...\n")
86
87 (setf (gethash "font-lock-keywords" realgud:nodejs-pat-hash)
88 '(
89 ;; The frame number and first type name, if present.
90 ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
91 ;; --^-
92 ("^\\(->\\|##\\)\\([0-9]+\\) "
93 (2 realgud-backtrace-number-face))
94
95 ;; File name.
96 ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
97 ;; ---------^^^^^^^^^^^^^^^^^^^^-
98 ("[ \t]+\\(in\\|from\\) file `\\(.+\\)'"
99 (2 realgud-file-name-face))
100
101 ;; File name.
102 ;; E.g. ->0 in file `/etc/init.d/apparmor' at line 35
103 ;; --------^^
104 ;; Line number.
105 ("[ \t]+at line \\([0-9]+\\)$"
106 (1 realgud-line-number-face))
107 ))
108
109 (setf (gethash "nodejs" realgud-pat-hash) realgud:nodejs-pat-hash)
110
111 (defvar realgud:nodejs-command-hash (make-hash-table :test 'equal)
112 "Hash key is command name like 'finish' and the value is
113 the nodejs command to use, like 'out'")
114
115 (setf (gethash "nodejs" realgud-command-hash realgud:nodejs-command-hash))
116
117 (setf (gethash "backtrace" realgud:nodejs-command-hash) "T")
118 (setf (gethash "continue" realgud:nodejs-command-hash) "cont")
119 (setf (gethash "quit" realgud:nodejs-command-hash) "quit")
120 (setf (gethash "finish" realgud:nodejs-command-hash) "out")
121 (setf (gethash "shell" realgud:nodejs-command-hash) "repl")
122 (setf (gethash "step" realgud:nodejs-command-hash) "step")
123 (setf (gethash "next" realgud:nodejs-command-hash) "next")
124
125 (provide-me "realgud:nodejs-")